P_208.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Merukimon
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_208 : 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.IsLevel5 &&
  18. (targetPermanent.TopCard.EqualsTraits("Beastkin") || targetPermanent.TopCard.HasTSTraits);
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Execute
  24. if (timing == EffectTiming.OnEndTurn)
  25. {
  26. cardEffects.Add(CardEffectFactory.ExecuteSelfEffect(isInheritedEffect: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region OP/OD Shared
  30. bool SharedCanSelectCardCondition(CardSource cardSource, ActivateClass activateClass)
  31. {
  32. return cardSource.IsDigimon
  33. && cardSource.HasLevel && cardSource.Level <= 4
  34. && (cardSource.HasAvianBeastAnimalTraits || cardSource.HasTSTraits)
  35. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  36. }
  37. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  38. {
  39. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, cs => SharedCanSelectCardCondition(cs, activateClass)))
  40. {
  41. CardSource selectedCard = null;
  42. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  43. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, cs => SharedCanSelectCardCondition(cs, activateClass)));
  44. selectCardEffect.SetUp(
  45. canTargetCondition: cs => SharedCanSelectCardCondition(cs, activateClass),
  46. canTargetCondition_ByPreSelecetedList: null,
  47. canEndSelectCondition: null,
  48. canNoSelect: () => true,
  49. selectCardCoroutine: SelectCardCoroutine,
  50. afterSelectCardCoroutine: null,
  51. message: "Select 1 card to play.",
  52. maxCount: maxCount,
  53. canEndNotMax: false,
  54. isShowOpponent: true,
  55. mode: SelectCardEffect.Mode.Custom,
  56. root: SelectCardEffect.Root.Trash,
  57. customRootCardList: null,
  58. canLookReverseCard: true,
  59. selectPlayer: card.Owner,
  60. cardEffect: activateClass);
  61. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  62. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  63. IEnumerator SelectCardCoroutine(CardSource cardSource)
  64. {
  65. selectedCard = cardSource;
  66. yield return null;
  67. }
  68. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  69. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  70. cardSources: new List<CardSource>() { selectedCard },
  71. activateClass: activateClass,
  72. payCost: false,
  73. isTapped: false,
  74. root: SelectCardEffect.Root.Trash,
  75. activateETB: true));
  76. }
  77. }
  78. #endregion
  79. #region When Digivolving
  80. if (timing == EffectTiming.OnEnterFieldAnyone)
  81. {
  82. ActivateClass activateClass = new ActivateClass();
  83. activateClass.SetUpICardEffect("Play 1 level 4 or lower [Avian]/[Bird]/[Beast]/[Animal]/Sovereign]/[TS] digimon from trash", CanUseCondition, card);
  84. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  85. cardEffects.Add(activateClass);
  86. string EffectDiscription()
  87. {
  88. return "[When Digivolving] You may play 1 level 4 or lower Digimon card with [Avian], [Bird], [Beast], [Animal] or [Sovereign] in any of its traits (other than [Sea Animal]) or the [TS] trait from your trash without paying the cost.";
  89. }
  90. bool CanUseCondition(Hashtable hashtable)
  91. {
  92. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  93. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  94. }
  95. bool CanActivateCondition(Hashtable hashtable)
  96. {
  97. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  98. }
  99. }
  100. #endregion
  101. #region On Deletion
  102. if (timing == EffectTiming.OnDestroyedAnyone)
  103. {
  104. ActivateClass activateClass = new ActivateClass();
  105. activateClass.SetUpICardEffect("Play 1 level 4 or lower [Avian]/[Bird]/[Beast]/[Animal]/Sovereign]/[TS] digimon from trash", CanUseCondition, card);
  106. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  107. cardEffects.Add(activateClass);
  108. string EffectDiscription()
  109. {
  110. return "[On Deletion] You may play 1 level 4 or lower Digimon card with [Avian], [Bird], [Beast], [Animal] or [Sovereign] in any of its traits (other than [Sea Animal]) or the [TS] trait from your trash without paying the cost.";
  111. }
  112. bool CanUseCondition(Hashtable hashtable)
  113. {
  114. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  115. }
  116. bool CanActivateCondition(Hashtable hashtable)
  117. {
  118. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  119. }
  120. }
  121. #endregion
  122. #region When Attacking - OPT
  123. if (timing == EffectTiming.OnAllyAttack)
  124. {
  125. ActivateClass activateClass = new ActivateClass();
  126. activateClass.SetUpICardEffect("Return 1 suspended digimon to bottom of deck", CanUseCondition, card);
  127. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  128. activateClass.SetHashString("P_208_WA");
  129. cardEffects.Add(activateClass);
  130. string EffectDiscription()
  131. {
  132. return "[When Attacking] [Once Per Turn] Return 1 of your opponent's suspended Digimon to the bottom of the deck.";
  133. }
  134. bool CanUseCondition(Hashtable hashtable)
  135. {
  136. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  137. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  138. }
  139. bool CanActivateCondition(Hashtable hashtable)
  140. {
  141. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  142. }
  143. bool CanSelectPermanentCondition(Permanent permanent)
  144. {
  145. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  146. && permanent.IsSuspended;
  147. }
  148. IEnumerator ActivateCoroutine(Hashtable hashtable)
  149. {
  150. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  151. {
  152. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  153. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  154. selectPermanentEffect.SetUp(
  155. selectPlayer: card.Owner,
  156. canTargetCondition: CanSelectPermanentCondition,
  157. canTargetCondition_ByPreSelecetedList: null,
  158. canEndSelectCondition: null,
  159. maxCount: maxCount,
  160. canNoSelect: false,
  161. canEndNotMax: false,
  162. selectPermanentCoroutine: null,
  163. afterSelectPermanentCoroutine: null,
  164. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  165. cardEffect: activateClass);
  166. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to return to bottom of deck.", "The opponent is selecting 1 Digimon to return to bottom of deck.");
  167. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  168. }
  169. }
  170. }
  171. #endregion
  172. return cardEffects;
  173. }
  174. }
  175. }