ST23_03.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Cougarmon
  5. namespace DCGO.CardEffects.ST23
  6. {
  7. public class ST23_03 : 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 Shared OP / WD
  23. string SharedEffectName = "Add your top security to hand. <Recovery +1>";
  24. string SharedEffectDescription(string tag) => $"[{tag}] Add your top security card to the hand. Then, <Recovery +1>. (Place the top card of your deck as your top security card.)";
  25. CardEffectFactory.ActivateClassesForSharedEffects
  26. (ref cardEffects, timing, card,
  27. SharedEffectName,
  28. SharedActivateCoroutine,
  29. SharedEffectDescription,
  30. optional: false,
  31. onPlay: true,
  32. whenDigivolving: true);
  33. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  34. {
  35. if (card.Owner.SecurityCards.Any())
  36. {
  37. CardSource topCard = card.Owner.SecurityCards[0];
  38. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  39. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(player: card.Owner, refSkillInfos: ref ContinuousController.instance.nullSkillInfos, activateClass).ReduceSecurity());
  40. }
  41. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  42. }
  43. #endregion
  44. #region Your Turn
  45. if (timing == EffectTiming.BeforePayCost)
  46. {
  47. ActivateClass activateClass = new ActivateClass();
  48. activateClass.SetUpICardEffect("By trashing the bottom face down card under your tamer, Reduce the digivolution cost by 2", CanUseCondition, card);
  49. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  50. cardEffects.Add(activateClass);
  51. string EffectDescription()
  52. {
  53. 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.";
  54. }
  55. bool PermanentCondition(Permanent permanent)
  56. {
  57. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  58. && permanent == card.PermanentOfThisCard();
  59. }
  60. bool HasProperTrait(CardSource source)
  61. {
  62. return source.IsDigimon
  63. && source.EqualsTraits("Glowing Dawn");
  64. }
  65. bool CanUseCondition(Hashtable hashtable)
  66. {
  67. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  68. && CardEffectCommons.IsOwnerTurn(card)
  69. && CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, HasProperTrait)
  70. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, ValidTamerCondition);
  71. }
  72. bool FaceDownCards(CardSource cardSource) => cardSource.IsFaceDown;
  73. bool ValidTamerCondition(Permanent permanent)
  74. {
  75. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  76. && permanent.DigivolutionCards.Any(FaceDownCards);
  77. }
  78. bool CanActivateCondition(Hashtable hashtable)
  79. {
  80. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  81. }
  82. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  83. {
  84. bool trash = false;
  85. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  86. selectPermanentEffect1.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: ValidTamerCondition,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: 1,
  92. canNoSelect: true,
  93. canEndNotMax: false,
  94. selectPermanentCoroutine: null,
  95. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  96. mode: SelectPermanentEffect.Mode.Custom,
  97. cardEffect: activateClass);
  98. 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");
  99. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  100. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  101. {
  102. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 1, isFromTop: false, activateClass: activateClass, FaceDownCards));
  103. trash = true;
  104. }
  105. if (trash)
  106. {
  107. Hashtable hashtable = new Hashtable
  108. {
  109. { "CardEffect", activateClass }
  110. };
  111. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  112. ChangeCostClass changeCostClass = new ChangeCostClass();
  113. changeCostClass.SetUpICardEffect("Digivolution Cost -2", CanUseCondition1, card);
  114. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  115. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  116. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  117. bool CanUseCondition1(Hashtable hashtable)
  118. {
  119. return true;
  120. }
  121. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  122. {
  123. if (CardSourceCondition(cardSource)
  124. && RootCondition(root)
  125. && PermanentsCondition(targetPermanents))
  126. {
  127. Cost -= 2;
  128. }
  129. return Cost;
  130. }
  131. bool PermanentsCondition(List<Permanent> targetPermanents)
  132. {
  133. return targetPermanents != null
  134. && targetPermanents.Count(PermanentCondition) >= 1;
  135. }
  136. bool PermanentCondition(Permanent targetPermanent)
  137. {
  138. return targetPermanent.TopCard != null
  139. && targetPermanent.TopCard.Owner == card.Owner
  140. && targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent);
  141. }
  142. bool CardSourceCondition(CardSource cardSource)
  143. {
  144. return cardSource != null
  145. && cardSource.Owner == card.Owner
  146. && cardSource.EqualsTraits("Glowing Dawn");
  147. }
  148. bool RootCondition(SelectCardEffect.Root root) => true;
  149. bool isUpDown() => true;
  150. }
  151. }
  152. }
  153. #endregion
  154. #region Barrier - ESS
  155. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  156. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: true, card: card, condition: null));
  157. #endregion
  158. return cardEffects;
  159. }
  160. }
  161. }