ST23_04.cs 16 KB

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