EX2_011.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX2
  6. {
  7. public class EX2_011 : 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 Condition()
  15. {
  16. if (CardEffectCommons.IsExistOnBattleArea(card))
  17. {
  18. if (CardEffectCommons.IsOwnerTurn(card))
  19. {
  20. return true;
  21. }
  22. }
  23. return false;
  24. }
  25. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 2000, isInheritedEffect: false, card: card, condition: Condition));
  26. }
  27. if (timing == EffectTiming.None)
  28. {
  29. ChangeDPDeleteEffectMaxDPClass changeDPDeleteEffectMaxDPClass = new ChangeDPDeleteEffectMaxDPClass();
  30. changeDPDeleteEffectMaxDPClass.SetUpICardEffect("Maximum DP of DP-based deletion effects gets +2000 DP", CanUseCondition, card);
  31. changeDPDeleteEffectMaxDPClass.SetUpChangeDPDeleteEffectMaxDPClass(changeMaxDP: ChangeMaxDP);
  32. cardEffects.Add(changeDPDeleteEffectMaxDPClass);
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. if (isExistOnField(card))
  36. {
  37. if (CardEffectCommons.IsOwnerTurn(card))
  38. {
  39. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  40. {
  41. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardColors.Contains(CardColor.Red) && permanent.IsTamer))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. int ChangeMaxDP(int maxDP, ICardEffect cardEffect)
  51. {
  52. if (cardEffect != null)
  53. {
  54. if (cardEffect.EffectSourceCard != null)
  55. {
  56. if (cardEffect.EffectSourceCard.Owner == card.Owner)
  57. {
  58. maxDP += 2000;
  59. }
  60. }
  61. }
  62. return maxDP;
  63. }
  64. }
  65. if (timing == EffectTiming.OnAllyAttack)
  66. {
  67. ActivateClass activateClass = new ActivateClass();
  68. activateClass.SetUpICardEffect("Delete Digimon whose total DP adds up to 6000 or less", CanUseCondition, card);
  69. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  70. cardEffects.Add(activateClass);
  71. string EffectDiscription()
  72. {
  73. return "[When Attacking] Choose any number of your opponent's Digimon whose total DP adds up to 6000 or less and delete them.";
  74. }
  75. bool CanSelectPermanentCondition(Permanent permanent)
  76. {
  77. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  78. {
  79. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(6000, activateClass))
  80. {
  81. return true;
  82. }
  83. }
  84. return false;
  85. }
  86. bool CanUseCondition(Hashtable hashtable)
  87. {
  88. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  89. }
  90. bool CanActivateCondition(Hashtable hashtable)
  91. {
  92. if (CardEffectCommons.IsExistOnBattleArea(card))
  93. {
  94. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  95. {
  96. return true;
  97. }
  98. }
  99. return false;
  100. }
  101. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  102. {
  103. if (isExistOnField(card))
  104. {
  105. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  106. {
  107. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  108. {
  109. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition), CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  110. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  111. selectPermanentEffect.SetUp(
  112. selectPlayer: card.Owner,
  113. canTargetCondition: CanSelectPermanentCondition,
  114. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  115. canEndSelectCondition: CanEndSelectCondition,
  116. maxCount: maxCount,
  117. canNoSelect: false,
  118. canEndNotMax: true,
  119. selectPermanentCoroutine: null,
  120. afterSelectPermanentCoroutine: null,
  121. mode: SelectPermanentEffect.Mode.Destroy,
  122. cardEffect: activateClass);
  123. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  124. bool CanEndSelectCondition(List<Permanent> permanents)
  125. {
  126. if (permanents.Count <= 0)
  127. {
  128. return false;
  129. }
  130. int sumDP = 0;
  131. foreach (Permanent permanent1 in permanents)
  132. {
  133. sumDP += permanent1.DP;
  134. }
  135. if (sumDP > card.Owner.MaxDP_DeleteEffect(6000, activateClass))
  136. {
  137. return false;
  138. }
  139. return true;
  140. }
  141. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  142. {
  143. int sumDP = 0;
  144. foreach (Permanent permanent1 in permanents)
  145. {
  146. sumDP += permanent1.DP;
  147. }
  148. sumDP += permanent.DP;
  149. if (sumDP > card.Owner.MaxDP_DeleteEffect(6000, activateClass))
  150. {
  151. return false;
  152. }
  153. return true;
  154. }
  155. }
  156. }
  157. }
  158. }
  159. }
  160. return cardEffects;
  161. }
  162. }
  163. }