ST23_11.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Wolvermon
  5. namespace DCGO.CardEffects.ST23
  6. {
  7. public class ST23_11 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alt Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsTraits("Glowing Dawn");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 3, permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Blocker
  23. if (timing == EffectTiming.None)
  24. {
  25. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  26. }
  27. #endregion
  28. #region Your Turn
  29. if (timing == EffectTiming.BeforePayCost)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("By trashing the bottom face down card under your tamer, Reduce the digivolution cost by 2", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  34. cardEffects.Add(activateClass);
  35. string EffectDescription()
  36. {
  37. return "[Your Turn] When this Digimon would digivolve into a [Glowing Dawn] trait Digimon card, by trashing the bottom face-down card from under any of your Tamers, reduce the cost by 2.";
  38. }
  39. bool PermanentCondition(Permanent permanent)
  40. {
  41. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  42. && permanent == card.PermanentOfThisCard();
  43. }
  44. bool HasProperTrait(CardSource source)
  45. {
  46. return source.IsDigimon
  47. && source.EqualsTraits("Glowing Dawn");
  48. }
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  52. && CardEffectCommons.IsOwnerTurn(card)
  53. && CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, HasProperTrait)
  54. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, ValidTamerCondition);
  55. }
  56. bool FaceDownCards(CardSource cardSource) => cardSource.IsFlipped;
  57. bool ValidTamerCondition(Permanent permanent)
  58. {
  59. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  60. && permanent.DigivolutionCards.Any(FaceDownCards);
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  67. {
  68. bool trash = false;
  69. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  70. selectPermanentEffect1.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: ValidTamerCondition,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: 1,
  76. canNoSelect: true,
  77. canEndNotMax: false,
  78. selectPermanentCoroutine: null,
  79. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  80. mode: SelectPermanentEffect.Mode.Custom,
  81. cardEffect: activateClass);
  82. selectPermanentEffect1.SetUpCustomMessage("Select 1 Tamer to trash 1 bottom face-down card from", "The opponent is selecting 1 Tamer to trash 1 bottom face-down card from");
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  84. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  85. {
  86. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 1, isFromTop: false, activateClass: activateClass, FaceDownCards));
  87. trash = true;
  88. }
  89. if (trash)
  90. {
  91. Hashtable hashtable = new Hashtable();
  92. hashtable.Add("CardEffect", activateClass);
  93. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  94. ChangeCostClass changeCostClass = new ChangeCostClass();
  95. changeCostClass.SetUpICardEffect("Digivolution Cost -2", CanUseCondition1, card);
  96. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  97. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  98. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  99. bool CanUseCondition1(Hashtable hashtable)
  100. {
  101. return true;
  102. }
  103. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  104. {
  105. if (CardSourceCondition(cardSource)
  106. && RootCondition(root)
  107. && PermanentsCondition(targetPermanents))
  108. {
  109. Cost -= 2;
  110. }
  111. return Cost;
  112. }
  113. bool PermanentsCondition(List<Permanent> targetPermanents)
  114. {
  115. return targetPermanents != null
  116. && targetPermanents.Count(PermanentCondition) >= 1;
  117. }
  118. bool PermanentCondition(Permanent targetPermanent)
  119. {
  120. return targetPermanent.TopCard != null
  121. && targetPermanent.TopCard.Owner == card.Owner
  122. && targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent);
  123. }
  124. bool CardSourceCondition(CardSource cardSource)
  125. {
  126. return cardSource != null
  127. && cardSource.Owner == card.Owner
  128. && cardSource.EqualsTraits("Glowing Dawn");
  129. }
  130. bool RootCondition(SelectCardEffect.Root root)
  131. {
  132. return true;
  133. }
  134. bool isUpDown()
  135. {
  136. return true;
  137. }
  138. }
  139. }
  140. }
  141. #endregion
  142. #region Blocker - ESS
  143. if (timing == EffectTiming.None)
  144. {
  145. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  146. }
  147. #endregion
  148. return cardEffects;
  149. }
  150. }
  151. }