ST7_12.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 ST7_12 : 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.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] Choose any number of your opponent's Digimon whose total DP adds up to 8000 or less and delete them.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  39. {
  40. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  41. {
  42. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition), CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  43. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  44. selectPermanentEffect.SetUp(
  45. selectPlayer: card.Owner,
  46. canTargetCondition: CanSelectPermanentCondition,
  47. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  48. canEndSelectCondition: CanEndSelectCondition,
  49. maxCount: maxCount,
  50. canNoSelect: false,
  51. canEndNotMax: true,
  52. selectPermanentCoroutine: null,
  53. afterSelectPermanentCoroutine: null,
  54. mode: SelectPermanentEffect.Mode.Destroy,
  55. cardEffect: activateClass);
  56. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  57. bool CanEndSelectCondition(List<Permanent> permanents)
  58. {
  59. if (permanents.Count <= 0)
  60. {
  61. return false;
  62. }
  63. int sumDP = 0;
  64. foreach (Permanent permanent1 in permanents)
  65. {
  66. sumDP += permanent1.DP;
  67. }
  68. if (sumDP > card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  69. {
  70. return false;
  71. }
  72. return true;
  73. }
  74. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  75. {
  76. int sumDP = 0;
  77. foreach (Permanent permanent1 in permanents)
  78. {
  79. sumDP += permanent1.DP;
  80. }
  81. sumDP += permanent.DP;
  82. if (sumDP > card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  83. {
  84. return false;
  85. }
  86. return true;
  87. }
  88. }
  89. }
  90. }
  91. if (timing == EffectTiming.SecuritySkill)
  92. {
  93. ActivateClass activateClass = new ActivateClass();
  94. activateClass.SetUpICardEffect($"Delete Digimon whose total DP adds up to 8000 or less", CanUseCondition, card);
  95. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  96. activateClass.SetIsSecurityEffect(true);
  97. cardEffects.Add(activateClass);
  98. string EffectDiscription()
  99. {
  100. return "[Security] Choose any number of your opponent's Digimon whose total DP adds up to 8000 or less and delete them.";
  101. }
  102. bool CanSelectPermanentCondition(Permanent permanent)
  103. {
  104. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  105. {
  106. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  107. {
  108. return true;
  109. }
  110. }
  111. return false;
  112. }
  113. bool CanUseCondition(Hashtable hashtable)
  114. {
  115. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  116. }
  117. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  118. {
  119. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  120. {
  121. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition), CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  122. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  123. selectPermanentEffect.SetUp(
  124. selectPlayer: card.Owner,
  125. canTargetCondition: CanSelectPermanentCondition,
  126. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  127. canEndSelectCondition: CanEndSelectCondition,
  128. maxCount: maxCount,
  129. canNoSelect: false,
  130. canEndNotMax: true,
  131. selectPermanentCoroutine: null,
  132. afterSelectPermanentCoroutine: null,
  133. mode: SelectPermanentEffect.Mode.Destroy,
  134. cardEffect: activateClass);
  135. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  136. bool CanEndSelectCondition(List<Permanent> permanents)
  137. {
  138. if (permanents.Count <= 0)
  139. {
  140. return false;
  141. }
  142. int sumDP = 0;
  143. foreach (Permanent permanent1 in permanents)
  144. {
  145. sumDP += permanent1.DP;
  146. }
  147. if (sumDP > card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  148. {
  149. return false;
  150. }
  151. return true;
  152. }
  153. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  154. {
  155. int sumDP = 0;
  156. foreach (Permanent permanent1 in permanents)
  157. {
  158. sumDP += permanent1.DP;
  159. }
  160. sumDP += permanent.DP;
  161. if (sumDP > card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  162. {
  163. return false;
  164. }
  165. return true;
  166. }
  167. }
  168. }
  169. }
  170. return cardEffects;
  171. }
  172. }