EX7_029.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX7
  6. {
  7. public class EX7_029 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel5 &&
  18. (targetPermanent.TopCard.ContainsTraits("NSp") || targetPermanent.TopCard.ContainsCardName("Leomon"));
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 3,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Ace - Blast Digivolve
  30. if (timing == EffectTiming.OnCounterTiming)
  31. {
  32. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  33. }
  34. #endregion
  35. #region On Play/ When Digivolving Shared
  36. bool CanSelectPermanentSharedCondition1(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  39. permanent.IsSuspended;
  40. }
  41. bool CanActivateSharedCondition1(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  44. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition1);
  45. }
  46. #endregion
  47. #region On Play
  48. if (timing == EffectTiming.OnEnterFieldAnyone)
  49. {
  50. ActivateClass activateClass = new ActivateClass();
  51. activateClass.SetUpICardEffect("2 suspended Digimon get DP -8000", CanUseCondition, card);
  52. activateClass.SetUpActivateClass(CanActivateSharedCondition1, ActivateCoroutine, -1, false,
  53. EffectDescription());
  54. cardEffects.Add(activateClass);
  55. string EffectDescription()
  56. {
  57. return "[On Play] 2 of your opponent's suspended Digimon get -8000 DP until the end of your turn.";
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable hashtable)
  64. {
  65. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition1))
  66. {
  67. SelectPermanentEffect selectPermanentEffect =
  68. GManager.instance.GetComponent<SelectPermanentEffect>();
  69. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentSharedCondition1));
  70. selectPermanentEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: CanSelectPermanentSharedCondition1,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: maxCount,
  76. canNoSelect: false,
  77. canEndNotMax: false,
  78. selectPermanentCoroutine: SelectPermanentCoroutine,
  79. afterSelectPermanentCoroutine: null,
  80. mode: SelectPermanentEffect.Mode.Custom,
  81. cardEffect: activateClass);
  82. selectPermanentEffect.SetUpCustomMessage("Select Digimon that will get DP -8000.",
  83. "The opponent is selecting Digimon that will get DP -8000.");
  84. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  85. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  86. {
  87. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  88. targetPermanent: permanent,
  89. changeValue: -8000,
  90. effectDuration: EffectDuration.UntilOwnerTurnEnd,
  91. activateClass: activateClass));
  92. }
  93. }
  94. }
  95. }
  96. #endregion
  97. #region When Digivolving
  98. if (timing == EffectTiming.OnEnterFieldAnyone)
  99. {
  100. ActivateClass activateClass = new ActivateClass();
  101. activateClass.SetUpICardEffect("2 suspended Digimon get DP -8000", CanUseCondition, card);
  102. activateClass.SetUpActivateClass(CanActivateSharedCondition1, ActivateCoroutine, -1, false,
  103. EffectDescription());
  104. cardEffects.Add(activateClass);
  105. string EffectDescription()
  106. {
  107. return "[When Digivolving] 2 of your opponent's suspended Digimon get -8000 DP until the end of your turn.";
  108. }
  109. bool CanUseCondition(Hashtable hashtable)
  110. {
  111. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  112. }
  113. IEnumerator ActivateCoroutine(Hashtable hashtable)
  114. {
  115. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition1))
  116. {
  117. SelectPermanentEffect selectPermanentEffect =
  118. GManager.instance.GetComponent<SelectPermanentEffect>();
  119. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentSharedCondition1));
  120. selectPermanentEffect.SetUp(
  121. selectPlayer: card.Owner,
  122. canTargetCondition: CanSelectPermanentSharedCondition1,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. maxCount: maxCount,
  126. canNoSelect: false,
  127. canEndNotMax: false,
  128. selectPermanentCoroutine: SelectPermanentCoroutine,
  129. afterSelectPermanentCoroutine: null,
  130. mode: SelectPermanentEffect.Mode.Custom,
  131. cardEffect: activateClass);
  132. selectPermanentEffect.SetUpCustomMessage("Select Digimon that will get DP -8000.",
  133. "The opponent is selecting Digimon that will get DP -8000.");
  134. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  135. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  136. {
  137. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  138. targetPermanent: permanent,
  139. changeValue: -8000,
  140. effectDuration: EffectDuration.UntilOwnerTurnEnd,
  141. activateClass: activateClass));
  142. }
  143. }
  144. }
  145. }
  146. #endregion
  147. #region When Digivolving/ When Attacking Shared
  148. bool CanSelectPermanentSharedCondition2(Permanent permanent)
  149. {
  150. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  151. }
  152. bool CanActivateSharedCondition2(Hashtable hashtable)
  153. {
  154. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  155. (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition2) ||
  156. card.Owner.Enemy.GetBattleAreaDigimons().Count(permanent => !permanent.IsSuspended) == 0);
  157. }
  158. #endregion
  159. #region When Digivolving
  160. if (timing == EffectTiming.OnEnterFieldAnyone)
  161. {
  162. ActivateClass activateClass = new ActivateClass();
  163. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  164. activateClass.SetUpActivateClass(CanActivateSharedCondition2, ActivateCoroutine, 1, false, EffectDescription());
  165. activateClass.SetHashString("Suspend_EX7_029");
  166. cardEffects.Add(activateClass);
  167. string EffectDescription()
  168. {
  169. return
  170. "[When Digivolving] Suspend 1 of your opponent's Digimon. Then, if your opponent has no unsuspended Digimon, unsuspend this Digimon.";
  171. }
  172. bool CanUseCondition(Hashtable hashtable)
  173. {
  174. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  175. }
  176. IEnumerator ActivateCoroutine(Hashtable hashtable)
  177. {
  178. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition2))
  179. {
  180. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  181. selectPermanentEffect.SetUp(
  182. selectPlayer: card.Owner,
  183. canTargetCondition: CanSelectPermanentSharedCondition2,
  184. canTargetCondition_ByPreSelecetedList: null,
  185. canEndSelectCondition: null,
  186. maxCount: 1,
  187. canNoSelect: false,
  188. canEndNotMax: false,
  189. selectPermanentCoroutine: null,
  190. afterSelectPermanentCoroutine: null,
  191. mode: SelectPermanentEffect.Mode.Tap,
  192. cardEffect: activateClass);
  193. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  194. }
  195. if (card.Owner.Enemy.GetBattleAreaDigimons().Count(permanent => !permanent.IsSuspended) == 0)
  196. {
  197. yield return ContinuousController.instance.StartCoroutine(
  198. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  199. }
  200. }
  201. }
  202. #endregion
  203. #region When Attacking
  204. if (timing == EffectTiming.OnAllyAttack)
  205. {
  206. ActivateClass activateClass = new ActivateClass();
  207. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  208. activateClass.SetUpActivateClass(CanActivateSharedCondition2, ActivateCoroutine, 1, false, EffectDescription());
  209. activateClass.SetHashString("Suspend_EX7_029");
  210. cardEffects.Add(activateClass);
  211. string EffectDescription()
  212. {
  213. return
  214. "[When Attacking] Suspend 1 of your opponent's Digimon. Then, if your opponent has no unsuspended Digimon, unsuspend this Digimon.";
  215. }
  216. bool CanUseCondition(Hashtable hashtable)
  217. {
  218. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  219. }
  220. IEnumerator ActivateCoroutine(Hashtable hashtable)
  221. {
  222. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition2))
  223. {
  224. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  225. selectPermanentEffect.SetUp(
  226. selectPlayer: card.Owner,
  227. canTargetCondition: CanSelectPermanentSharedCondition2,
  228. canTargetCondition_ByPreSelecetedList: null,
  229. canEndSelectCondition: null,
  230. maxCount: 1,
  231. canNoSelect: false,
  232. canEndNotMax: false,
  233. selectPermanentCoroutine: null,
  234. afterSelectPermanentCoroutine: null,
  235. mode: SelectPermanentEffect.Mode.Tap,
  236. cardEffect: activateClass);
  237. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  238. }
  239. if (card.Owner.Enemy.GetBattleAreaDigimons().Count(permanent => !permanent.IsSuspended) == 0)
  240. {
  241. yield return ContinuousController.instance.StartCoroutine(
  242. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  243. }
  244. }
  245. }
  246. #endregion
  247. return cardEffects;
  248. }
  249. }
  250. }