ST23_03.cs 11 KB

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