EX7_059.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX7
  6. {
  7. public class EX7_059 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasText("Three Musketeers") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5 || targetPermanent.TopCard.HasText("ThreeMusketeers") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Blast Digivolve
  23. if (timing == EffectTiming.OnCounterTiming)
  24. {
  25. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  26. }
  27. #endregion
  28. #region On Play
  29. if (timing == EffectTiming.OnEnterFieldAnyone)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Return 1 Option from trash then play an Option", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  34. cardEffects.Add(activateClass);
  35. string EffectDiscription()
  36. {
  37. return "[On Play] Return 1 Option card from your trash to the hand. Then, you may use 1 Option card with the [Three Musketeers] trait from your hand without paying the cost.";
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  46. {
  47. return true;
  48. }
  49. return false;
  50. }
  51. bool CanSelectCardCondition(CardSource cardSource)
  52. {
  53. if (cardSource.IsOption)
  54. {
  55. return true;
  56. }
  57. return false;
  58. }
  59. bool CanSelectCardCondition1(CardSource cardSource)
  60. {
  61. if (cardSource.IsOption)
  62. {
  63. if (cardSource.CardTraits.Contains("Three Musketeers") || cardSource.CardTraits.Contains("ThreeMusketeers"))
  64. {
  65. if (cardSource.HasUseCost)
  66. {
  67. if (!cardSource.CanNotPlayThisOption)
  68. {
  69. return true;
  70. }
  71. }
  72. }
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  77. {
  78. List<CardSource> selectedCards = new List<CardSource>();
  79. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  80. {
  81. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  82. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  83. selectCardEffect.SetUp(
  84. canTargetCondition: CanSelectCardCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. canNoSelect: () => false,
  88. selectCardCoroutine: null,
  89. afterSelectCardCoroutine: null,
  90. message: "Select 1 card to add to your hand.",
  91. maxCount: maxCount,
  92. canEndNotMax: false,
  93. isShowOpponent: true,
  94. mode: SelectCardEffect.Mode.AddHand,
  95. root: SelectCardEffect.Root.Trash,
  96. customRootCardList: null,
  97. canLookReverseCard: true,
  98. selectPlayer: card.Owner,
  99. cardEffect: activateClass);
  100. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  101. }
  102. if (card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1)
  103. {
  104. int maxCount = 1;
  105. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  106. selectHandEffect.SetUp(
  107. selectPlayer: card.Owner,
  108. canTargetCondition: CanSelectCardCondition1,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. maxCount: maxCount,
  112. canNoSelect: true,
  113. canEndNotMax: false,
  114. isShowOpponent: true,
  115. selectCardCoroutine: SelectCardCoroutine,
  116. afterSelectCardCoroutine: null,
  117. mode: SelectHandEffect.Mode.Custom,
  118. cardEffect: activateClass);
  119. selectHandEffect.SetUpCustomMessage(
  120. "Select 1 option card to use.",
  121. "The opponent is selecting 1 option card to use.");
  122. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  123. yield return StartCoroutine(selectHandEffect.Activate());
  124. IEnumerator SelectCardCoroutine(CardSource cardSource)
  125. {
  126. selectedCards.Add(cardSource);
  127. yield return null;
  128. }
  129. }
  130. if (selectedCards.Count >= 1)
  131. {
  132. yield return ContinuousController.instance.StartCoroutine(
  133. CardEffectCommons.PlayOptionCards(
  134. cardSources: selectedCards,
  135. activateClass: activateClass,
  136. payCost: false,
  137. root: SelectCardEffect.Root.Hand
  138. )
  139. );
  140. }
  141. }
  142. }
  143. #endregion
  144. #region When Digivolving
  145. if (timing == EffectTiming.OnEnterFieldAnyone)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect("Return 1 Option from trash then play an Option", CanUseCondition, card);
  149. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  150. cardEffects.Add(activateClass);
  151. string EffectDiscription()
  152. {
  153. return "[When Digivolving] Return 1 Option card from your trash to the hand. Then, you may use 1 Option card with the [Three Musketeers] trait from your hand without paying the cost.";
  154. }
  155. bool CanUseCondition(Hashtable hashtable)
  156. {
  157. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  158. {
  159. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  160. {
  161. return true;
  162. }
  163. }
  164. return false;
  165. }
  166. bool CanActivateCondition(Hashtable hashtable)
  167. {
  168. if(CardEffectCommons.IsExistOnBattleArea(card))
  169. {
  170. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  171. {
  172. return true;
  173. }
  174. }
  175. return false;
  176. }
  177. bool CanSelectCardCondition(CardSource cardSource)
  178. {
  179. if (cardSource.IsOption)
  180. {
  181. return true;
  182. }
  183. return false;
  184. }
  185. bool CanSelectCardCondition1(CardSource cardSource)
  186. {
  187. if (cardSource.IsOption)
  188. {
  189. if (cardSource.EqualsTraits("Three Musketeers"))
  190. {
  191. if (cardSource.HasUseCost)
  192. {
  193. if (!cardSource.CanNotPlayThisOption)
  194. {
  195. return true;
  196. }
  197. }
  198. }
  199. }
  200. return false;
  201. }
  202. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  203. {
  204. List<CardSource> selectedCards = new List<CardSource>();
  205. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  206. {
  207. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  208. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  209. selectCardEffect.SetUp(
  210. canTargetCondition: CanSelectCardCondition,
  211. canTargetCondition_ByPreSelecetedList: null,
  212. canEndSelectCondition: null,
  213. canNoSelect: () => false,
  214. selectCardCoroutine: null,
  215. afterSelectCardCoroutine: null,
  216. message: "Select 1 card to add to your hand.",
  217. maxCount: maxCount,
  218. canEndNotMax: false,
  219. isShowOpponent: true,
  220. mode: SelectCardEffect.Mode.AddHand,
  221. root: SelectCardEffect.Root.Trash,
  222. customRootCardList: null,
  223. canLookReverseCard: true,
  224. selectPlayer: card.Owner,
  225. cardEffect: activateClass);
  226. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  227. }
  228. if (card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1)
  229. {
  230. int maxCount = 1;
  231. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  232. selectHandEffect.SetUp(
  233. selectPlayer: card.Owner,
  234. canTargetCondition: CanSelectCardCondition1,
  235. canTargetCondition_ByPreSelecetedList: null,
  236. canEndSelectCondition: null,
  237. maxCount: maxCount,
  238. canNoSelect: true,
  239. canEndNotMax: false,
  240. isShowOpponent: true,
  241. selectCardCoroutine: SelectCardCoroutine,
  242. afterSelectCardCoroutine: null,
  243. mode: SelectHandEffect.Mode.Custom,
  244. cardEffect: activateClass);
  245. selectHandEffect.SetUpCustomMessage(
  246. "Select 1 option card to use.",
  247. "The opponent is selecting 1 option card to use.");
  248. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  249. yield return StartCoroutine(selectHandEffect.Activate());
  250. IEnumerator SelectCardCoroutine(CardSource cardSource)
  251. {
  252. selectedCards.Add(cardSource);
  253. yield return null;
  254. }
  255. }
  256. if (selectedCards.Count >= 1)
  257. {
  258. yield return ContinuousController.instance.StartCoroutine(
  259. CardEffectCommons.PlayOptionCards(
  260. cardSources: selectedCards,
  261. activateClass: activateClass,
  262. payCost: false,
  263. root: SelectCardEffect.Root.Hand
  264. )
  265. );
  266. }
  267. }
  268. }
  269. #endregion
  270. #region When Attacking
  271. if (timing == EffectTiming.OnAllyAttack)
  272. {
  273. ActivateClass activateClass = new ActivateClass();
  274. activateClass.SetUpICardEffect("Return 1 digivolution card to play 1 Option", CanUseCondition, card);
  275. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  276. activateClass.SetHashString("PlayOption_EX7-059");
  277. cardEffects.Add(activateClass);
  278. string EffectDiscription()
  279. {
  280. return "[When Attacking] [Once Per Turn] By trashing 1 Option card from this Digimon's digivolution cards, you may use 1 Option card with the [Three Musketeers] trait from your hand without paying the cost.";
  281. }
  282. bool CanSelectCardCondition(CardSource cardSource)
  283. {
  284. if (cardSource.IsOption)
  285. {
  286. if (!cardSource.CanNotTrashFromDigivolutionCards(activateClass))
  287. {
  288. return true;
  289. }
  290. }
  291. return false;
  292. }
  293. bool CanUseCondition(Hashtable hashtable)
  294. {
  295. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  296. }
  297. bool CanActivateCondition(Hashtable hashtable)
  298. {
  299. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  300. {
  301. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  302. {
  303. return true;
  304. }
  305. }
  306. return false;
  307. }
  308. bool CanSelectCardCondition1(CardSource cardSource)
  309. {
  310. if (cardSource.IsOption)
  311. {
  312. if (cardSource.EqualsTraits("Three Musketeers"))
  313. {
  314. if (cardSource.HasUseCost)
  315. {
  316. if (!cardSource.CanNotPlayThisOption)
  317. {
  318. return true;
  319. }
  320. }
  321. }
  322. }
  323. return false;
  324. }
  325. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  326. {
  327. bool trashed = false;
  328. List<CardSource> selectedCards = new List<CardSource>();
  329. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  330. selectCardEffect.SetUp(
  331. canTargetCondition: CanSelectCardCondition,
  332. canTargetCondition_ByPreSelecetedList: null,
  333. canEndSelectCondition: null,
  334. canNoSelect: () => true,
  335. selectCardCoroutine: SelectCardCoroutine,
  336. afterSelectCardCoroutine: null,
  337. message: "Select 1 Option card to discard.",
  338. maxCount: 1,
  339. canEndNotMax: false,
  340. isShowOpponent: true,
  341. mode: SelectCardEffect.Mode.Custom,
  342. root: SelectCardEffect.Root.Custom,
  343. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  344. canLookReverseCard: true,
  345. selectPlayer: card.Owner,
  346. cardEffect: null);
  347. selectCardEffect.SetUpCustomMessage("Select 1 Option card to discard.", "The opponent is selecting 1 Option card to discard.");
  348. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  349. IEnumerator SelectCardCoroutine(CardSource cardSource)
  350. {
  351. selectedCards.Add(cardSource);
  352. yield return null;
  353. }
  354. if (selectedCards.Count >= 1)
  355. {
  356. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(card.PermanentOfThisCard(), selectedCards, activateClass).TrashDigivolutionCards());
  357. trashed = true;
  358. selectedCards.Clear();
  359. }
  360. if (trashed)
  361. {
  362. if (card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1)
  363. {
  364. int maxCount = 1;
  365. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  366. selectHandEffect.SetUp(
  367. selectPlayer: card.Owner,
  368. canTargetCondition: CanSelectCardCondition1,
  369. canTargetCondition_ByPreSelecetedList: null,
  370. canEndSelectCondition: null,
  371. maxCount: maxCount,
  372. canNoSelect: true,
  373. canEndNotMax: false,
  374. isShowOpponent: true,
  375. selectCardCoroutine: SelectCardCoroutine1,
  376. afterSelectCardCoroutine: null,
  377. mode: SelectHandEffect.Mode.Custom,
  378. cardEffect: activateClass);
  379. selectHandEffect.SetUpCustomMessage(
  380. "Select 1 option card to use.",
  381. "The opponent is selecting 1 option card to use.");
  382. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  383. yield return StartCoroutine(selectHandEffect.Activate());
  384. IEnumerator SelectCardCoroutine1(CardSource cardSource)
  385. {
  386. selectedCards.Add(cardSource);
  387. yield return null;
  388. }
  389. }
  390. if (selectedCards.Count >= 1)
  391. {
  392. yield return ContinuousController.instance.StartCoroutine(
  393. CardEffectCommons.PlayOptionCards(
  394. cardSources: selectedCards,
  395. activateClass: activateClass,
  396. payCost: false,
  397. root: SelectCardEffect.Root.Hand
  398. )
  399. );
  400. }
  401. }
  402. }
  403. }
  404. #endregion
  405. return cardEffects;
  406. }
  407. }
  408. }