EX4_012.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.EX4
  5. {
  6. public class EX4_012 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect($"Delete 1 Digimon", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[When Digivolving] Delete 1 of your opponent's Digimon with 6000 DP or less. For every Digimon your opponent has in play, add 2000 to the maximum this DP-based deletion effect can delete.";
  20. }
  21. int maxDP()
  22. {
  23. int maxDP = 6000;
  24. maxDP += 2000 * card.Owner.Enemy.GetBattleAreaDigimons().Count;
  25. return maxDP;
  26. }
  27. bool CanSelectPermanentCondition(Permanent permanent)
  28. {
  29. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  30. {
  31. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  47. {
  48. activateClass.SetEffectName($"Delete 1 Digimon with {maxDP()} DP or less");
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  57. {
  58. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  59. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  60. selectPermanentEffect.SetUp(
  61. selectPlayer: card.Owner,
  62. canTargetCondition: CanSelectPermanentCondition,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: null,
  65. maxCount: maxCount,
  66. canNoSelect: false,
  67. canEndNotMax: false,
  68. selectPermanentCoroutine: null,
  69. afterSelectPermanentCoroutine: null,
  70. mode: SelectPermanentEffect.Mode.Destroy,
  71. cardEffect: activateClass);
  72. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  73. }
  74. }
  75. }
  76. if (timing == EffectTiming.OnDestroyedAnyone)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect("Delete opponent's 1 Digimon with the highest DP", CanUseCondition, card);
  80. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  81. activateClass.SetHashString("Delete_EX4_012");
  82. cardEffects.Add(activateClass);
  83. string EffectDiscription()
  84. {
  85. return "[All Turns][Once Per Turn] When an opponent's Digimon is deleted, if you have a Tamer in play, delete 1 of your opponent's Digimon with the highest DP.";
  86. }
  87. bool CanSelectPermanentCondition(Permanent permanent)
  88. {
  89. return CardEffectCommons.IsMaxDP(permanent, card.Owner.Enemy, null);
  90. }
  91. bool PermanentCondition(Permanent permanent)
  92. {
  93. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  94. }
  95. bool CanUseCondition(Hashtable hashtable)
  96. {
  97. if (CardEffectCommons.IsExistOnBattleArea(card))
  98. {
  99. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  100. {
  101. return true;
  102. }
  103. }
  104. return false;
  105. }
  106. bool CanActivateCondition(Hashtable hashtable)
  107. {
  108. if (CardEffectCommons.IsExistOnBattleArea(card))
  109. {
  110. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer))
  111. {
  112. return true;
  113. }
  114. }
  115. return false;
  116. }
  117. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  118. {
  119. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  120. {
  121. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  122. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  123. selectPermanentEffect.SetUp(
  124. selectPlayer: card.Owner,
  125. canTargetCondition: CanSelectPermanentCondition,
  126. canTargetCondition_ByPreSelecetedList: null,
  127. canEndSelectCondition: null,
  128. maxCount: maxCount,
  129. canNoSelect: false,
  130. canEndNotMax: false,
  131. selectPermanentCoroutine: null,
  132. afterSelectPermanentCoroutine: null,
  133. mode: SelectPermanentEffect.Mode.Destroy,
  134. cardEffect: activateClass);
  135. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  136. }
  137. }
  138. }
  139. return cardEffects;
  140. }
  141. }
  142. }