BT19_011.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT19
  6. {
  7. public class BT19_011 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Blast Digivolve
  13. if (timing == EffectTiming.OnCounterTiming)
  14. {
  15. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  16. }
  17. #endregion
  18. #region On Play
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. int enemyCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count, card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()));
  22. int maxDP = 3000 + 2000 * enemyCount;
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Delete up to 3000 DP of your opponents Digimon, this DP-based deletion increases by 2000 DP for each of your opponent's Digimon and gain memory", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[On Play] Delete any of your opponent's Digimon with DP adding up to 3000. For each of your opponent's Digimon, add 2000 to this DP-Based deletion effect's maximum. Then, for each Digimon deleted by this effect, gain 1 memory.";
  30. }
  31. bool CanSelectOpponentsPermanent(Permanent permanent)
  32. {
  33. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  34. {
  35. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(maxDP, activateClass))
  36. {
  37. if (permanent.TopCard.HasDP)
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. return false;
  44. }
  45. bool CanEndSelectCondition(List<Permanent> permanents)
  46. {
  47. if (permanents.Count <= 0)
  48. return false;
  49. int sumDP = 0;
  50. foreach (Permanent permanent1 in permanents)
  51. {
  52. sumDP += permanent1.DP;
  53. }
  54. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDP, activateClass))
  55. return false;
  56. return true;
  57. }
  58. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  59. {
  60. int sumDP = 0;
  61. foreach (Permanent permanent1 in permanents)
  62. {
  63. sumDP += permanent1.DP;
  64. }
  65. sumDP += permanent.DP;
  66. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDP, activateClass))
  67. return false;
  68. return true;
  69. }
  70. bool CanUseCondition(Hashtable hashtable)
  71. {
  72. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  73. }
  74. bool CanActivateCondition(Hashtable hashtable)
  75. {
  76. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  77. }
  78. IEnumerator ActivateCoroutine(Hashtable hashtable)
  79. {
  80. int destroyCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectOpponentsPermanent);
  81. List<Permanent> destroyTargetPermanents = new List<Permanent>();
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectOpponentsPermanent,
  86. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  87. canEndSelectCondition: CanEndSelectCondition,
  88. maxCount: destroyCount,
  89. canNoSelect: false,
  90. canEndNotMax: true,
  91. selectPermanentCoroutine: SelectPermanentCoroutine,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Destroy,
  94. cardEffect: activateClass);
  95. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  96. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  97. {
  98. destroyTargetPermanents.Add(permanent);
  99. yield return null;
  100. }
  101. if (card.Owner.CanAddMemory(activateClass))
  102. {
  103. var memoryGain = destroyTargetPermanents.Count - destroyTargetPermanents.Filter(x => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(x, card)).Count;
  104. if (memoryGain > 0) yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(memoryGain, activateClass));
  105. }
  106. }
  107. }
  108. #endregion
  109. #region When Digivolving
  110. if (timing == EffectTiming.OnEnterFieldAnyone)
  111. {
  112. int enemyCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count, card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()));
  113. int maxDP = 3000 + 2000 * enemyCount;
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect("Delete up to 3000 DP of your opponents Digimon, this DP-based deletion increases by 2000 DP for each of your opponent's Digimon and gain memory", CanUseCondition, card);
  116. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  117. cardEffects.Add(activateClass);
  118. string EffectDiscription()
  119. {
  120. return "[When Digivolving] Delete any of your opponent's Digimon with DP adding up to 3000. For each of your opponent's Digimon, add 2000 to this DP-Based deletion effect's maximum. Then, for each Digimon deleted by this effect, gain 1 memory.";
  121. }
  122. bool CanSelectOpponentsPermanent(Permanent permanent)
  123. {
  124. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  125. {
  126. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(maxDP, activateClass))
  127. {
  128. if (permanent.TopCard.HasDP)
  129. {
  130. return true;
  131. }
  132. }
  133. }
  134. return false;
  135. }
  136. bool CanEndSelectCondition(List<Permanent> permanents)
  137. {
  138. if (permanents.Count <= 0)
  139. return false;
  140. int sumDP = 0;
  141. foreach (Permanent permanent1 in permanents)
  142. {
  143. sumDP += permanent1.DP;
  144. }
  145. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDP, activateClass))
  146. return false;
  147. return true;
  148. }
  149. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  150. {
  151. int sumDP = 0;
  152. foreach (Permanent permanent1 in permanents)
  153. {
  154. sumDP += permanent1.DP;
  155. }
  156. sumDP += permanent.DP;
  157. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDP, activateClass))
  158. return false;
  159. return true;
  160. }
  161. bool CanUseCondition(Hashtable hashtable)
  162. {
  163. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  164. {
  165. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  166. {
  167. return true;
  168. }
  169. }
  170. return false;
  171. }
  172. bool CanActivateCondition(Hashtable hashtable)
  173. {
  174. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  175. }
  176. IEnumerator ActivateCoroutine(Hashtable hashtable)
  177. {
  178. int destroyCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectOpponentsPermanent);
  179. List<Permanent> destroyTargetPermanents = new List<Permanent>();
  180. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  181. selectPermanentEffect.SetUp(
  182. selectPlayer: card.Owner,
  183. canTargetCondition: CanSelectOpponentsPermanent,
  184. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  185. canEndSelectCondition: CanEndSelectCondition,
  186. maxCount: destroyCount,
  187. canNoSelect: false,
  188. canEndNotMax: true,
  189. selectPermanentCoroutine: SelectPermanentCoroutine,
  190. afterSelectPermanentCoroutine: null,
  191. mode: SelectPermanentEffect.Mode.Destroy,
  192. cardEffect: activateClass);
  193. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  194. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  195. {
  196. destroyTargetPermanents.Add(permanent);
  197. yield return null;
  198. }
  199. if (card.Owner.CanAddMemory(activateClass))
  200. {
  201. var memoryGain = destroyTargetPermanents.Count - destroyTargetPermanents.Filter(x => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(x, card)).Count;
  202. if (memoryGain > 0) yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(memoryGain, activateClass));
  203. }
  204. }
  205. }
  206. #endregion
  207. #region Inherit
  208. if (timing == EffectTiming.None)
  209. {
  210. ChangeDPDeleteEffectMaxDPClass changeDPDeleteEffectMaxDPClass = new ChangeDPDeleteEffectMaxDPClass();
  211. changeDPDeleteEffectMaxDPClass.SetUpICardEffect("Maximum DP of DP-based deletion effects gets +3000 DP", CanUseCondition, card);
  212. changeDPDeleteEffectMaxDPClass.SetUpChangeDPDeleteEffectMaxDPClass(changeMaxDP: ChangeMaxDP);
  213. changeDPDeleteEffectMaxDPClass.SetIsInheritedEffect(true);
  214. cardEffects.Add(changeDPDeleteEffectMaxDPClass);
  215. bool CanUseCondition(Hashtable hashtable)
  216. {
  217. if (isExistOnField(card))
  218. {
  219. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  220. {
  221. return true;
  222. }
  223. }
  224. return false;
  225. }
  226. int ChangeMaxDP(int maxDP, ICardEffect cardEffect)
  227. {
  228. if (cardEffect != null)
  229. {
  230. if (cardEffect.EffectSourceCard != null)
  231. {
  232. if (cardEffect.EffectSourceCard.Owner == card.Owner)
  233. {
  234. if (cardEffect.EffectSourceCard.PermanentOfThisCard() == card.PermanentOfThisCard()) maxDP += 3000;
  235. }
  236. }
  237. }
  238. return maxDP;
  239. }
  240. }
  241. #endregion
  242. return cardEffects;
  243. }
  244. }
  245. }