EX9_045.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Cernumon
  5. namespace DCGO.CardEffects.EX9
  6. {
  7. public class EX9_045 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region DNA
  13. if (timing == EffectTiming.None)
  14. {
  15. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  16. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  17. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  18. addJogressConditionClass.SetNotShowUI(true);
  19. cardEffects.Add(addJogressConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. JogressCondition GetJogress(CardSource cardSource)
  25. {
  26. if (cardSource == card)
  27. {
  28. bool PermanentCondition1(Permanent permanent) => (permanent.TopCard.CardColors.Contains(CardColor.Green) || permanent.TopCard.CardColors.Contains(CardColor.Yellow)) && permanent.Levels_ForJogress(card).Contains(6);
  29. bool PermanentCondition2(Permanent permanent) => (permanent.TopCard.CardColors.Contains(CardColor.Blue) || permanent.TopCard.CardColors.Contains(CardColor.Purple)) && permanent.Levels_ForJogress(card).Contains(6);
  30. JogressConditionElement[] elements = new JogressConditionElement[]
  31. {
  32. new JogressConditionElement(PermanentCondition1, "a level 6 green/yellow Digimon"),
  33. new JogressConditionElement(PermanentCondition2, "a level 6 blue/purple Digimon"),
  34. };
  35. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  36. return jogressCondition;
  37. }
  38. return null;
  39. }
  40. }
  41. #endregion
  42. #region Alliance
  43. if (timing == EffectTiming.OnAllyAttack)
  44. {
  45. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  46. }
  47. #endregion
  48. #region Blocker
  49. if (timing == EffectTiming.None)
  50. {
  51. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  52. }
  53. #endregion
  54. #region When Digivolving
  55. if (timing == EffectTiming.OnEnterFieldAnyone)
  56. {
  57. ActivateClass activateClass = new ActivateClass();
  58. activateClass.SetUpICardEffect("Play 1 digimon, then if DNA bounce 2 digimon", CanUseCondition, card);
  59. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  60. cardEffects.Add(activateClass);
  61. string EffectDiscription()
  62. {
  63. return "[When Digivolving] you may play 1 play cost 7 or lower [WG] trait Digimon card from your hand without paying the cost. Then, if DNA digivolving, you may return up to 2 of your opponent's Digimon to the bottom of the deck.";
  64. }
  65. bool CanUseCondition(Hashtable hashtable)
  66. {
  67. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  68. }
  69. bool CanActivateCondition(Hashtable hashtable)
  70. {
  71. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  72. }
  73. bool CanSelectCardCondition(CardSource cardSource)
  74. {
  75. if (cardSource.HasWGTraits && cardSource.GetCostItself <= 7)
  76. {
  77. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  78. {
  79. return true;
  80. }
  81. }
  82. return false;
  83. }
  84. bool CanSelectPermanentCondition(Permanent permanent)
  85. {
  86. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  87. }
  88. IEnumerator ActivateCoroutine(Hashtable hashtable)
  89. {
  90. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  91. {
  92. List<CardSource> selectedCards = new List<CardSource>();
  93. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  94. selectHandEffect.SetUp(
  95. selectPlayer: card.Owner,
  96. canTargetCondition: CanSelectCardCondition,
  97. canTargetCondition_ByPreSelecetedList: null,
  98. canEndSelectCondition: null,
  99. maxCount: 1,
  100. canNoSelect: true,
  101. canEndNotMax: false,
  102. isShowOpponent: true,
  103. selectCardCoroutine: SelectCardCoroutine,
  104. afterSelectCardCoroutine: null,
  105. mode: SelectHandEffect.Mode.Custom,
  106. cardEffect: activateClass);
  107. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  108. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  109. yield return StartCoroutine(selectHandEffect.Activate());
  110. IEnumerator SelectCardCoroutine(CardSource cardSource)
  111. {
  112. selectedCards.Add(cardSource);
  113. yield return null;
  114. }
  115. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  116. cardSources: selectedCards,
  117. activateClass: activateClass,
  118. payCost: false,
  119. isTapped: false,
  120. root: SelectCardEffect.Root.Hand,
  121. activateETB: true));
  122. }
  123. if (CardEffectCommons.IsJogress(hashtable) && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  124. {
  125. int maxCount1 = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  126. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  127. selectPermanentEffect.SetUp(
  128. selectPlayer: card.Owner,
  129. canTargetCondition: CanSelectPermanentCondition,
  130. canTargetCondition_ByPreSelecetedList: null,
  131. canEndSelectCondition: null,
  132. maxCount: maxCount1,
  133. canNoSelect: true,
  134. canEndNotMax: true,
  135. selectPermanentCoroutine: null,
  136. afterSelectPermanentCoroutine: null,
  137. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  138. cardEffect: activateClass);
  139. selectPermanentEffect.SetUpCustomMessage("Select up to 2 Digimon to bounce", "The opponent is selecting up to 2 Digimon to bounce");
  140. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  141. }
  142. }
  143. }
  144. #endregion
  145. #region All Turns - When Removed
  146. if (timing == EffectTiming.WhenRemoveField)
  147. {
  148. ActivateClass activateClass = new ActivateClass();
  149. activateClass.SetUpICardEffect("Play a 7 or less cost [WG] Digimon", CanUseCondition, card);
  150. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  151. activateClass.SetHashString("EX9_045_Play");
  152. cardEffects.Add(activateClass);
  153. string EffectDiscription()
  154. {
  155. return "[All Turns] [Once Per Turn] When any of your [WG] trait Digimon would leave the battle area other than in battle, you may play 1 play cost 7 or lower [WG] trait Digimon card from your hand without paying the cost.";
  156. }
  157. bool HasWGDigimon(Permanent permanent)
  158. {
  159. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  160. return permanent.TopCard.EqualsTraits("WG");
  161. return false;
  162. }
  163. bool CanUseCondition(Hashtable hashtable)
  164. {
  165. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  166. {
  167. if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, HasWGDigimon))
  168. {
  169. if (!CardEffectCommons.IsByBattle(hashtable))
  170. {
  171. return true;
  172. }
  173. }
  174. }
  175. return false;
  176. }
  177. bool CanActivateCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  180. }
  181. bool CanSelectCardCondition(CardSource cardSource)
  182. {
  183. if (cardSource.EqualsTraits("WG") && cardSource.GetCostItself <= 7)
  184. {
  185. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  186. {
  187. return true;
  188. }
  189. }
  190. return false;
  191. }
  192. IEnumerator ActivateCoroutine(Hashtable hashtable)
  193. {
  194. if (CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectCardCondition) >= 1)
  195. {
  196. List<CardSource> selectedCards = new List<CardSource>();
  197. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectCardCondition));
  198. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  199. selectHandEffect.SetUp(
  200. selectPlayer: card.Owner,
  201. canTargetCondition: CanSelectCardCondition,
  202. canTargetCondition_ByPreSelecetedList: null,
  203. canEndSelectCondition: null,
  204. maxCount: maxCount,
  205. canNoSelect: true,
  206. canEndNotMax: false,
  207. isShowOpponent: true,
  208. selectCardCoroutine: SelectCardCoroutine,
  209. afterSelectCardCoroutine: null,
  210. mode: SelectHandEffect.Mode.Custom,
  211. cardEffect: activateClass);
  212. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  213. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  214. yield return StartCoroutine(selectHandEffect.Activate());
  215. IEnumerator SelectCardCoroutine(CardSource cardSource)
  216. {
  217. selectedCards.Add(cardSource);
  218. yield return null;
  219. }
  220. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  221. cardSources: selectedCards,
  222. activateClass: activateClass,
  223. payCost: false,
  224. isTapped: false,
  225. root: SelectCardEffect.Root.Hand,
  226. activateETB: true));
  227. }
  228. }
  229. }
  230. #endregion
  231. return cardEffects;
  232. }
  233. }
  234. }