LM_021.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.LM
  6. {
  7. public class LM_021 : 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 DigivolutionCondition()
  16. {
  17. return card.Owner.SecurityCards.Count <= 2;
  18. }
  19. bool PermanentCondition(Permanent targetPermanent)
  20. {
  21. return targetPermanent.TopCard.EqualsCardName("Agumon");
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition,
  24. digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: DigivolutionCondition));
  25. }
  26. #endregion
  27. #region Ace - Blast Digivolve
  28. if (timing == EffectTiming.OnCounterTiming)
  29. {
  30. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  31. }
  32. #endregion
  33. #region On Play/ When Digivolving Shared
  34. int MaxDP()
  35. {
  36. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) ? card.PermanentOfThisCard().DP : 0;
  37. }
  38. #endregion
  39. #region On Play
  40. if (timing == EffectTiming.OnEnterFieldAnyone)
  41. {
  42. ActivateClass activateClass = new ActivateClass();
  43. activateClass.SetUpICardEffect($"Delete opponent's Digimon whose total DP adds up to {MaxDP()} or less", CanUseCondition,
  44. card);
  45. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  46. cardEffects.Add(activateClass);
  47. string EffectDescription()
  48. {
  49. return
  50. "[On Play] Delete any number of your opponent’s Digimon whose total DP adds up to equal or less than this Digimon’s DP.";
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  55. }
  56. bool CanSelectPermanentCondition(Permanent permanent)
  57. {
  58. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  59. permanent.DP <= card.Owner.MaxDP_DeleteEffect(MaxDP(), activateClass);
  60. }
  61. bool CanActivateCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  64. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable hashtable)
  67. {
  68. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition),
  69. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  70. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectPermanentCondition,
  74. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  75. canEndSelectCondition: CanEndSelectCondition,
  76. maxCount: maxCount,
  77. canNoSelect: false,
  78. canEndNotMax: true,
  79. selectPermanentCoroutine: null,
  80. afterSelectPermanentCoroutine: null,
  81. mode: SelectPermanentEffect.Mode.Destroy,
  82. cardEffect: activateClass);
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  84. bool CanEndSelectCondition(List<Permanent> permanents)
  85. {
  86. if (permanents.Count <= 0) return false;
  87. int sumDP = permanents.Sum(permanent => permanent.DP);
  88. return sumDP <= card.Owner.MaxDP_DeleteEffect(MaxDP(), activateClass);
  89. }
  90. bool CanTargetConditionByPreSelectedList(List<Permanent> permanents, Permanent permanent)
  91. {
  92. int sumDP = permanents.Sum(permanent1 => permanent1.DP);
  93. sumDP += permanent.DP;
  94. return sumDP <= card.Owner.MaxDP_DeleteEffect(MaxDP(), activateClass);
  95. }
  96. }
  97. }
  98. #endregion
  99. #region When Digivolving
  100. if (timing == EffectTiming.OnEnterFieldAnyone)
  101. {
  102. ActivateClass activateClass = new ActivateClass();
  103. activateClass.SetUpICardEffect($"Delete opponent's Digimon whose total DP adds up to {MaxDP()} or less", CanUseCondition,
  104. card);
  105. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  106. cardEffects.Add(activateClass);
  107. string EffectDescription()
  108. {
  109. return
  110. "[When Digivolving] Delete any number of your opponent’s Digimon whose total DP adds up to equal or less than this Digimon’s DP.";
  111. }
  112. bool CanUseCondition(Hashtable hashtable)
  113. {
  114. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  115. }
  116. bool CanSelectPermanentCondition(Permanent permanent)
  117. {
  118. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  119. permanent.DP <= card.Owner.MaxDP_DeleteEffect(MaxDP(), activateClass);
  120. }
  121. bool CanActivateCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  124. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  125. }
  126. IEnumerator ActivateCoroutine(Hashtable hashtable)
  127. {
  128. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition),
  129. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  130. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  131. selectPermanentEffect.SetUp(
  132. selectPlayer: card.Owner,
  133. canTargetCondition: CanSelectPermanentCondition,
  134. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  135. canEndSelectCondition: CanEndSelectCondition,
  136. maxCount: maxCount,
  137. canNoSelect: false,
  138. canEndNotMax: true,
  139. selectPermanentCoroutine: null,
  140. afterSelectPermanentCoroutine: null,
  141. mode: SelectPermanentEffect.Mode.Destroy,
  142. cardEffect: activateClass);
  143. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  144. bool CanEndSelectCondition(List<Permanent> permanents)
  145. {
  146. if (permanents.Count <= 0) return false;
  147. int sumDP = permanents.Sum(permanent => permanent.DP);
  148. return sumDP <= card.Owner.MaxDP_DeleteEffect(MaxDP(), activateClass);
  149. }
  150. bool CanTargetConditionByPreSelectedList(List<Permanent> permanents, Permanent permanent)
  151. {
  152. int sumDP = permanents.Sum(permanent1 => permanent1.DP);
  153. sumDP += permanent.DP;
  154. return sumDP <= card.Owner.MaxDP_DeleteEffect(MaxDP(), activateClass);
  155. }
  156. }
  157. }
  158. #endregion
  159. #region When Attacking
  160. if (timing == EffectTiming.OnAllyAttack)
  161. {
  162. ActivateClass activateClass = new ActivateClass();
  163. activateClass.SetUpICardEffect($"Trash the top card of your opponent's security stack", CanUseCondition, card);
  164. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  165. activateClass.SetHashString("TrashTopSec_LM_021");
  166. cardEffects.Add(activateClass);
  167. string EffectDescription()
  168. {
  169. return "[When Attacking] (Once Per Turn) If you have a Tamer, trash the top card of your opponent’s security stack.";
  170. }
  171. bool CanUseCondition(Hashtable hashtable)
  172. {
  173. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  174. }
  175. bool CanActivateCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  178. CardEffectCommons.HasMatchConditionOwnersPermanent(card, permanent => permanent.IsTamer) &&
  179. card.Owner.Enemy.SecurityCards.Count >= 1;
  180. }
  181. IEnumerator ActivateCoroutine(Hashtable hashtable)
  182. {
  183. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  184. player: card.Owner.Enemy,
  185. destroySecurityCount: 1,
  186. cardEffect: activateClass,
  187. fromTop: true).DestroySecurity());
  188. }
  189. }
  190. #endregion
  191. return cardEffects;
  192. }
  193. }
  194. }