BT16_059.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT16
  4. {
  5. public class BT16_059 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. # region Alternate Digivolution Requirement
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. if (targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4)
  16. {
  17. if (targetPermanent.TopCard.HasText("Pulsemon"))
  18. {
  19. return true;
  20. }
  21. }
  22. return false;
  23. }
  24. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  25. permanentCondition: PermanentCondition,
  26. digivolutionCost: 3,
  27. ignoreDigivolutionRequirement: false,
  28. card: card,
  29. condition: null));
  30. }
  31. #endregion
  32. #region On Play
  33. if (timing == EffectTiming.OnEnterFieldAnyone)
  34. {
  35. ActivateClass activateClass = new ActivateClass();
  36. activateClass.SetUpICardEffect("De-Digivolve 1 digimon, then delete 1 digimon ", CanUseCondition, card);
  37. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  38. cardEffects.Add(activateClass);
  39. string EffectDiscription()
  40. {
  41. return "[On Play] If you have 3 or more security cards, <De-Digivolve 1> 1 of your opponent's Digimon. If you have 3 or fewer security cards, delete 1 of your opponent's Digimon with a play cost of 6 or less.";
  42. }
  43. bool CanSelectDeletePermanentCondition(Permanent permanent)
  44. {
  45. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  46. {
  47. if (permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 6)
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanSelectDeDigivolvePermanentCondition(Permanent permanent)
  55. {
  56. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.IsExistOnBattleArea(card);
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable hashtable)
  67. {
  68. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  69. if (card.Owner.SecurityCards.Count >= 3)
  70. {
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectDeDigivolvePermanentCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: 1,
  77. canNoSelect: false,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: null,
  80. afterSelectPermanentCoroutine: AfterSelectDedigivolveCoroutine,
  81. mode: SelectPermanentEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  84. IEnumerator AfterSelectDedigivolveCoroutine(List<Permanent> permanents)
  85. {
  86. foreach (Permanent permanent in permanents)
  87. {
  88. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 1, activateClass).Degeneration());
  89. }
  90. }
  91. }
  92. if (card.Owner.SecurityCards.Count <= 3)
  93. {
  94. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDeletePermanentCondition))
  95. {
  96. selectPermanentEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: CanSelectDeletePermanentCondition,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. maxCount: 1,
  102. canNoSelect: false,
  103. canEndNotMax: false,
  104. selectPermanentCoroutine: null,
  105. afterSelectPermanentCoroutine: null,
  106. mode: SelectPermanentEffect.Mode.Destroy,
  107. cardEffect: activateClass);
  108. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  109. }
  110. }
  111. }
  112. }
  113. #endregion
  114. #region When Digivolving
  115. if (timing == EffectTiming.OnEnterFieldAnyone)
  116. {
  117. ActivateClass activateClass = new ActivateClass();
  118. activateClass.SetUpICardEffect("De-Digivolve 1 digimon, then delete 1 digimon ", CanUseCondition, card);
  119. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  120. cardEffects.Add(activateClass);
  121. string EffectDiscription()
  122. {
  123. return "[When Digivolving] If you have 3 or more security cards, <De-Digivolve 1> 1 of your opponent's Digimon. If you have 3 or fewer security cards, delete 1 of your opponent's Digimon with a play cost of 6 or less.";
  124. }
  125. bool CanSelectDeletePermanentCondition(Permanent permanent)
  126. {
  127. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  128. {
  129. if (permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 6)
  130. {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. bool CanSelectDeDigivolvePermanentCondition(Permanent permanent)
  137. {
  138. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  139. }
  140. bool CanUseCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  143. }
  144. bool CanActivateCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.IsExistOnBattleArea(card);
  147. }
  148. IEnumerator ActivateCoroutine(Hashtable hashtable)
  149. {
  150. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  151. if (card.Owner.SecurityCards.Count >= 3)
  152. {
  153. selectPermanentEffect.SetUp(
  154. selectPlayer: card.Owner,
  155. canTargetCondition: CanSelectDeDigivolvePermanentCondition,
  156. canTargetCondition_ByPreSelecetedList: null,
  157. canEndSelectCondition: null,
  158. maxCount: 1,
  159. canNoSelect: false,
  160. canEndNotMax: false,
  161. selectPermanentCoroutine: null,
  162. afterSelectPermanentCoroutine: AfterSelectDedigivolveCoroutine,
  163. mode: SelectPermanentEffect.Mode.Custom,
  164. cardEffect: activateClass);
  165. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  166. IEnumerator AfterSelectDedigivolveCoroutine(List<Permanent> permanents)
  167. {
  168. foreach (Permanent permanent in permanents)
  169. {
  170. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 1, activateClass).Degeneration());
  171. }
  172. }
  173. }
  174. if (card.Owner.SecurityCards.Count <= 3)
  175. {
  176. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDeletePermanentCondition))
  177. {
  178. selectPermanentEffect.SetUp(
  179. selectPlayer: card.Owner,
  180. canTargetCondition: CanSelectDeletePermanentCondition,
  181. canTargetCondition_ByPreSelecetedList: null,
  182. canEndSelectCondition: null,
  183. maxCount: 1,
  184. canNoSelect: false,
  185. canEndNotMax: false,
  186. selectPermanentCoroutine: null,
  187. afterSelectPermanentCoroutine: null,
  188. mode: SelectPermanentEffect.Mode.Destroy,
  189. cardEffect: activateClass);
  190. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  191. }
  192. }
  193. }
  194. }
  195. #endregion
  196. #region End Of Attack - ESS
  197. if (timing == EffectTiming.OnEndAttack)
  198. {
  199. ActivateClass activateClass = new ActivateClass();
  200. activateClass.SetUpICardEffect("Unsuspend this Digimon by trashing the top card of your security.", CanUseCondition, card);
  201. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  202. activateClass.SetIsInheritedEffect(true);
  203. activateClass.SetHashString("Inherit_BT16_059");
  204. cardEffects.Add(activateClass);
  205. string EffectDiscription()
  206. {
  207. return "[End of Attack] [Once per turn] If this Digimon has [Pulsemon] in its text, by trashing the top card of your security stack, unsuspend this Digimon.";
  208. }
  209. bool CanUseCondition(Hashtable hashtable)
  210. {
  211. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  212. }
  213. bool CanActivateCondition(Hashtable hashtable)
  214. {
  215. if (CardEffectCommons.IsExistOnBattleArea(card))
  216. {
  217. if (card.PermanentOfThisCard().TopCard.HasText("Pulsemon"))
  218. {
  219. if (card.Owner.SecurityCards.Count >= 1)
  220. {
  221. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  222. {
  223. return true;
  224. }
  225. }
  226. }
  227. }
  228. return false;
  229. }
  230. bool PermanentCondition(Permanent permanent)
  231. {
  232. if (permanent == card.PermanentOfThisCard())
  233. {
  234. if (card.PermanentOfThisCard().TopCard.HasText("Pulsemon"))
  235. {
  236. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  237. {
  238. return true;
  239. }
  240. }
  241. }
  242. return false;
  243. }
  244. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  245. {
  246. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  247. player: card.Owner,
  248. destroySecurityCount: 1,
  249. cardEffect: activateClass,
  250. fromTop: true).DestroySecurity());
  251. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  252. {
  253. Permanent selectedPermanent = card.PermanentOfThisCard();
  254. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  255. }
  256. }
  257. }
  258. #endregion
  259. return cardEffects;
  260. }
  261. }
  262. }