BT19_047.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT19
  5. {
  6. public class BT19_047 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Play
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Digivolve into [AtlurBallistamon] from under your Tamers", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  17. cardEffects.Add(activateClass);
  18. string EffectDescription()
  19. {
  20. return
  21. "[On Play] This Digimon may digivolve into [AtlurBallistamon] under your Tamers without paying the cost.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  26. }
  27. bool DigivolveCardCondition(CardSource cardSource)
  28. {
  29. return cardSource.IsDigimon && cardSource.EqualsCardName("AtlurBallistamon") &&
  30. cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass);
  31. }
  32. bool TamerHasDigimonCondition(Permanent permanent)
  33. {
  34. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  35. permanent.IsTamer && permanent.DigivolutionCards.Count(DigivolveCardCondition) >= 1;
  36. }
  37. bool CanActivateCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  40. CardEffectCommons.HasMatchConditionPermanent(TamerHasDigimonCondition);
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable hashtable)
  43. {
  44. Permanent selectedPermanent = null;
  45. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  46. selectPermanentEffect.SetUp(
  47. selectPlayer: card.Owner,
  48. canTargetCondition: TamerHasDigimonCondition,
  49. canTargetCondition_ByPreSelecetedList: null,
  50. canEndSelectCondition: null,
  51. maxCount: 1,
  52. canNoSelect: true,
  53. canEndNotMax: false,
  54. selectPermanentCoroutine: SelectPermanentCoroutine,
  55. afterSelectPermanentCoroutine: null,
  56. mode: SelectPermanentEffect.Mode.Custom,
  57. cardEffect: activateClass);
  58. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  59. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  60. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  61. {
  62. selectedPermanent = permanent;
  63. yield return null;
  64. }
  65. if (selectedPermanent != null)
  66. {
  67. List<CardSource> selectedCards = new List<CardSource>();
  68. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  69. selectCardEffect.SetUp(
  70. canTargetCondition: DigivolveCardCondition,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. canNoSelect: () => true,
  74. selectCardCoroutine: SelectCardCoroutine,
  75. afterSelectCardCoroutine: null,
  76. message: "Select 1 card to digivolve into.",
  77. maxCount: 1,
  78. canEndNotMax: false,
  79. isShowOpponent: true,
  80. mode: SelectCardEffect.Mode.Custom,
  81. root: SelectCardEffect.Root.Custom,
  82. customRootCardList: selectedPermanent.DigivolutionCards,
  83. canLookReverseCard: true,
  84. selectPlayer: card.Owner,
  85. cardEffect: activateClass);
  86. selectCardEffect.SetUpCustomMessage("Select 1 card to digivolve into.",
  87. "The opponent is selecting 1 card to digivolve into.");
  88. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolve Card");
  89. yield return StartCoroutine(selectCardEffect.Activate());
  90. IEnumerator SelectCardCoroutine(CardSource cardSource)
  91. {
  92. selectedCards.Add(cardSource);
  93. yield return null;
  94. }
  95. yield return ContinuousController.instance.StartCoroutine(new PlayCardClass(
  96. cardSources: selectedCards,
  97. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  98. payCost: false,
  99. targetPermanent: card.PermanentOfThisCard(),
  100. isTapped: false,
  101. root: SelectCardEffect.Root.DigivolutionCards,
  102. activateETB: true).PlayCard());
  103. }
  104. }
  105. }
  106. #endregion
  107. #region On Deletion
  108. if (timing == EffectTiming.OnDestroyedAnyone)
  109. {
  110. cardEffects.Add(CardEffectFactory.SaveEffect(card: card));
  111. }
  112. #endregion
  113. #region Opponent Turn - ESS
  114. if (timing == EffectTiming.None)
  115. {
  116. bool Condition()
  117. {
  118. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.IsOpponentTurn(card) &&
  119. card.PermanentOfThisCard().TopCard.EqualsTraits("Xros Heart");
  120. }
  121. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: true, card: card, condition: Condition));
  122. }
  123. #endregion
  124. return cardEffects;
  125. }
  126. }
  127. }