EX9_053.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Mamemon
  5. namespace DCGO.CardEffects.EX9
  6. {
  7. public class EX9_053 : 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 Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasDMTraits && targetPermanent.TopCard.IsLevel4;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Collision
  23. if (timing == EffectTiming.OnCounterTiming)
  24. {
  25. cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, card, null));
  26. }
  27. #endregion
  28. #region On Play
  29. if (timing == EffectTiming.OnEnterFieldAnyone)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Reveal 3, Play 1 [DM] trait Digimon", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  34. cardEffects.Add(activateClass);
  35. string EffectDiscription()
  36. {
  37. return "[On Play] Reveal the top 3 cards of your deck. you may play 1 play cost 4 or lower [DM] trait card among them without paying the cost. For each of this Digimon's face-down digivolution cards, add 1 to this effect's play cost maximum. Return the rest to the bottom of the deck.";
  38. }
  39. int GetCostToPlay()
  40. {
  41. int cost = 4;
  42. cost += card.PermanentOfThisCard().DigivolutionCards.Count(x => x.IsFlipped);
  43. return cost;
  44. }
  45. bool SelectDigimonToPlay(CardSource source)
  46. {
  47. return source.HasDMTraits &&
  48. source.GetCostItself <= GetCostToPlay() &&
  49. CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass, SelectCardEffect.Root.Library);
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  54. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  59. card.Owner.LibraryCards.Count > 0;
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable hashtable)
  62. {
  63. List<CardSource> selectedCards = new List<CardSource>();
  64. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  65. revealCount: 3,
  66. simplifiedSelectCardConditions:
  67. new SimplifiedSelectCardConditionClass[]
  68. {
  69. new SimplifiedSelectCardConditionClass(
  70. canTargetCondition:SelectDigimonToPlay,
  71. message: "Select 1 card with [DM] trait.",
  72. mode: SelectCardEffect.Mode.Custom,
  73. maxCount: 1,
  74. selectCardCoroutine: CardSelected),
  75. },
  76. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  77. activateClass: activateClass
  78. ));
  79. IEnumerator CardSelected(CardSource source)
  80. {
  81. selectedCards.Add(source);
  82. yield return null;
  83. }
  84. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  85. cardSources: selectedCards,
  86. activateClass: activateClass,
  87. payCost: false,
  88. isTapped: false,
  89. root: SelectCardEffect.Root.Library,
  90. activateETB: true));
  91. }
  92. }
  93. #endregion
  94. #region When Digivolving
  95. if (timing == EffectTiming.OnEnterFieldAnyone)
  96. {
  97. ActivateClass activateClass = new ActivateClass();
  98. activateClass.SetUpICardEffect("Reveal 3, Play 1 [DM] trait Digimon", CanUseCondition, card);
  99. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  100. cardEffects.Add(activateClass);
  101. string EffectDiscription()
  102. {
  103. return "[When Digivolving] Reveal the top 3 cards of your deck. you may play 1 play cost 4 or lower [DM] trait card among them without paying the cost. For each of this Digimon's face-down digivolution cards, add 1 to this effect's play cost maximum. Return the rest to the bottom of the deck.";
  104. }
  105. int GetCostToPlay()
  106. {
  107. int cost = 4;
  108. cost += card.PermanentOfThisCard().DigivolutionCards.Count(x => x.IsFlipped);
  109. return cost;
  110. }
  111. bool SelectDigimonToPlay(CardSource source)
  112. {
  113. return source.HasDMTraits &&
  114. source.GetCostItself <= GetCostToPlay() &&
  115. CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass, SelectCardEffect.Root.Library);
  116. }
  117. bool CanUseCondition(Hashtable hashtable)
  118. {
  119. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  120. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  121. }
  122. bool CanActivateCondition(Hashtable hashtable)
  123. {
  124. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  125. card.Owner.LibraryCards.Count > 0;
  126. }
  127. IEnumerator ActivateCoroutine(Hashtable hashtable)
  128. {
  129. List<CardSource> selectedCards = new List<CardSource>();
  130. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  131. revealCount: 3,
  132. simplifiedSelectCardConditions:
  133. new SimplifiedSelectCardConditionClass[]
  134. {
  135. new SimplifiedSelectCardConditionClass(
  136. canTargetCondition:SelectDigimonToPlay,
  137. message: "Select 1 card with [DM] trait.",
  138. mode: SelectCardEffect.Mode.Custom,
  139. maxCount: 1,
  140. selectCardCoroutine: CardSelected),
  141. },
  142. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  143. activateClass: activateClass
  144. ));
  145. IEnumerator CardSelected(CardSource source)
  146. {
  147. selectedCards.Add(source);
  148. yield return null;
  149. }
  150. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  151. cardSources: selectedCards,
  152. activateClass: activateClass,
  153. payCost: false,
  154. isTapped: false,
  155. root: SelectCardEffect.Root.Library,
  156. activateETB: true));
  157. }
  158. }
  159. #endregion
  160. #region When Attacking - ESS
  161. if (timing == EffectTiming.OnAllyAttack)
  162. {
  163. ActivateClass activateClass = new ActivateClass();
  164. activateClass.SetUpICardEffect("De-Digivolve 1", CanUseCondition, card);
  165. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  166. activateClass.SetHashString("WA_EX9-053");
  167. activateClass.SetIsInheritedEffect(true);
  168. cardEffects.Add(activateClass);
  169. string EffectDiscription()
  170. {
  171. return "[When Attacking] [Once Per Turn] <De-Digivolve 1> 1 of your opponent's Digimon (Trash the top card. You can't trash past level 3 cards).";
  172. }
  173. bool IsOpponentDigimon(Permanent targetPermanent)
  174. {
  175. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(targetPermanent, card);
  176. }
  177. bool CanUseCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  180. }
  181. bool CanActivateCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  184. }
  185. IEnumerator ActivateCoroutine(Hashtable hashtable)
  186. {
  187. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentDigimon))
  188. {
  189. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  190. selectPermanentEffect.SetUp(
  191. selectPlayer: card.Owner,
  192. canTargetCondition: IsOpponentDigimon,
  193. canTargetCondition_ByPreSelecetedList: null,
  194. canEndSelectCondition: null,
  195. maxCount: 1,
  196. canNoSelect: false,
  197. canEndNotMax: false,
  198. selectPermanentCoroutine: SelectPermanentCoroutine1,
  199. afterSelectPermanentCoroutine: null,
  200. mode: SelectPermanentEffect.Mode.Custom,
  201. cardEffect: activateClass);
  202. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  203. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  204. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  205. {
  206. Permanent selectedPermanent = permanent;
  207. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  208. }
  209. }
  210. }
  211. }
  212. #endregion
  213. return cardEffects;
  214. }
  215. }
  216. }