BT19_027.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT19
  4. {
  5. public class BT19_027 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Decode
  11. if (timing == EffectTiming.WhenRemoveField)
  12. {
  13. bool SourceCondition(CardSource source)
  14. {
  15. return source.HasCardColor(CardColor.Blue) && source.HasLevel && source.IsLevel5;
  16. }
  17. string[] decodeStrings = { "(Blue Lv.5)", "Blue Level 5" };
  18. cardEffects.Add(CardEffectFactory.DecodeSelfEffect(card: card, isInheritedEffect: false, decodeStrings: decodeStrings, sourceCondition: SourceCondition, condition: null));
  19. }
  20. #endregion
  21. #region When Digivolving
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Play 1 Digimon from this Digimon's digivolution cards",
  26. CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  28. cardEffects.Add(activateClass);
  29. string EffectDescription()
  30. {
  31. return
  32. "[When Digivolving] You may play 1 level 4 or lower blue Digimon card from this Digimon's digivolution cards without paying the cost.";
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  37. }
  38. bool CanSelectSourceCardCondition(CardSource cardSource)
  39. {
  40. return cardSource.IsDigimon &&
  41. cardSource.HasLevel && cardSource.Level <= 4 &&
  42. cardSource.HasCardColor(CardColor.Blue) &&
  43. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  48. card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition);
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable hashtable)
  51. {
  52. List<CardSource> selectedCards = new List<CardSource>();
  53. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  54. selectCardEffect.SetUp(
  55. canTargetCondition: CanSelectSourceCardCondition,
  56. canTargetCondition_ByPreSelecetedList: null,
  57. canEndSelectCondition: null,
  58. canNoSelect: () => true,
  59. selectCardCoroutine: SelectCardCoroutine,
  60. afterSelectCardCoroutine: null,
  61. message: "Select 1 digivolution card to play.",
  62. maxCount: 1,
  63. canEndNotMax: false,
  64. isShowOpponent: true,
  65. mode: SelectCardEffect.Mode.Custom,
  66. root: SelectCardEffect.Root.Custom,
  67. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  68. canLookReverseCard: true,
  69. selectPlayer: card.Owner,
  70. cardEffect: activateClass);
  71. selectCardEffect.SetUpCustomMessage(
  72. "Select 1 digivolution card to play.",
  73. "The opponent is selecting 1 digivolution card to play.");
  74. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  75. yield return StartCoroutine(selectCardEffect.Activate());
  76. IEnumerator SelectCardCoroutine(CardSource cardSource)
  77. {
  78. selectedCards.Add(cardSource);
  79. yield return null;
  80. }
  81. yield return ContinuousController.instance.StartCoroutine(
  82. CardEffectCommons.PlayPermanentCards(
  83. cardSources: selectedCards,
  84. activateClass: activateClass,
  85. payCost: false,
  86. isTapped: false,
  87. root: SelectCardEffect.Root.DigivolutionCards,
  88. activateETB: true));
  89. }
  90. }
  91. #endregion
  92. #region End of Your Turn
  93. if (timing == EffectTiming.OnEndTurn)
  94. {
  95. ActivateClass activateClass = new ActivateClass();
  96. activateClass.SetUpICardEffect("Bottom deck 1 of your Digimon to bottom deck and opponent's Digimon with the same level",
  97. CanUseCondition, card);
  98. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  99. activateClass.SetHashString("BottomDeck_BT19_027");
  100. cardEffects.Add(activateClass);
  101. string EffectDescription()
  102. {
  103. return
  104. "[End of Your Turn] (Once Per Turn) By returning 1 of your Digimon to the bottom of the deck, return 1 of your opponent's Digimon with level equal to or lower to your Digimon to the bottom of the deck.";
  105. }
  106. bool CanUseCondition(Hashtable hashtable)
  107. {
  108. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  109. CardEffectCommons.IsOwnerTurn(card);
  110. }
  111. bool CanSelectOwnerPermanentCondition(Permanent permanent)
  112. {
  113. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  114. }
  115. bool CanSelectOpponentPermanentLevelCondition(Permanent permanent, int level)
  116. {
  117. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  118. permanent.TopCard.HasLevel && permanent.TopCard.Level <= level;
  119. }
  120. bool CanActivateCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  123. }
  124. IEnumerator ActivateCoroutine(Hashtable hashtable)
  125. {
  126. Permanent selectedPermanent = null;
  127. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  128. selectPermanentEffect.SetUp(
  129. selectPlayer: card.Owner,
  130. canTargetCondition_ByPreSelecetedList: null,
  131. canTargetCondition: CanSelectOwnerPermanentCondition,
  132. canEndSelectCondition: null,
  133. maxCount: 1,
  134. canNoSelect: true,
  135. canEndNotMax: false,
  136. selectPermanentCoroutine: SelectCardCoroutine,
  137. afterSelectPermanentCoroutine: null,
  138. mode: SelectPermanentEffect.Mode.Custom,
  139. cardEffect: activateClass);
  140. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to bottom deck.",
  141. "The opponent is selecting 1 Digimon to bottom deck.");
  142. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  143. IEnumerator SelectCardCoroutine(Permanent permanent)
  144. {
  145. selectedPermanent = permanent;
  146. yield return null;
  147. }
  148. if (selectedPermanent != null)
  149. {
  150. bool selectedHasLevel = selectedPermanent.TopCard.HasLevel;
  151. int selectedLevel = selectedPermanent.TopCard.Level;
  152. yield return ContinuousController.instance.StartCoroutine(
  153. new DeckBottomBounceClass(new List<Permanent> { selectedPermanent }, hashtable).DeckBounce());
  154. if (selectedHasLevel && selectedLevel > 0)
  155. {
  156. if (CardEffectCommons.HasMatchConditionPermanent(permanent =>
  157. CanSelectOpponentPermanentLevelCondition(permanent, selectedLevel)))
  158. {
  159. selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  160. selectPermanentEffect.SetUp(
  161. selectPlayer: card.Owner,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canTargetCondition: permanent =>
  164. CanSelectOpponentPermanentLevelCondition(permanent, selectedLevel),
  165. canEndSelectCondition: null,
  166. maxCount: 1,
  167. canNoSelect: false,
  168. canEndNotMax: false,
  169. selectPermanentCoroutine: null,
  170. afterSelectPermanentCoroutine: null,
  171. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  172. cardEffect: activateClass);
  173. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to bottom deck.",
  174. "The opponent is selecting 1 Digimon to bottom deck.");
  175. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  176. }
  177. }
  178. }
  179. }
  180. }
  181. #endregion
  182. return cardEffects;
  183. }
  184. }
  185. }