BT19_057.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT19
  5. {
  6. public class BT19_057 : 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("Twilight") || 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 When Attacking
  24. if (timing == EffectTiming.OnAllyAttack)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Digivolve into [RaptorSparrowmon] 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. "[When Attacking] This Digimon may digivolve into [RaptorSparrowmon] under your Tamers without paying the cost.";
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  38. }
  39. bool DigivolveCardCondition(CardSource cardSource)
  40. {
  41. return cardSource.IsDigimon && cardSource.EqualsCardName("RaptorSparrowmon") &&
  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. cardEffects.Add(CardEffectFactory.SaveEffect(card: card));
  123. }
  124. #endregion
  125. #region Your Turn - ESS
  126. if (timing == EffectTiming.OnCounterTiming)
  127. {
  128. bool Condition()
  129. {
  130. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.IsOwnerTurn(card) &&
  131. card.PermanentOfThisCard().TopCard.EqualsTraits("Xros Heart");
  132. }
  133. cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(isInheritedEffect: true, card: card, condition: Condition));
  134. }
  135. #endregion
  136. return cardEffects;
  137. }
  138. }
  139. }