EX9_056.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. //Hi-Andromon ACE
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_056 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.HasDMTraits &&
  19. targetPermanent.TopCard.IsLevel5;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 3,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null));
  27. }
  28. #endregion
  29. #region Blast Digivolve
  30. if (timing == EffectTiming.OnCounterTiming)
  31. {
  32. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  33. }
  34. #endregion
  35. #region On Play
  36. if (timing == EffectTiming.OnEnterFieldAnyone)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect("Place 1 Digimon in security bottom. Trash their security top", CanUseCondition, card);
  40. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  41. cardEffects.Add(activateClass);
  42. string EffectDiscription()
  43. {
  44. return "[On Play] By placing 1 8000 DP or lower Digimon as the bottom security card, trash your opponent's top security card.";
  45. }
  46. bool CanSelectPermanentCondition(Permanent permanent)
  47. {
  48. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
  49. permanent.DP <= 8000;
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  54. }
  55. bool CanActivateCondition(Hashtable hashtable)
  56. {
  57. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  58. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  59. }
  60. IEnumerator ActivateCoroutine(Hashtable hashtable)
  61. {
  62. Permanent selectedPermanent = null;
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectPermanentCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: 1,
  70. canNoSelect: true,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: SelectPermanentCoroutine,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectPermanentEffect.SetUpCustomMessage(
  77. "Select 1 Digimon to place at the bottom of security.",
  78. "The opponent is selecting 1 Digimon to place at the bottom of security.");
  79. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  80. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  81. {
  82. selectedPermanent = permanent;
  83. yield return null;
  84. }
  85. if (selectedPermanent != null)
  86. {
  87. CardSource selectedCard = selectedPermanent.TopCard;
  88. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  89. selectedPermanent,
  90. CardEffectCommons.CardEffectHashtable(activateClass), toTop: false).PutSecurity());
  91. if (selectedCard.Owner.SecurityCards.Contains(selectedCard) || selectedCard.IsToken)
  92. {
  93. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  94. player: card.Owner.Enemy,
  95. destroySecurityCount: 1,
  96. cardEffect: activateClass,
  97. fromTop: true).DestroySecurity());
  98. }
  99. }
  100. }
  101. }
  102. #endregion
  103. #region When Digivolving
  104. if (timing == EffectTiming.OnEnterFieldAnyone)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("Opponent places 1 card from hand in security bottom. Trash their security top", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  109. cardEffects.Add(activateClass);
  110. string EffectDiscription()
  111. {
  112. return "[When Digivolving] By placing 1 8000 DP or lower Digimon as the bottom security card, trash your opponent's top security card.";
  113. }
  114. bool CanSelectPermanentCondition(Permanent permanent)
  115. {
  116. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
  117. permanent.DP <= 8000;
  118. }
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  122. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  123. }
  124. bool CanActivateCondition(Hashtable hashtable)
  125. {
  126. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  127. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  128. }
  129. IEnumerator ActivateCoroutine(Hashtable hashtable)
  130. {
  131. Permanent selectedPermanent = null;
  132. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  133. selectPermanentEffect.SetUp(
  134. selectPlayer: card.Owner,
  135. canTargetCondition: CanSelectPermanentCondition,
  136. canTargetCondition_ByPreSelecetedList: null,
  137. canEndSelectCondition: null,
  138. maxCount: 1,
  139. canNoSelect: true,
  140. canEndNotMax: false,
  141. selectPermanentCoroutine: SelectPermanentCoroutine,
  142. afterSelectPermanentCoroutine: null,
  143. mode: SelectPermanentEffect.Mode.Custom,
  144. cardEffect: activateClass);
  145. selectPermanentEffect.SetUpCustomMessage(
  146. "Select 1 Digimon to place at the bottom of security.",
  147. "The opponent is selecting 1 Digimon to place at the bottom of security.");
  148. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  149. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  150. {
  151. selectedPermanent = permanent;
  152. yield return null;
  153. }
  154. if (selectedPermanent != null)
  155. {
  156. CardSource selectedCard = selectedPermanent.TopCard;
  157. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  158. selectedPermanent,
  159. CardEffectCommons.CardEffectHashtable(activateClass), toTop: false).PutSecurity());
  160. if (selectedCard.Owner.SecurityCards.Contains(selectedCard) || selectedCard.IsToken)
  161. {
  162. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  163. player: card.Owner.Enemy,
  164. destroySecurityCount: 1,
  165. cardEffect: activateClass,
  166. fromTop: true).DestroySecurity());
  167. }
  168. }
  169. }
  170. }
  171. #endregion
  172. #region All Turns
  173. if (timing == EffectTiming.WhenRemoveField)
  174. {
  175. ActivateClass activateClass = new ActivateClass();
  176. activateClass.SetUpICardEffect(
  177. "By trashing the top card of your security stack, prevent Digimon from leaving the battle area",
  178. CanUseCondition, card);
  179. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true,
  180. EffectDescription());
  181. activateClass.SetHashString("TrashSecurityToPreventLeaving_EX9_056");
  182. cardEffects.Add(activateClass);
  183. string EffectDescription()
  184. {
  185. return
  186. "[All Turns] [Once Per Turn] When any of your [Ver.3] trait Digimon would leave the battle area, by trashing your top security card, they don't leave.";
  187. }
  188. bool PermanentCondition(Permanent permanent)
  189. {
  190. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  191. {
  192. if (permanent.TopCard.EqualsTraits("Ver.3"))
  193. {
  194. return true;
  195. }
  196. }
  197. return false;
  198. }
  199. bool CanUseCondition(Hashtable hashtable)
  200. {
  201. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  202. {
  203. if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition))
  204. {
  205. return true;
  206. }
  207. }
  208. return false;
  209. }
  210. bool CanActivateCondition(Hashtable hashtable)
  211. {
  212. if (CardEffectCommons.IsExistOnBattleArea(card))
  213. {
  214. if (card.Owner.SecurityCards.Count >= 1)
  215. {
  216. return true;
  217. }
  218. }
  219. return false;
  220. }
  221. IEnumerator ActivateCoroutine(Hashtable hashtable)
  222. {
  223. List<Permanent> removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable);
  224. removedPermanents = removedPermanents.Filter(PermanentCondition);
  225. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  226. {
  227. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  228. player: card.Owner,
  229. destroySecurityCount: 1,
  230. cardEffect: activateClass,
  231. fromTop: true).DestroySecurity());
  232. foreach (Permanent permanent in removedPermanents)
  233. {
  234. permanent.willBeRemoveField = false;
  235. permanent.HideDeleteEffect();
  236. permanent.HideHandBounceEffect();
  237. permanent.HideDeckBounceEffect();
  238. permanent.HideWillRemoveFieldEffect();
  239. }
  240. }
  241. }
  242. }
  243. #endregion
  244. return cardEffects;
  245. }
  246. }
  247. }