BT17_018.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_018 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel6 && targetPermanent.TopCard.ContainsCardName("Gallantmon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 4,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region Ace - Blast Digivolve
  29. if (timing == EffectTiming.OnCounterTiming)
  30. {
  31. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  32. }
  33. #endregion
  34. #region On Play/ When Digivolving Shared
  35. int maxDPDeletionValue = 15000;
  36. #endregion
  37. #region On Play
  38. if (timing == EffectTiming.OnEnterFieldAnyone)
  39. {
  40. ActivateClass activateClass = new ActivateClass();
  41. activateClass.SetUpICardEffect("Delete opponent's Digimon whose total DP adds up to 15000 or less", CanUseCondition, card);
  42. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  43. cardEffects.Add(activateClass);
  44. string EffectDescription()
  45. {
  46. return
  47. "[On Play] Choose any number of your opponent's Digimon whose total DP adds up to 15000 or less and delete them.";
  48. }
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  52. }
  53. bool CanSelectPermanentCondition(Permanent permanent)
  54. {
  55. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  56. {
  57. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(maxDPDeletionValue, activateClass))
  58. {
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.IsExistOnBattleArea(card))
  67. {
  68. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  69. {
  70. return true;
  71. }
  72. }
  73. return false;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable hashtable)
  76. {
  77. if (CardEffectCommons.IsExistOnBattleArea(card))
  78. {
  79. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  80. {
  81. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition),
  82. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  83. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  84. selectPermanentEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: CanSelectPermanentCondition,
  87. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  88. canEndSelectCondition: CanEndSelectCondition,
  89. maxCount: maxCount,
  90. canNoSelect: false,
  91. canEndNotMax: true,
  92. selectPermanentCoroutine: null,
  93. afterSelectPermanentCoroutine: null,
  94. mode: SelectPermanentEffect.Mode.Destroy,
  95. cardEffect: activateClass);
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. bool CanEndSelectCondition(List<Permanent> permanents)
  98. {
  99. if (permanents.Count <= 0)
  100. {
  101. return false;
  102. }
  103. int sumDP = 0;
  104. foreach (Permanent permanent in permanents)
  105. {
  106. sumDP += permanent.DP;
  107. }
  108. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDPDeletionValue, activateClass))
  109. {
  110. return false;
  111. }
  112. return true;
  113. }
  114. bool CanTargetConditionByPreSelectedList(List<Permanent> permanents, Permanent permanent)
  115. {
  116. int sumDP = 0;
  117. foreach (Permanent permanent1 in permanents)
  118. {
  119. sumDP += permanent1.DP;
  120. }
  121. sumDP += permanent.DP;
  122. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDPDeletionValue, activateClass))
  123. {
  124. return false;
  125. }
  126. return true;
  127. }
  128. }
  129. }
  130. }
  131. }
  132. #endregion
  133. #region When Digivolving
  134. if (timing == EffectTiming.OnEnterFieldAnyone)
  135. {
  136. ActivateClass activateClass = new ActivateClass();
  137. activateClass.SetUpICardEffect("Delete opponent's Digimon whose total DP adds up to 15000 or less", CanUseCondition, card);
  138. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  139. cardEffects.Add(activateClass);
  140. string EffectDescription()
  141. {
  142. return
  143. "[When Digivolving] Choose any number of your opponent's Digimon whose total DP adds up to 15000 or less and delete them.";
  144. }
  145. bool CanUseCondition(Hashtable hashtable)
  146. {
  147. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  148. }
  149. bool CanSelectPermanentCondition(Permanent permanent)
  150. {
  151. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  152. {
  153. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(maxDPDeletionValue, activateClass))
  154. {
  155. return true;
  156. }
  157. }
  158. return false;
  159. }
  160. bool CanActivateCondition(Hashtable hashtable)
  161. {
  162. if (CardEffectCommons.IsExistOnBattleArea(card))
  163. {
  164. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  165. {
  166. return true;
  167. }
  168. }
  169. return false;
  170. }
  171. IEnumerator ActivateCoroutine(Hashtable hashtable)
  172. {
  173. if (CardEffectCommons.IsExistOnBattleArea(card))
  174. {
  175. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  176. {
  177. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition),
  178. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  179. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  180. selectPermanentEffect.SetUp(
  181. selectPlayer: card.Owner,
  182. canTargetCondition: CanSelectPermanentCondition,
  183. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  184. canEndSelectCondition: CanEndSelectCondition,
  185. maxCount: maxCount,
  186. canNoSelect: false,
  187. canEndNotMax: true,
  188. selectPermanentCoroutine: null,
  189. afterSelectPermanentCoroutine: null,
  190. mode: SelectPermanentEffect.Mode.Destroy,
  191. cardEffect: activateClass);
  192. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  193. bool CanEndSelectCondition(List<Permanent> permanents)
  194. {
  195. if (permanents.Count <= 0)
  196. {
  197. return false;
  198. }
  199. int sumDP = 0;
  200. foreach (Permanent permanent in permanents)
  201. {
  202. sumDP += permanent.DP;
  203. }
  204. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDPDeletionValue, activateClass))
  205. {
  206. return false;
  207. }
  208. return true;
  209. }
  210. bool CanTargetConditionByPreSelectedList(List<Permanent> permanents, Permanent permanent)
  211. {
  212. int sumDP = 0;
  213. foreach (Permanent permanent1 in permanents)
  214. {
  215. sumDP += permanent1.DP;
  216. }
  217. sumDP += permanent.DP;
  218. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDPDeletionValue, activateClass))
  219. {
  220. return false;
  221. }
  222. return true;
  223. }
  224. }
  225. }
  226. }
  227. }
  228. #endregion
  229. #region When Attacking
  230. if (timing == EffectTiming.OnAllyAttack)
  231. {
  232. int Count()
  233. {
  234. return (card.Owner.TrashCards.Count + card.Owner.Enemy.TrashCards.Count) / 10;
  235. }
  236. ActivateClass activateClass = new ActivateClass();
  237. activateClass.SetUpICardEffect($"Trash {Count()} cards from the top of your opponent's security stack", CanUseCondition,
  238. card);
  239. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  240. activateClass.SetHashString("WhenAttack_BT17_018");
  241. cardEffects.Add(activateClass);
  242. string EffectDescription()
  243. {
  244. return
  245. "[When Attacking] [Once Per Turn] For every 10 cards in both player's trash, trash 1 card from the top of your opponent's security stack.";
  246. }
  247. bool CanUseCondition(Hashtable hashtable)
  248. {
  249. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  250. }
  251. bool CanActivateCondition(Hashtable hashtable)
  252. {
  253. if (CardEffectCommons.IsExistOnBattleArea(card))
  254. {
  255. return true;
  256. }
  257. return false;
  258. }
  259. IEnumerator ActivateCoroutine(Hashtable hashtable)
  260. {
  261. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  262. player: card.Owner.Enemy,
  263. destroySecurityCount: Count(),
  264. cardEffect: activateClass,
  265. fromTop: true).DestroySecurity());
  266. }
  267. }
  268. #endregion
  269. return cardEffects;
  270. }
  271. }
  272. }