BT13_017.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_017 : 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.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Delete Digimon", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] Choose any number of your opponent's Digimon so that their DP total is up to 6000 and delete them. For each of your other Digimon, add 2000 to the maximum this DP-based deletion effect can delete.";
  21. }
  22. int maxDP()
  23. {
  24. int maxDP = 6000;
  25. maxDP += 2000 * card.Owner.GetBattleAreaDigimons().Count((permanent) => permanent != card.PermanentOfThisCard());
  26. return maxDP;
  27. }
  28. bool CanSelectPermanentCondition(Permanent permanent)
  29. {
  30. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  31. {
  32. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  33. {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition), CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  57. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  58. selectPermanentEffect.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: CanSelectPermanentCondition,
  61. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  62. canEndSelectCondition: CanEndSelectCondition,
  63. maxCount: maxCount,
  64. canNoSelect: false,
  65. canEndNotMax: true,
  66. selectPermanentCoroutine: null,
  67. afterSelectPermanentCoroutine: null,
  68. mode: SelectPermanentEffect.Mode.Destroy,
  69. cardEffect: activateClass);
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. bool CanEndSelectCondition(List<Permanent> permanents)
  72. {
  73. if (permanents.Count <= 0)
  74. {
  75. return false;
  76. }
  77. int sumDP = 0;
  78. foreach (Permanent permanent1 in permanents)
  79. {
  80. sumDP += permanent1.DP;
  81. }
  82. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  83. {
  84. return false;
  85. }
  86. return true;
  87. }
  88. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  89. {
  90. int sumDP = 0;
  91. foreach (Permanent permanent1 in permanents)
  92. {
  93. sumDP += permanent1.DP;
  94. }
  95. sumDP += permanent.DP;
  96. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  97. {
  98. return false;
  99. }
  100. return true;
  101. }
  102. }
  103. }
  104. if (timing == EffectTiming.OnEnterFieldAnyone)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("Delete Digimon", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  109. cardEffects.Add(activateClass);
  110. string EffectDiscription()
  111. {
  112. return "[When Digivolving] Choose any number of your opponent's Digimon so that their DP total is up to 6000 and delete them. For each of your other Digimon, add 2000 to the maximum this DP-based deletion effect can delete.";
  113. }
  114. int maxDP()
  115. {
  116. int maxDP = 6000;
  117. maxDP += 2000 * card.Owner.GetBattleAreaDigimons().Count((permanent) => permanent != card.PermanentOfThisCard());
  118. return maxDP;
  119. }
  120. bool CanSelectPermanentCondition(Permanent permanent)
  121. {
  122. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  123. {
  124. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  125. {
  126. return true;
  127. }
  128. }
  129. return false;
  130. }
  131. bool CanUseCondition(Hashtable hashtable)
  132. {
  133. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  134. }
  135. bool CanActivateCondition(Hashtable hashtable)
  136. {
  137. if (CardEffectCommons.IsExistOnBattleArea(card))
  138. {
  139. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  140. {
  141. return true;
  142. }
  143. }
  144. return false;
  145. }
  146. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  147. {
  148. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition), CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  149. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  150. selectPermanentEffect.SetUp(
  151. selectPlayer: card.Owner,
  152. canTargetCondition: CanSelectPermanentCondition,
  153. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  154. canEndSelectCondition: CanEndSelectCondition,
  155. maxCount: maxCount,
  156. canNoSelect: false,
  157. canEndNotMax: true,
  158. selectPermanentCoroutine: null,
  159. afterSelectPermanentCoroutine: null,
  160. mode: SelectPermanentEffect.Mode.Destroy,
  161. cardEffect: activateClass);
  162. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  163. bool CanEndSelectCondition(List<Permanent> permanents)
  164. {
  165. if (permanents.Count <= 0)
  166. {
  167. return false;
  168. }
  169. int sumDP = 0;
  170. foreach (Permanent permanent1 in permanents)
  171. {
  172. sumDP += permanent1.DP;
  173. }
  174. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  175. {
  176. return false;
  177. }
  178. return true;
  179. }
  180. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  181. {
  182. int sumDP = 0;
  183. foreach (Permanent permanent1 in permanents)
  184. {
  185. sumDP += permanent1.DP;
  186. }
  187. sumDP += permanent.DP;
  188. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  189. {
  190. return false;
  191. }
  192. return true;
  193. }
  194. }
  195. }
  196. if (timing == EffectTiming.None)
  197. {
  198. int count()
  199. {
  200. return card.Owner.GetBattleAreaDigimons().Count((permanent) => permanent != card.PermanentOfThisCard() && (permanent.TopCard.ContainsCardName("Sistermon") || permanent.TopCard.HasRoyalKnightTraits));
  201. }
  202. bool PermanentCondition(Permanent permanent)
  203. {
  204. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  205. }
  206. bool CanUseCondition()
  207. {
  208. if (CardEffectCommons.IsExistOnBattleArea(card))
  209. {
  210. if (count() >= 1)
  211. {
  212. return true;
  213. }
  214. }
  215. return false;
  216. }
  217. string EffectName() => $"Your Digimon gain DP+{1000 * count()}";
  218. cardEffects.Add(CardEffectFactory.ChangeDPStaticEffect<Func<int>>(
  219. permanentCondition: PermanentCondition,
  220. changeValue: () => 1000 * count(),
  221. isInheritedEffect: false,
  222. card: card,
  223. condition: CanUseCondition,
  224. effectName: EffectName));
  225. }
  226. return cardEffects;
  227. }
  228. }
  229. }