BT25_049.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Armalizamon
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_049 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasGlowingDawnTraits;
  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 = "You may suspend 1 enemy Digimon";
  24. string SharedEffectDescription(string tag) => $"[{tag}] You may suspend 1 of your opponent's Digimon.";
  25. bool OpponentsDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. CardEffectFactory.ActivateClassesForSharedEffects
  27. (ref cardEffects, timing, card,
  28. SharedEffectName,
  29. SharedActivateCoroutine,
  30. SharedEffectDescription,
  31. optional: false,
  32. isSkippable: true,
  33. onPlay: true,
  34. whenDigivolving: true);
  35. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  36. {
  37. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  38. selectPermanentEffect.SetUp(
  39. selectPlayer: card.Owner,
  40. canTargetCondition: OpponentsDigimon,
  41. canTargetCondition_ByPreSelecetedList: null,
  42. canEndSelectCondition: null,
  43. maxCount: 1,
  44. canNoSelect: true,
  45. canEndNotMax: false,
  46. selectPermanentCoroutine: null,
  47. afterSelectPermanentCoroutine: null,
  48. mode: SelectPermanentEffect.Mode.Tap,
  49. cardEffect: activateClass);
  50. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  51. }
  52. #endregion
  53. #region Your Turn - Cost Reduction
  54. string CostReductionEffectName = "Trash 1 Face Down under a tamer to reduce cost by 3";
  55. bool TamerWithOneFaceDownSource(Permanent permanent)
  56. {
  57. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  58. && permanent.DigivolutionCards.Any(CanTrashCard);
  59. }
  60. bool CanTrashCard(CardSource cardSource) => cardSource.IsFaceDown;
  61. bool CardCondition(CardSource cardSource)
  62. {
  63. return cardSource.HasUseCost
  64. && cardSource.HasGlowingDawnTraits
  65. && cardSource.Owner == card.Owner;
  66. }
  67. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  68. {
  69. if (CardCondition(cardSource))
  70. {
  71. if (RootCondition(root))
  72. {
  73. if (PermanentsCondition(targetPermanents))
  74. {
  75. Cost -= 3;
  76. }
  77. }
  78. }
  79. return Cost;
  80. }
  81. bool PermanentsCondition(List<Permanent> targetPermanents)
  82. {
  83. if (targetPermanents == null)
  84. {
  85. return true;
  86. }
  87. else
  88. {
  89. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  90. {
  91. return true;
  92. }
  93. }
  94. return false;
  95. }
  96. bool RootCondition(SelectCardEffect.Root root)
  97. {
  98. return true;
  99. }
  100. #region Before Pay Cost - Condition Effect
  101. if (timing == EffectTiming.BeforePayCost)
  102. {
  103. ActivateClass activateClass = new ActivateClass();
  104. activateClass.SetUpICardEffect(CostReductionEffectName, CanUseCondition, card);
  105. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  106. activateClass.SetHashString("PlayCost-3_BT25_049");
  107. activateClass.SetIsSkippable(true);
  108. cardEffects.Add(activateClass);
  109. string EffectDescription()
  110. => "[Your Turn] [Once Per Turn] When you would use an Option card with the [Glowing Dawn] trait, by trashing the bottom face-down card under any of your Tamers, reduce the cost by 3.";
  111. bool CanNoSelect(Hashtable hashtable)
  112. {
  113. CardSource cardSource = CardEffectCommons.GetCardFromHashtable(hashtable);
  114. SelectCardEffect.Root root = SelectCardEffect.Root.None;
  115. if (CardEffectCommons.IsExistOnHand(cardSource))
  116. root = SelectCardEffect.Root.Hand;
  117. else if (CardEffectCommons.IsExistInAnyTrash(cardSource))
  118. root = SelectCardEffect.Root.Trash;
  119. else if (CardEffectCommons.IsExistDigivolutionCards(cardSource))
  120. root = SelectCardEffect.Root.DigivolutionCards;
  121. else if (CardEffectCommons.IsExistLinked(cardSource))
  122. root = SelectCardEffect.Root.LinkedCards;
  123. return cardSource != null
  124. && cardSource.PayingCost(root, null, checkAvailability: false) <= cardSource.Owner.MaxMemoryCost;
  125. }
  126. bool CanUseCondition(Hashtable hashtable)
  127. {
  128. return CardEffectCommons.IsExistOnBattleArea(card)
  129. && CardEffectCommons.IsOwnerTurn(card)
  130. && CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  131. }
  132. bool CanActivateCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.IsExistOnBattleArea(card)
  135. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, TamerWithOneFaceDownSource);
  136. }
  137. IEnumerator ActivateCoroutine(Hashtable hashtable)
  138. {
  139. bool trash = false;
  140. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  141. selectPermanentEffect1.SetUp(
  142. selectPlayer: card.Owner,
  143. canTargetCondition: TamerWithOneFaceDownSource,
  144. canTargetCondition_ByPreSelecetedList: null,
  145. canEndSelectCondition: null,
  146. maxCount: 1,
  147. canNoSelect: CanNoSelect(hashtable),
  148. canEndNotMax: false,
  149. selectPermanentCoroutine: null,
  150. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  151. mode: SelectPermanentEffect.Mode.Custom,
  152. cardEffect: activateClass);
  153. 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");
  154. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  155. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  156. {
  157. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanTrashCard));
  158. trash = true;
  159. }
  160. if (trash)
  161. {
  162. if (card.Owner.CanReduceCost(null, card))
  163. {
  164. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  165. }
  166. ChangeCostClass changeCostClass = new ChangeCostClass();
  167. changeCostClass.SetUpICardEffect("Play Cost -3", CanUseCondition1, card);
  168. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  169. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  170. bool CanUseCondition1(Hashtable _hashtable)
  171. {
  172. return true;
  173. }
  174. bool isUpDown()
  175. {
  176. return true;
  177. }
  178. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  179. }
  180. else activateClass.RemoveUse();
  181. }
  182. }
  183. #endregion
  184. #region Reduce Play Cost - Not Shown
  185. if (timing == EffectTiming.None)
  186. {
  187. ChangeCostClass changeCostClass = new ChangeCostClass();
  188. changeCostClass.SetUpICardEffect("Play Cost -3", CanUseCondition, card);
  189. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  190. changeCostClass.SetNotShowUI(true);
  191. cardEffects.Add(changeCostClass);
  192. bool CanUseCondition(Hashtable hashtable)
  193. {
  194. if (CardEffectCommons.IsExistOnBattleArea(card)
  195. && CardEffectCommons.IsOwnerTurn(card)
  196. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, TamerWithOneFaceDownSource))
  197. {
  198. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == CostReductionEffectName);
  199. return activateClass != null
  200. && !card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass, activateClass.MaxCountPerTurn);
  201. }
  202. return false;
  203. }
  204. bool isUpDown()
  205. {
  206. return true;
  207. }
  208. }
  209. #endregion
  210. #endregion
  211. #region Piercing - ESS
  212. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  213. {
  214. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: null));
  215. }
  216. #endregion
  217. return cardEffects;
  218. }
  219. }
  220. }