EX10_047.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Arukenimon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_047 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region On Play
  14. if (timing == EffectTiming.OnEnterFieldAnyone)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Trash 1 card from hand to delete up to 6000DP of opponent's Digimon", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[On Play] By trashing 1 card in your hand, delete up to 6000 DP total worth of your opponent's Digimon.";
  23. }
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  27. }
  28. bool CanActivateCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  31. card.Owner.HandCards.Count >= 1;
  32. }
  33. int DeletionMaxDP() => 6000;
  34. bool CanSelectDeletePermanentCondition(Permanent permanent)
  35. {
  36. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  37. {
  38. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  39. {
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. IEnumerator ActivateCoroutine(Hashtable hashtable)
  46. {
  47. // First select the card to discard
  48. bool discarded = false;
  49. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  50. selectHandEffect.SetUp(
  51. canTargetCondition: _ => true,
  52. canTargetCondition_ByPreSelecetedList: null,
  53. canEndSelectCondition: null,
  54. canNoSelect: true,
  55. selectCardCoroutine: null,
  56. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  57. maxCount: 1,
  58. canEndNotMax: false,
  59. isShowOpponent: true,
  60. mode: SelectHandEffect.Mode.Discard,
  61. selectPlayer: card.Owner,
  62. cardEffect: activateClass);
  63. selectHandEffect.SetUpCustomMessage("Select 1 card to discard.",
  64. "The opponent is selecting 1 card to discard.");
  65. yield return StartCoroutine(selectHandEffect.Activate());
  66. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  67. {
  68. discarded = cardSources.Count > 0;
  69. yield return null;
  70. }
  71. // If the player discarded a card, continue with the rest of the effect
  72. if (discarded && CardEffectCommons.HasMatchConditionPermanent(CanSelectDeletePermanentCondition))
  73. {
  74. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectDeletePermanentCondition),
  75. CardEffectCommons.MatchConditionPermanentCount(CanSelectDeletePermanentCondition));
  76. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: CanSelectDeletePermanentCondition,
  80. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  81. canEndSelectCondition: CanEndSelectCondition,
  82. maxCount: maxCount,
  83. canNoSelect: false,
  84. canEndNotMax: true,
  85. selectPermanentCoroutine: null,
  86. afterSelectPermanentCoroutine: null,
  87. mode: SelectPermanentEffect.Mode.Destroy,
  88. cardEffect: activateClass);
  89. selectPermanentEffect.SetUpCustomMessage("Choose digimon to delete", "Opponent is choosing digimon to delete");
  90. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  91. bool CanEndSelectCondition(List<Permanent> permanents)
  92. {
  93. if (permanents.Count <= 0)
  94. {
  95. return false;
  96. }
  97. int sumDP = 0;
  98. foreach (Permanent permanent in permanents)
  99. {
  100. sumDP += permanent.DP;
  101. }
  102. if (sumDP > card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  103. {
  104. return false;
  105. }
  106. return true;
  107. }
  108. bool CanTargetConditionByPreSelectedList(List<Permanent> permanents, Permanent permanent)
  109. {
  110. int sumDP = 0;
  111. foreach (Permanent permanent1 in permanents)
  112. {
  113. sumDP += permanent1.DP;
  114. }
  115. sumDP += permanent.DP;
  116. if (sumDP > card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  117. {
  118. return false;
  119. }
  120. return true;
  121. }
  122. }
  123. }
  124. }
  125. #endregion
  126. #region On Deletion
  127. if (timing == EffectTiming.OnDestroyedAnyone)
  128. {
  129. ActivateClass activateClass = new ActivateClass();
  130. activateClass.SetUpICardEffect("Play 1 tamer with [Myotismon] in it's text from your trash.", CanUseCondition, card);
  131. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  132. cardEffects.Add(activateClass);
  133. string EffectDiscription()
  134. {
  135. return "[On Deletion] You may play 1 Tamer card with [Myotismon] in its text from your trash without paying the cost. This effect can't play cards with the same name as any of your Tamers.";
  136. }
  137. bool CanSelectCardCondition(CardSource cardSource)
  138. {
  139. if (cardSource != null)
  140. {
  141. if (cardSource.Owner == card.Owner)
  142. {
  143. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  144. {
  145. if (cardSource.HasText("Myotismon") && cardSource.IsTamer)
  146. {
  147. if (!card.Owner.GetBattleAreaPermanents().Some(permanent => cardSource.HasSameCardName(permanent.TopCard)))
  148. {
  149. return true;
  150. }
  151. }
  152. }
  153. }
  154. }
  155. return false;
  156. }
  157. bool CanUseCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  160. }
  161. bool CanActivateCondition(Hashtable hashtable)
  162. {
  163. if (CardEffectCommons.CanActivateOnDeletion(card))
  164. {
  165. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  166. {
  167. return true;
  168. }
  169. }
  170. return false;
  171. }
  172. IEnumerator ActivateCoroutine(Hashtable hashtable)
  173. {
  174. int maxCount = 1;
  175. List<CardSource> selectedCards = new List<CardSource>();
  176. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  177. selectCardEffect.SetUp(
  178. canTargetCondition: CanSelectCardCondition,
  179. canTargetCondition_ByPreSelecetedList: null,
  180. canEndSelectCondition: null,
  181. canNoSelect: () => true,
  182. selectCardCoroutine: SelectCardCoroutine,
  183. afterSelectCardCoroutine: null,
  184. message: "Select 1 card to play.",
  185. maxCount: maxCount,
  186. canEndNotMax: false,
  187. isShowOpponent: true,
  188. mode: SelectCardEffect.Mode.Custom,
  189. root: SelectCardEffect.Root.Trash,
  190. customRootCardList: null,
  191. canLookReverseCard: true,
  192. selectPlayer: card.Owner,
  193. cardEffect: activateClass);
  194. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  195. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  196. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  197. IEnumerator SelectCardCoroutine(CardSource cardSource)
  198. {
  199. selectedCards.Add(cardSource);
  200. yield return null;
  201. }
  202. SelectCardEffect.Root root = SelectCardEffect.Root.Trash;
  203. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  204. cardSources: selectedCards,
  205. activateClass: activateClass,
  206. payCost: false,
  207. isTapped: false,
  208. root: root,
  209. activateETB: true));
  210. }
  211. }
  212. #endregion
  213. return cardEffects;
  214. }
  215. }
  216. }