BT15_017.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT15
  6. {
  7. public class BT15_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 1 Digimon with the lowest DP and trash the top card of opponent's security", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] If your opponent has 3 or fewer security cards, delete 1 of their Digimon with the lowest DP. If they have 4 or more, trash the top card of their security stack.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  29. }
  30. bool CanActivateCondition(Hashtable hashtable)
  31. {
  32. if (CardEffectCommons.IsExistOnBattleArea(card))
  33. {
  34. if (card.Owner.Enemy.SecurityCards.Count <= 3)
  35. {
  36. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  37. {
  38. return true;
  39. }
  40. }
  41. if (card.Owner.Enemy.SecurityCards.Count >= 4)
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  49. {
  50. if (card.Owner.Enemy.SecurityCards.Count <= 3)
  51. {
  52. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  53. {
  54. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  55. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  56. selectPermanentEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: CanSelectPermanentCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: maxCount,
  62. canNoSelect: false,
  63. canEndNotMax: false,
  64. selectPermanentCoroutine: null,
  65. afterSelectPermanentCoroutine: null,
  66. mode: SelectPermanentEffect.Mode.Destroy,
  67. cardEffect: activateClass);
  68. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  69. }
  70. }
  71. if (card.Owner.Enemy.SecurityCards.Count >= 4)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  74. player: card.Owner.Enemy,
  75. destroySecurityCount: 1,
  76. cardEffect: activateClass,
  77. fromTop: true).DestroySecurity());
  78. }
  79. }
  80. }
  81. if (timing == EffectTiming.OnDestroyedAnyone)
  82. {
  83. ActivateClass activateClass = new ActivateClass();
  84. activateClass.SetUpICardEffect("Delete 1 Digimon with the lowest DP and trash the top card of opponent's security", CanUseCondition, card);
  85. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  86. cardEffects.Add(activateClass);
  87. string EffectDiscription()
  88. {
  89. return "[On Deletion] If your opponent has 3 or fewer security cards, delete 1 of their Digimon with the lowest DP. If they have 4 or more, trash the top card of their security stack.";
  90. }
  91. bool CanSelectPermanentCondition(Permanent permanent)
  92. {
  93. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  94. }
  95. bool CanUseCondition(Hashtable hashtable)
  96. {
  97. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  98. }
  99. bool CanActivateCondition(Hashtable hashtable)
  100. {
  101. if (CardEffectCommons.CanActivateOnDeletion(card))
  102. {
  103. if (card.Owner.Enemy.SecurityCards.Count <= 3)
  104. {
  105. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  106. {
  107. return true;
  108. }
  109. }
  110. if (card.Owner.Enemy.SecurityCards.Count >= 4)
  111. {
  112. return true;
  113. }
  114. }
  115. return false;
  116. }
  117. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  118. {
  119. if (card.Owner.Enemy.SecurityCards.Count <= 3)
  120. {
  121. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  122. {
  123. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  124. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  125. selectPermanentEffect.SetUp(
  126. selectPlayer: card.Owner,
  127. canTargetCondition: CanSelectPermanentCondition,
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. maxCount: maxCount,
  131. canNoSelect: false,
  132. canEndNotMax: false,
  133. selectPermanentCoroutine: null,
  134. afterSelectPermanentCoroutine: null,
  135. mode: SelectPermanentEffect.Mode.Destroy,
  136. cardEffect: activateClass);
  137. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  138. }
  139. }
  140. if (card.Owner.Enemy.SecurityCards.Count >= 4)
  141. {
  142. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  143. player: card.Owner.Enemy,
  144. destroySecurityCount: 1,
  145. cardEffect: activateClass,
  146. fromTop: true).DestroySecurity());
  147. }
  148. }
  149. }
  150. if (timing == EffectTiming.OnEnterFieldAnyone)
  151. {
  152. ActivateClass activateClass = new ActivateClass();
  153. activateClass.SetUpICardEffect("Play 1 Digimon or Tamer from hand", CanUseCondition, card);
  154. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  155. cardEffects.Add(activateClass);
  156. string EffectDiscription()
  157. {
  158. return "[When Digivolving] You may play 1 red Digimon card with 5000 DP or less or 1 red Tamer card from your hand without paying the cost.";
  159. }
  160. bool CanSelectCardCondition(CardSource cardSource)
  161. {
  162. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  163. {
  164. if (cardSource.HasCardColor(CardColor.Red))
  165. {
  166. if (cardSource.IsDigimon)
  167. {
  168. if (cardSource.CardDP <= 5000)
  169. {
  170. if (cardSource.HasDP)
  171. {
  172. return true;
  173. }
  174. }
  175. }
  176. if (cardSource.IsTamer)
  177. {
  178. return true;
  179. }
  180. }
  181. }
  182. return false;
  183. }
  184. bool CanUseCondition(Hashtable hashtable)
  185. {
  186. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  187. }
  188. bool CanActivateCondition(Hashtable hashtable)
  189. {
  190. if (CardEffectCommons.IsExistOnBattleArea(card))
  191. {
  192. if (card.Owner.HandCards.Count >= 1)
  193. {
  194. return true;
  195. }
  196. }
  197. return false;
  198. }
  199. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  200. {
  201. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  202. {
  203. List<CardSource> selectedCards = new List<CardSource>();
  204. int maxCount = 1;
  205. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  206. selectHandEffect.SetUp(
  207. selectPlayer: card.Owner,
  208. canTargetCondition: CanSelectCardCondition,
  209. canTargetCondition_ByPreSelecetedList: null,
  210. canEndSelectCondition: null,
  211. maxCount: maxCount,
  212. canNoSelect: true,
  213. canEndNotMax: false,
  214. isShowOpponent: true,
  215. selectCardCoroutine: SelectCardCoroutine,
  216. afterSelectCardCoroutine: null,
  217. mode: SelectHandEffect.Mode.Custom,
  218. cardEffect: activateClass);
  219. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  220. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  221. yield return StartCoroutine(selectHandEffect.Activate());
  222. IEnumerator SelectCardCoroutine(CardSource cardSource)
  223. {
  224. selectedCards.Add(cardSource);
  225. yield return null;
  226. }
  227. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  228. }
  229. }
  230. }
  231. return cardEffects;
  232. }
  233. }
  234. }