ST21_11.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //ST21 Metalgarurumon
  4. namespace DCGO.CardEffects.ST21
  5. {
  6. public class ST21_11 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alt Digivolution
  12. if(timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent permanent)
  15. {
  16. return permanent.Level == 5 && permanent.TopCard.HasAdventureTraits;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card, null));
  19. }
  20. #endregion
  21. #region Blast Digivolve
  22. if (timing == EffectTiming.OnCounterTiming)
  23. {
  24. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  25. }
  26. #endregion
  27. #region On Play/When Digivolving shared
  28. bool CanActivateConditionShared(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  31. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition);
  32. }
  33. bool CanGetCardColour(Permanent permanent) => permanent.IsTamer && permanent.TopCard.Owner == card.Owner;
  34. bool CanSelectPermanentCondition(Permanent permanent)
  35. {
  36. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.Level <= 4 + (CardEffectCommons.GetUniqueColourCountOnOwnerBattleArea(card, CanGetCardColour) / 2);
  37. }
  38. #endregion
  39. #region On Play
  40. if(timing == EffectTiming.OnEnterFieldAnyone)
  41. {
  42. ActivateClass activateClass = new ActivateClass();
  43. activateClass.SetUpICardEffect("Bottom-deck level 4 + tamer colours/2", CanUseCondition, card);
  44. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  45. cardEffects.Add(activateClass);
  46. string EffectDescription()
  47. {
  48. return "[On Play] Return 1 of your opponent's level 4 or lower Digimon to the bottom of the deck. For every 2 colors your Tamers have, add 1 to this effect's level maximum.";
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable hashtable)
  55. {
  56. SelectPermanentEffect selectReturnEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectReturnEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectPermanentCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: 1,
  63. canNoSelect: false,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: null,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  68. cardEffect: activateClass);
  69. selectReturnEffect.SetUpCustomMessage("Select 1 Digimon to return to bottom of deck.", "The opponent is selecting 1 Digimon to return to bottom of deck.");
  70. yield return ContinuousController.instance.StartCoroutine(selectReturnEffect.Activate());
  71. }
  72. }
  73. #endregion
  74. #region When Digivolving
  75. if (timing == EffectTiming.OnEnterFieldAnyone)
  76. {
  77. ActivateClass activateClass = new ActivateClass();
  78. activateClass.SetUpICardEffect("Bottom-deck level 4 + tamer colours/2", CanUseCondition, card);
  79. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  80. cardEffects.Add(activateClass);
  81. string EffectDescription()
  82. {
  83. return "[When Digivolving] Return 1 of your opponent's level 4 or lower Digimon to the bottom of the deck. For every 2 colors your Tamers have, add 1 to this effect's level maximum.";
  84. }
  85. bool CanUseCondition(Hashtable hashtable)
  86. {
  87. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  88. }
  89. IEnumerator ActivateCoroutine(Hashtable hashtable)
  90. {
  91. SelectPermanentEffect selectReturnEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  92. selectReturnEffect.SetUp(
  93. selectPlayer: card.Owner,
  94. canTargetCondition: CanSelectPermanentCondition,
  95. canTargetCondition_ByPreSelecetedList: null,
  96. canEndSelectCondition: null,
  97. maxCount: 1,
  98. canNoSelect: false,
  99. canEndNotMax: false,
  100. selectPermanentCoroutine: null,
  101. afterSelectPermanentCoroutine: null,
  102. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  103. cardEffect: activateClass);
  104. selectReturnEffect.SetUpCustomMessage("Select 1 Digimon to return to bottom of deck.", "The opponent is selecting 1 Digimon to return to bottom of deck.");
  105. yield return ContinuousController.instance.StartCoroutine(selectReturnEffect.Activate());
  106. }
  107. }
  108. #endregion
  109. #region When Attacking
  110. if(timing == EffectTiming.OnAllyAttack)
  111. {
  112. ActivateClass activateClass = new ActivateClass();
  113. activateClass.SetUpICardEffect("Play level 4", CanUseCondition, card);
  114. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  115. activateClass.SetHashString("WA_ST21-11");
  116. cardEffects.Add(activateClass);
  117. string EffectDescription()
  118. {
  119. return "[When Attacking][Once Per Turn] You may play 1 level 4 or lower Digimon card from your trash without paying the cost.";
  120. }
  121. bool PlayableCardCondition(CardSource cardSource)
  122. {
  123. return CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, SelectCardEffect.Root.Trash)
  124. && cardSource.IsDigimon && cardSource.Level <= 4;
  125. }
  126. bool CanUseCondition(Hashtable hashtable)
  127. {
  128. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  129. }
  130. bool CanActivateCondition(Hashtable hashtable)
  131. {
  132. return CardEffectCommons.IsExistOnField(card) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, PlayableCardCondition);
  133. }
  134. IEnumerator ActivateCoroutine(Hashtable hashtable)
  135. {
  136. List<CardSource> selectedCards = new List<CardSource>();
  137. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  138. selectCardEffect.SetUp(
  139. canTargetCondition: PlayableCardCondition,
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. canNoSelect: ()=>true,
  143. selectCardCoroutine: null,
  144. afterSelectCardCoroutine: SelectCardCoroutine,
  145. message: "Select 1 level 4 or lower Digimon card to play.",
  146. maxCount: 1,
  147. canEndNotMax: false,
  148. isShowOpponent: true,
  149. mode: SelectCardEffect.Mode.Custom,
  150. root: SelectCardEffect.Root.Trash,
  151. customRootCardList: null,
  152. canLookReverseCard: true,
  153. selectPlayer: card.Owner,
  154. cardEffect: activateClass);
  155. selectCardEffect.SetUpCustomMessage(
  156. "Select 1 level 4 or lower Digimon card to play.",
  157. "The opponent is selecting 1 level 4 or lower Digimon card to play.");
  158. selectCardEffect.SetUpCustomMessage_ShowCard("Play Card");
  159. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  160. IEnumerator SelectCardCoroutine(List<CardSource> sources)
  161. {
  162. selectedCards = sources;
  163. yield return null;
  164. }
  165. if (selectedCards.Count > 0)
  166. {
  167. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  168. cardSources: selectedCards,
  169. activateClass: activateClass,
  170. payCost: false,
  171. isTapped: false,
  172. root: SelectCardEffect.Root.Trash,
  173. activateETB: true));
  174. }
  175. }
  176. }
  177. #endregion
  178. return cardEffects;
  179. }
  180. }
  181. }