BT19_008.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT19
  5. {
  6. public class BT19_008 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 2 &&
  17. targetPermanent.TopCard.EqualsTraits("Xros Heart");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition,
  20. digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region On Play
  24. if (timing == EffectTiming.OnEnterFieldAnyone)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Digivolve into [OmniShoutmon] from under your Tamers", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  29. cardEffects.Add(activateClass);
  30. string EffectDescription()
  31. {
  32. return
  33. "[On Play] This Digimon may digivolve into [OmniShoutmon] under your Tamers without paying the cost.";
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  38. }
  39. bool DigivolveCardCondition(CardSource cardSource)
  40. {
  41. return cardSource.IsDigimon && cardSource.EqualsCardName("OmniShoutmon") &&
  42. cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass);
  43. }
  44. bool TamerHasDigimonCondition(Permanent permanent)
  45. {
  46. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  47. permanent.IsTamer && permanent.DigivolutionCards.Count(DigivolveCardCondition) >= 1;
  48. }
  49. bool CanActivateCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  52. CardEffectCommons.HasMatchConditionPermanent(TamerHasDigimonCondition);
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable hashtable)
  55. {
  56. Permanent selectedPermanent = null;
  57. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  58. selectPermanentEffect.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: TamerHasDigimonCondition,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. maxCount: 1,
  64. canNoSelect: true,
  65. canEndNotMax: false,
  66. selectPermanentCoroutine: SelectPermanentCoroutine,
  67. afterSelectPermanentCoroutine: null,
  68. mode: SelectPermanentEffect.Mode.Custom,
  69. cardEffect: activateClass);
  70. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  71. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  72. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  73. {
  74. selectedPermanent = permanent;
  75. yield return null;
  76. }
  77. if (selectedPermanent != null)
  78. {
  79. List<CardSource> selectedCards = new List<CardSource>();
  80. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  81. selectCardEffect.SetUp(
  82. canTargetCondition: DigivolveCardCondition,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. canNoSelect: () => true,
  86. selectCardCoroutine: SelectCardCoroutine,
  87. afterSelectCardCoroutine: null,
  88. message: "Select 1 card to digivolve into.",
  89. maxCount: 1,
  90. canEndNotMax: false,
  91. isShowOpponent: true,
  92. mode: SelectCardEffect.Mode.Custom,
  93. root: SelectCardEffect.Root.Custom,
  94. customRootCardList: selectedPermanent.DigivolutionCards,
  95. canLookReverseCard: true,
  96. selectPlayer: card.Owner,
  97. cardEffect: activateClass);
  98. selectCardEffect.SetUpCustomMessage("Select 1 card to digivolve into.",
  99. "The opponent is selecting 1 card to digivolve into.");
  100. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolve Card");
  101. yield return StartCoroutine(selectCardEffect.Activate());
  102. IEnumerator SelectCardCoroutine(CardSource cardSource)
  103. {
  104. selectedCards.Add(cardSource);
  105. yield return null;
  106. }
  107. yield return ContinuousController.instance.StartCoroutine(new PlayCardClass(
  108. cardSources: selectedCards,
  109. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  110. payCost: false,
  111. targetPermanent: card.PermanentOfThisCard(),
  112. isTapped: false,
  113. root: SelectCardEffect.Root.DigivolutionCards,
  114. activateETB: true).PlayCard());
  115. }
  116. }
  117. }
  118. #endregion
  119. #region On Deletion
  120. if (timing == EffectTiming.OnDestroyedAnyone)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect("Reveal top 3 cards of the deck and play 1 [Xros Heart] Tamer from them, then <Save>",
  124. CanUseCondition, card);
  125. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  126. cardEffects.Add(activateClass);
  127. string EffectDescription()
  128. {
  129. return
  130. "[On Deletion] Reveal the top 3 cards of your deck. Play 1 Tamer card with the [Xros Heart] trait among them without paying the cost. Return the rest to the bottom of the deck. Then, <Save>.";
  131. }
  132. bool CanUseCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  135. }
  136. bool IsTamerCardCondition(CardSource cardSource)
  137. {
  138. return cardSource.IsTamer && cardSource.EqualsTraits("Xros Heart") &&
  139. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  140. }
  141. bool CanSelectSaveTamerPermanentCondition(Permanent permanent)
  142. {
  143. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  144. && permanent.IsTamer;
  145. }
  146. bool CanActivateCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  149. }
  150. IEnumerator ActivateCoroutine(Hashtable hashtable)
  151. {
  152. List<CardSource> selectedCards = new List<CardSource>();
  153. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.RevealDeckTopCardsAndSelect(
  154. revealCount: 3,
  155. selectCardConditions:
  156. new SelectCardConditionClass[]
  157. {
  158. new(
  159. canTargetCondition: IsTamerCardCondition,
  160. canTargetCondition_ByPreSelecetedList: null,
  161. canEndSelectCondition: null,
  162. canNoSelect: false,
  163. selectCardCoroutine: SelectCardCoroutine,
  164. message: "Select 1 Tamer with the [Xros Heart] trait.",
  165. maxCount: 1,
  166. canEndNotMax: false,
  167. mode: SelectCardEffect.Mode.Custom
  168. )
  169. },
  170. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  171. activateClass: activateClass,
  172. canNoAction: false
  173. ));
  174. IEnumerator SelectCardCoroutine(CardSource cardSource)
  175. {
  176. selectedCards.Add(cardSource);
  177. yield return null;
  178. }
  179. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  180. cardSources: selectedCards,
  181. activateClass: activateClass,
  182. payCost: false,
  183. isTapped: false,
  184. root: SelectCardEffect.Root.Library,
  185. activateETB: true));
  186. if (CardEffectCommons.CanActivateSave(hashtable, CanSelectSaveTamerPermanentCondition))
  187. {
  188. yield return ContinuousController.instance.StartCoroutine(
  189. CardEffectCommons.SaveProcess(hashtable, activateClass, card, CanSelectSaveTamerPermanentCondition));
  190. }
  191. }
  192. }
  193. #endregion
  194. #region Your Turn - ESS
  195. if (timing == EffectTiming.None)
  196. {
  197. bool Condition()
  198. {
  199. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.IsOwnerTurn(card) &&
  200. card.PermanentOfThisCard().TopCard.EqualsTraits("Xros Heart");
  201. }
  202. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: true, card: card, condition: Condition));
  203. }
  204. #endregion
  205. return cardEffects;
  206. }
  207. }
  208. }