ST23_08.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Monarchlizamon
  6. namespace DCGO.CardEffects.ST23
  7. {
  8. public class ST23_08 : 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: 4, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Alliance
  24. if (timing == EffectTiming.OnAllyAttack)
  25. {
  26. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region Shared OP/WD
  30. string SharedEffectName = "Gain +3K until end of opponent's turn, if your turn by trashing bottom face-down card from your Tamer, may play/use 1 [Glowing Dawn] card with the cost reduced by 3";
  31. CardEffectFactory.ActivateClassesForSharedEffects
  32. (ref cardEffects, timing, card,
  33. SharedEffectName,
  34. SharedActivateCoroutine,
  35. SharedEffectDescription,
  36. optional: false,
  37. maxCountPerTurn: -1,
  38. onPlay: true,
  39. whenDigivolving: true);
  40. string SharedEffectDescription(string tag)
  41. => $"[{tag}] This Digimon gets +3000 DP until your opponent's turn ends. Then, if it's your turn, by trashing the bottom face-down card from under any of your Tamers, you may play or use 1 [Glowing Dawn] trait card from your hand with the cost reduced by 3.";
  42. bool TamerWithOneFaceDownSource(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  45. && permanent.DigivolutionCards.Any(CanSelectTrashSourceCardCondition);
  46. }
  47. bool CanSelectTrashSourceCardCondition(CardSource cardSource)
  48. {
  49. return cardSource.IsFlipped;
  50. }
  51. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  52. {
  53. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: card.PermanentOfThisCard(), changeValue: 3000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  54. if (CardEffectCommons.MatchConditionPermanentCount(TamerWithOneFaceDownSource) > 0 && CardEffectCommons.IsOwnerTurn(card))
  55. {
  56. bool trash = false;
  57. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  58. selectPermanentEffect1.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: TamerWithOneFaceDownSource,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. maxCount: 1,
  64. canNoSelect: true,
  65. canEndNotMax: false,
  66. selectPermanentCoroutine: null,
  67. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  68. mode: SelectPermanentEffect.Mode.Custom,
  69. cardEffect: activateClass);
  70. 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");
  71. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  72. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  73. {
  74. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  75. trash = true;
  76. }
  77. if (trash)
  78. {
  79. bool CanSelectCardCondition(CardSource cardSource)
  80. {
  81. return cardSource.EqualsTraits("Glowing Dawn")
  82. && ((cardSource.IsOption
  83. && !cardSource.CanNotPlayThisOption)
  84. || (cardSource.HasPlayCost
  85. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, true, activateClass, fixedCost: cardSource.GetCostItself - 3)));
  86. }
  87. CardSource selectedCard = null;
  88. List<CardSource> selectedCards = new List<CardSource>();
  89. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  90. selectHandEffect.SetUp(
  91. selectPlayer: card.Owner,
  92. canTargetCondition: CanSelectCardCondition,
  93. canTargetCondition_ByPreSelecetedList: null,
  94. canEndSelectCondition: null,
  95. maxCount: 1,
  96. canNoSelect: true,
  97. canEndNotMax: false,
  98. isShowOpponent: true,
  99. selectCardCoroutine: SelectCardCoroutine,
  100. afterSelectCardCoroutine: null,
  101. mode: SelectHandEffect.Mode.Custom,
  102. cardEffect: activateClass);
  103. selectHandEffect.SetUpCustomMessage("Select 1 card to play/use.", "The opponent is selecting 1 card to play/use.");
  104. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  105. IEnumerator SelectCardCoroutine(CardSource cardSource)
  106. {
  107. selectedCards.Add(cardSource);
  108. selectedCard = cardSource;
  109. yield return null;
  110. }
  111. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  112. if (selectedCards != null)
  113. {
  114. #region reduce use cost
  115. ChangeCostClass changeCostClass = new ChangeCostClass();
  116. changeCostClass.SetUpICardEffect($"Play/Use Cost -3", CanUseCondition1, card);
  117. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: PlayOrUseCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  118. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  119. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  120. ICardEffect GetCardEffect(EffectTiming _timing)
  121. {
  122. if (_timing == EffectTiming.None)
  123. {
  124. return changeCostClass;
  125. }
  126. return null;
  127. }
  128. bool CanUseCondition1(Hashtable hashtable)
  129. {
  130. return true;
  131. }
  132. bool PlayOrUseCondition(CardSource cardSource)
  133. {
  134. return true;
  135. }
  136. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  137. {
  138. if (PlayOrUseCondition(cardSource))
  139. {
  140. if (RootCondition(root))
  141. {
  142. if (PermanentsCondition(targetPermanents))
  143. {
  144. Cost -= 3;
  145. }
  146. }
  147. }
  148. return Cost;
  149. }
  150. bool PermanentsCondition(List<Permanent> targetPermanents)
  151. {
  152. if (targetPermanents == null)
  153. {
  154. return true;
  155. }
  156. else
  157. {
  158. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  159. {
  160. return true;
  161. }
  162. }
  163. return false;
  164. }
  165. bool RootCondition(SelectCardEffect.Root root)
  166. {
  167. return true;
  168. }
  169. bool isUpDown()
  170. {
  171. return true;
  172. }
  173. #endregion
  174. if (selectedCard.IsOption)
  175. {
  176. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  177. cardSources: selectedCards,
  178. activateClass: activateClass,
  179. payCost: true,
  180. root: SelectCardEffect.Root.Hand));
  181. }
  182. else
  183. {
  184. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  185. cardSources: selectedCards,
  186. activateClass: activateClass,
  187. payCost: true,
  188. isTapped: false,
  189. root: SelectCardEffect.Root.Hand,
  190. activateETB: true));
  191. }
  192. #region release effect
  193. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  194. #endregion
  195. }
  196. }
  197. }
  198. }
  199. #endregion
  200. #region End of Attack = ESS
  201. if (timing == EffectTiming.OnEndAttack)
  202. {
  203. ActivateClass activateClass = new ActivateClass();
  204. activateClass.SetUpICardEffect("By trashing a face-down card from under a tamer, unsuspend this [Glowing Dawn] Digimon", CanUseCondition, card);
  205. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  206. activateClass.SetIsInheritedEffect(true);
  207. activateClass.SetHashString("Unsuspend_ST24_08");
  208. activateClass.SetIsSkippable(true);
  209. cardEffects.Add(activateClass);
  210. string EffectDiscription()
  211. {
  212. return "[End of Attack] [Once Per Turn] By trashing the bottom face-down card from under any of your Tamers, this [Glowing Dawn] trait Digimon unsuspends.";
  213. }
  214. bool CanUseCondition(Hashtable hashtable)
  215. {
  216. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  217. }
  218. bool CanActivateCondition(Hashtable hashtable)
  219. {
  220. return CardEffectCommons.IsExistOnBattleArea(card)
  221. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, TamerWithOneFaceDownSource);
  222. }
  223. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  224. {
  225. bool trash = false;
  226. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  227. selectPermanentEffect1.SetUp(
  228. selectPlayer: card.Owner,
  229. canTargetCondition: TamerWithOneFaceDownSource,
  230. canTargetCondition_ByPreSelecetedList: null,
  231. canEndSelectCondition: null,
  232. maxCount: 1,
  233. canNoSelect: true,
  234. canEndNotMax: false,
  235. selectPermanentCoroutine: null,
  236. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  237. mode: SelectPermanentEffect.Mode.Custom,
  238. cardEffect: activateClass);
  239. selectPermanentEffect1.SetUpCustomMessage("Select 1 Tamer to trash 1 bottom face-down card from to unsuspend this Digimon", "The opponent is selecting 1 Tamer to trash 1 bottom face-down card from");
  240. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  241. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  242. {
  243. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  244. trash = true;
  245. }
  246. if (trash)
  247. {
  248. if (card.PermanentOfThisCard().TopCard.EqualsTraits("Glowing Dawn"))
  249. {
  250. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  251. }
  252. }
  253. else
  254. {
  255. activateClass.RemoveUse();
  256. }
  257. }
  258. }
  259. #endregion
  260. return cardEffects;
  261. }
  262. }
  263. }