EX10_051.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Mummymon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_051 : 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 De-Digivolve-1 1 of your 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, <De-Digivolve 1> 1 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. bool CanSelectPermanentCondition(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  36. }
  37. IEnumerator ActivateCoroutine(Hashtable hashtable)
  38. {
  39. // First select the card to discard
  40. bool discarded = false;
  41. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  42. selectHandEffect.SetUp(
  43. canTargetCondition: _ => true,
  44. canTargetCondition_ByPreSelecetedList: null,
  45. canEndSelectCondition: null,
  46. canNoSelect: true,
  47. selectCardCoroutine: null,
  48. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  49. maxCount: 1,
  50. canEndNotMax: false,
  51. isShowOpponent: true,
  52. mode: SelectHandEffect.Mode.Discard,
  53. selectPlayer: card.Owner,
  54. cardEffect: activateClass);
  55. selectHandEffect.SetUpCustomMessage("Select 1 card to discard.",
  56. "The opponent is selecting 1 card to discard.");
  57. yield return StartCoroutine(selectHandEffect.Activate());
  58. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  59. {
  60. discarded = cardSources.Count > 0;
  61. yield return null;
  62. }
  63. // If the player discarded a card, continue with the rest of the effect
  64. if (discarded && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  65. {
  66. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  67. selectPermanentEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: CanSelectPermanentCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: CanEndSelectCondition,
  72. maxCount: 1,
  73. canNoSelect: false,
  74. canEndNotMax: false,
  75. selectPermanentCoroutine: SelectPermanentCoroutine,
  76. afterSelectPermanentCoroutine: null,
  77. mode: SelectPermanentEffect.Mode.Custom,
  78. cardEffect: activateClass);
  79. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  80. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  81. bool CanEndSelectCondition(List<Permanent> permanents)
  82. {
  83. if (permanents.Count <= 0)
  84. {
  85. return false;
  86. }
  87. return true;
  88. }
  89. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  90. {
  91. Permanent selectedPermanent = permanent;
  92. if (selectedPermanent != null)
  93. {
  94. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  95. }
  96. yield return null;
  97. }
  98. }
  99. }
  100. }
  101. #endregion
  102. #region On Deletion
  103. if (timing == EffectTiming.OnDestroyedAnyone)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect("Play 1 tamer with [Myotismon] in it's text from your trash.", CanUseCondition, card);
  107. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  108. cardEffects.Add(activateClass);
  109. string EffectDiscription()
  110. {
  111. 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.";
  112. }
  113. bool CanSelectCardCondition(CardSource cardSource)
  114. {
  115. if (cardSource != null)
  116. {
  117. if (cardSource.Owner == card.Owner)
  118. {
  119. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  120. {
  121. if (cardSource.HasText("Myotismon") && cardSource.IsTamer)
  122. {
  123. if (!card.Owner.GetBattleAreaPermanents().Some(permanent => cardSource.HasSameCardName(permanent.TopCard)))
  124. {
  125. return true;
  126. }
  127. }
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  136. }
  137. bool CanActivateCondition(Hashtable hashtable)
  138. {
  139. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  140. {
  141. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  142. {
  143. return true;
  144. }
  145. }
  146. return false;
  147. }
  148. IEnumerator ActivateCoroutine(Hashtable hashtable)
  149. {
  150. List<CardSource> selectedCards = new List<CardSource>();
  151. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  152. selectCardEffect.SetUp(
  153. canTargetCondition: CanSelectCardCondition,
  154. canTargetCondition_ByPreSelecetedList: null,
  155. canEndSelectCondition: null,
  156. canNoSelect: () => true,
  157. selectCardCoroutine: SelectCardCoroutine,
  158. afterSelectCardCoroutine: null,
  159. message: "Select 1 card to play.",
  160. maxCount: 1,
  161. canEndNotMax: false,
  162. isShowOpponent: true,
  163. mode: SelectCardEffect.Mode.Custom,
  164. root: SelectCardEffect.Root.Trash,
  165. customRootCardList: null,
  166. canLookReverseCard: true,
  167. selectPlayer: card.Owner,
  168. cardEffect: activateClass);
  169. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  170. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  171. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  172. IEnumerator SelectCardCoroutine(CardSource cardSource)
  173. {
  174. selectedCards.Add(cardSource);
  175. yield return null;
  176. }
  177. SelectCardEffect.Root root = SelectCardEffect.Root.Trash;
  178. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  179. cardSources: selectedCards,
  180. activateClass: activateClass,
  181. payCost: false,
  182. isTapped: false,
  183. root: root,
  184. activateETB: true));
  185. }
  186. }
  187. #endregion
  188. return cardEffects;
  189. }
  190. }
  191. }