BT20_027.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT20
  5. {
  6. public class BT20_027 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsCardName("Wingdramon") || targetPermanent.TopCard.EqualsCardName("Groundramon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition,
  19. digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Piercing
  23. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  24. {
  25. cardEffects.Add(CardEffectFactory.PierceSelfEffect(
  26. isInheritedEffect: false,
  27. card: card,
  28. condition: null));
  29. }
  30. #endregion
  31. #region On Play
  32. if (timing == EffectTiming.OnEnterFieldAnyone)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("Trash digivolution cards and delete 1 Digimon with no digivolution cards", CanUseCondition,
  36. card);
  37. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  38. cardEffects.Add(activateClass);
  39. string EffectDescription()
  40. {
  41. return
  42. "[On Play] Trash any 3 digivolution cards of 1 of your opponent's Digimon. Then, delete 1 of their Digimon with no digivolution cards.";
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  47. }
  48. bool CanSelectPermanentCondition(Permanent permanent)
  49. {
  50. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  51. permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  52. }
  53. bool CanSelectCardCondition(CardSource cardSource)
  54. {
  55. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  56. }
  57. bool CanSelectNoSourcePermanentCondition(Permanent permanent)
  58. {
  59. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  60. permanent.HasNoDigivolutionCards;
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  65. (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) ||
  66. CardEffectCommons.HasMatchConditionPermanent(CanSelectNoSourcePermanentCondition));
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable hashtable)
  69. {
  70. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  71. {
  72. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  73. permanentCondition: CanSelectPermanentCondition,
  74. cardCondition: CanSelectCardCondition,
  75. maxCount: 3,
  76. canNoTrash: false,
  77. isFromOnly1Permanent: true,
  78. activateClass: activateClass
  79. ));
  80. }
  81. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectNoSourcePermanentCondition))
  82. {
  83. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  84. selectPermanentEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: CanSelectNoSourcePermanentCondition,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: 1,
  90. canNoSelect: false,
  91. canEndNotMax: false,
  92. selectPermanentCoroutine: null,
  93. afterSelectPermanentCoroutine: null,
  94. mode: SelectPermanentEffect.Mode.Destroy,
  95. cardEffect: activateClass);
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. }
  98. }
  99. }
  100. #endregion
  101. #region When Digivolving
  102. if (timing == EffectTiming.OnEnterFieldAnyone)
  103. {
  104. ActivateClass activateClass = new ActivateClass();
  105. activateClass.SetUpICardEffect("Trash digivolution cards and delete 1 Digimon with no digivolution cards", CanUseCondition,
  106. card);
  107. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  108. cardEffects.Add(activateClass);
  109. string EffectDescription()
  110. {
  111. return
  112. "[When Digivolving] Trash any 3 digivolution cards of 1 of your opponent's Digimon. Then, delete 1 of their Digimon with no digivolution cards.";
  113. }
  114. bool CanUseCondition(Hashtable hashtable)
  115. {
  116. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  117. }
  118. bool CanSelectPermanentCondition(Permanent permanent)
  119. {
  120. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  121. permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  122. }
  123. bool CanSelectCardCondition(CardSource cardSource)
  124. {
  125. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  126. }
  127. bool CanSelectNoSourcePermanentCondition(Permanent permanent)
  128. {
  129. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  130. permanent.HasNoDigivolutionCards;
  131. }
  132. bool CanActivateCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  135. (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) ||
  136. CardEffectCommons.HasMatchConditionPermanent(CanSelectNoSourcePermanentCondition));
  137. }
  138. IEnumerator ActivateCoroutine(Hashtable hashtable)
  139. {
  140. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  141. {
  142. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  143. permanentCondition: CanSelectPermanentCondition,
  144. cardCondition: CanSelectCardCondition,
  145. maxCount: 3,
  146. canNoTrash: false,
  147. isFromOnly1Permanent: true,
  148. activateClass: activateClass
  149. ));
  150. }
  151. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectNoSourcePermanentCondition))
  152. {
  153. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  154. selectPermanentEffect.SetUp(
  155. selectPlayer: card.Owner,
  156. canTargetCondition: CanSelectNoSourcePermanentCondition,
  157. canTargetCondition_ByPreSelecetedList: null,
  158. canEndSelectCondition: null,
  159. maxCount: 1,
  160. canNoSelect: false,
  161. canEndNotMax: false,
  162. selectPermanentCoroutine: null,
  163. afterSelectPermanentCoroutine: null,
  164. mode: SelectPermanentEffect.Mode.Destroy,
  165. cardEffect: activateClass);
  166. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  167. }
  168. }
  169. }
  170. #endregion
  171. #region All Turns
  172. if (timing == EffectTiming.OnLoseSecurity)
  173. {
  174. ActivateClass activateClass = new ActivateClass();
  175. activateClass.SetUpICardEffect("Unsuspend 1 of your Digimon with [Dracomon]/[Examon] in its text", CanUseCondition, card);
  176. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  177. activateClass.SetHashString("Unsuspend_BT20_027");
  178. cardEffects.Add(activateClass);
  179. string EffectDescription()
  180. {
  181. return
  182. "[All Turns] (Once Per Turn) When your opponent's security stack is removed from, 1 of your Digimon with [Dracomon]/[Examon] in its text may unsuspend.";
  183. }
  184. bool CanUseCondition(Hashtable hashtable)
  185. {
  186. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  187. CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner.Enemy);
  188. }
  189. bool CanSelectPermanentCondition(Permanent permanent)
  190. {
  191. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  192. (permanent.TopCard.HasText("Dracomon") || permanent.TopCard.HasText("Examon")) &&
  193. permanent.CanUnsuspend;
  194. }
  195. bool CanActivateCondition(Hashtable hashtable)
  196. {
  197. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  198. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  199. }
  200. IEnumerator ActivateCoroutine(Hashtable hashtable)
  201. {
  202. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  203. selectPermanentEffect.SetUp(
  204. selectPlayer: card.Owner,
  205. canTargetCondition: CanSelectPermanentCondition,
  206. canTargetCondition_ByPreSelecetedList: null,
  207. canEndSelectCondition: null,
  208. maxCount: 1,
  209. canNoSelect: true,
  210. canEndNotMax: false,
  211. selectPermanentCoroutine: null,
  212. afterSelectPermanentCoroutine: null,
  213. mode: SelectPermanentEffect.Mode.UnTap,
  214. cardEffect: activateClass);
  215. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to unsuspend.",
  216. "The opponent is selecting 1 Digimon to unsuspend.");
  217. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  218. }
  219. }
  220. #endregion
  221. #region All Turns - ESS
  222. if (timing == EffectTiming.WhenRemoveField)
  223. {
  224. List<Permanent> removedPermanents = new List<Permanent>();
  225. ActivateClass activateClass = new ActivateClass();
  226. activateClass.SetUpICardEffect("Suspend this Digimon to prevent Digimon from leaving", CanUseCondition, card);
  227. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  228. activateClass.SetIsInheritedEffect(true);
  229. activateClass.SetHashString("AllTurns_BT20-027");
  230. cardEffects.Add(activateClass);
  231. string EffectDescription()
  232. {
  233. return
  234. "[All Turns] When any of your Digimon with [Dracomon]/[Examon] in their texts would leave the battle area other than in battle by suspending this Digimon, they don't leave.";
  235. }
  236. bool CanUseCondition(Hashtable hashtable)
  237. {
  238. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  239. CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, CanSelectPermanentCondition) &&
  240. !CardEffectCommons.IsByBattle(hashtable);
  241. }
  242. bool CanSelectPermanentCondition(Permanent permanent)
  243. {
  244. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  245. (permanent.TopCard.HasText("Dracomon") || permanent.TopCard.HasText("Examon"));
  246. }
  247. bool CanActivateCondition(Hashtable hashtable)
  248. {
  249. removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(CanSelectPermanentCondition);
  250. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  251. CardEffectCommons.CanActivateSuspendCostEffect(card);
  252. }
  253. IEnumerator ActivateCoroutine(Hashtable hashtable)
  254. {
  255. yield return ContinuousController.instance.StartCoroutine(
  256. new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() },
  257. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  258. foreach (Permanent permanent in removedPermanents)
  259. {
  260. permanent.willBeRemoveField = false;
  261. permanent.HideHandBounceEffect();
  262. permanent.HideDeckBounceEffect();
  263. permanent.HideWillRemoveFieldEffect();
  264. }
  265. }
  266. }
  267. #endregion
  268. return cardEffects;
  269. }
  270. }
  271. }