BT12_014.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_014 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.HasSaveText && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. if (timing == EffectTiming.OnEnterFieldAnyone)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("Delete Digimon", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  25. cardEffects.Add(activateClass);
  26. string EffectDiscription()
  27. {
  28. return "[When Digivolving] Choose any number of your opponent's Digimon whose total DP adds up to 4000 or less and delete them. For every 2 cards in this Digimon's digivolution cards, it gets +3000 to the maximum DP-based deletion effects.";
  29. }
  30. int maxDP()
  31. {
  32. int maxDP = 4000;
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. maxDP += 3000 * (card.PermanentOfThisCard().DigivolutionCards.Count / 2);
  36. }
  37. return maxDP;
  38. }
  39. bool CanSelectPermanentCondition(Permanent permanent)
  40. {
  41. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  42. {
  43. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.IsExistOnBattleArea(card))
  57. {
  58. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  59. {
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  66. {
  67. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  68. {
  69. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition), CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  70. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectPermanentCondition,
  74. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  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)
  87. {
  88. return false;
  89. }
  90. int sumDP = 0;
  91. foreach (Permanent permanent1 in permanents)
  92. {
  93. sumDP += permanent1.DP;
  94. }
  95. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  96. {
  97. return false;
  98. }
  99. return true;
  100. }
  101. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  102. {
  103. int sumDP = 0;
  104. foreach (Permanent permanent1 in permanents)
  105. {
  106. sumDP += permanent1.DP;
  107. }
  108. sumDP += permanent.DP;
  109. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  110. {
  111. return false;
  112. }
  113. return true;
  114. }
  115. }
  116. }
  117. }
  118. if (timing == EffectTiming.None)
  119. {
  120. bool Condition()
  121. {
  122. if (CardEffectCommons.IsExistOnBattleArea(card))
  123. {
  124. if (CardEffectCommons.IsOwnerTurn(card))
  125. {
  126. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 4)
  127. {
  128. return true;
  129. }
  130. }
  131. }
  132. return false;
  133. }
  134. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: Condition));
  135. }
  136. if (timing == EffectTiming.OnAllyAttack)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect("Delete 1 Digimon with 4000 DP or less", CanUseCondition, card);
  140. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  141. activateClass.SetIsInheritedEffect(true);
  142. activateClass.SetHashString("Delete_BT12_014");
  143. cardEffects.Add(activateClass);
  144. string EffectDiscription()
  145. {
  146. return "[When Attacking][Once Per Turn] If this Digimon has <Save> in its text, delete 1 of your opponent's Digimon with 4000 DP or less.";
  147. }
  148. bool CanSelectPermanentCondition(Permanent permanent)
  149. {
  150. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  151. {
  152. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(4000, activateClass))
  153. {
  154. return true;
  155. }
  156. }
  157. return false;
  158. }
  159. bool CanUseCondition(Hashtable hashtable)
  160. {
  161. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  162. }
  163. bool CanActivateCondition(Hashtable hashtable)
  164. {
  165. if (CardEffectCommons.IsExistOnBattleArea(card))
  166. {
  167. if (card.PermanentOfThisCard().TopCard.HasSaveText)
  168. {
  169. return true;
  170. }
  171. }
  172. return false;
  173. }
  174. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  175. {
  176. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  177. {
  178. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  179. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  180. selectPermanentEffect.SetUp(
  181. selectPlayer: card.Owner,
  182. canTargetCondition: CanSelectPermanentCondition,
  183. canTargetCondition_ByPreSelecetedList: null,
  184. canEndSelectCondition: null,
  185. maxCount: maxCount,
  186. canNoSelect: false,
  187. canEndNotMax: false,
  188. selectPermanentCoroutine: null,
  189. afterSelectPermanentCoroutine: null,
  190. mode: SelectPermanentEffect.Mode.Destroy,
  191. cardEffect: activateClass);
  192. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  193. }
  194. }
  195. }
  196. return cardEffects;
  197. }
  198. }
  199. }