Dukemon_EX2_011.cs 7.4 KB

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