BT16_023.cs 14 KB

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