EX9_031.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Etemon
  5. namespace DCGO.CardEffects.EX9
  6. {
  7. public class EX9_031 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region Sukamon Digivolution Cost Reduction
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("Sukamon") && targetPermanent.TopCard.IsLevel4;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition,
  21. digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Level 4 DM Digivolution Cost Reduction
  25. if (timing == EffectTiming.None)
  26. {
  27. bool PermanentCondition(Permanent targetPermanent)
  28. {
  29. return targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.EqualsTraits("DM");
  30. }
  31. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition,
  32. digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  33. }
  34. #endregion
  35. #region Ver3 Digivolution Cost Reduction
  36. if (timing == EffectTiming.BeforePayCost)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect("Reduce the digivolution cost by 1 for each face-down source", CanUseCondition, card);
  40. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  41. cardEffects.Add(activateClass);
  42. string EffectDiscription()
  43. => "When any of your [Ver.3] trait Digimon would digivolve into this card, for each of their face-down digivolution cards, reduce the digivolution cost by 1.";
  44. bool PermanentEvoCondition(Permanent permanent)
  45. {
  46. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  47. {
  48. if (permanent.TopCard.EqualsTraits("Ver.3"))
  49. {
  50. return card.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass);
  51. }
  52. }
  53. return false;
  54. }
  55. bool CardCondition(CardSource source)
  56. {
  57. return (source == card);
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentEvoCondition))
  62. {
  63. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentEvoCondition, CardCondition))
  64. {
  65. return true;
  66. }
  67. }
  68. return false;
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  71. {
  72. Hashtable hashtable = new Hashtable();
  73. hashtable.Add("CardEffect", activateClass);
  74. Permanent targetPermanent = CardEffectCommons.GetPermanentsFromHashtable(_hashtable)[0];
  75. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  76. ChangeCostClass changeCostClass = new ChangeCostClass();
  77. changeCostClass.SetUpICardEffect($"Digivolution Cost -{ReduceCost()}", CanUseCondition, card);
  78. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  79. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  80. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  81. bool CanUseCondition(Hashtable hashtable)
  82. {
  83. return true;
  84. }
  85. int ReduceCost()
  86. {
  87. return targetPermanent.DigivolutionCards.Filter(x => x.IsFlipped).Count;
  88. }
  89. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  90. {
  91. if (CardSourceCondition(cardSource))
  92. {
  93. if (RootCondition(root))
  94. {
  95. if (PermanentsCondition(targetPermanents))
  96. {
  97. Cost -= ReduceCost();
  98. }
  99. }
  100. }
  101. return Cost;
  102. }
  103. bool PermanentsCondition(List<Permanent> targetPermanents)
  104. {
  105. if (targetPermanents != null)
  106. {
  107. if (targetPermanents.Exists(PermanentCondition))
  108. {
  109. return true;
  110. }
  111. }
  112. return false;
  113. }
  114. bool PermanentCondition(Permanent targetPermanent)
  115. {
  116. if (targetPermanent.TopCard != null)
  117. {
  118. return PermanentEvoCondition(targetPermanent);
  119. }
  120. return false;
  121. }
  122. bool CardSourceCondition(CardSource cardSource)
  123. {
  124. if (cardSource != null)
  125. {
  126. return CardCondition(cardSource);
  127. }
  128. return false;
  129. }
  130. bool RootCondition(SelectCardEffect.Root root)
  131. {
  132. return true;
  133. }
  134. bool isUpDown()
  135. {
  136. return true;
  137. }
  138. }
  139. }
  140. #endregion
  141. #region Security Attack +1
  142. if (timing == EffectTiming.None)
  143. {
  144. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
  145. changeValue: 1,
  146. isInheritedEffect: false,
  147. card: card,
  148. condition: null));
  149. }
  150. #endregion
  151. #endregion
  152. #region When Digivolving/When Attacking Shared
  153. IEnumerator SharedActivateCoroutine(ActivateClass activateClass)
  154. {
  155. bool CanSelectCardCondition(CardSource cardSource)
  156. {
  157. return cardSource.IsFlipped;
  158. }
  159. int cardEvoSources = card.PermanentOfThisCard().DigivolutionCards.Count;
  160. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(
  161. targetPermanent: card.PermanentOfThisCard(),
  162. trashCount: 1,
  163. isFromTop: false,
  164. activateClass: activateClass,
  165. cardCondition: CanSelectCardCondition
  166. ));
  167. if (card.PermanentOfThisCard().DigivolutionCards.Count < cardEvoSources)
  168. {
  169. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  170. }
  171. }
  172. #endregion
  173. #region When Digivolving
  174. if (timing == EffectTiming.OnEnterFieldAnyone)
  175. {
  176. ActivateClass activateClass = new ActivateClass();
  177. activateClass.SetUpICardEffect("Trash 1 face down digivolution card, to Recovery +1", CanUseCondition, card);
  178. activateClass.SetUpActivateClass(CanActivateCondition, _ => SharedActivateCoroutine(activateClass), 1, true, EffectDiscription());
  179. activateClass.SetHashString("Recovery_EX9_031");
  180. cardEffects.Add(activateClass);
  181. string EffectDiscription()
  182. {
  183. return "[When Digivolving] [Once Per Turn] By trashing this Digimon's bottom face-down digivolution card, <Recovery +1 (Deck)> (Place the top card of your deck on top of your security stack).";
  184. }
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  188. }
  189. bool CanActivateCondition(Hashtable hashtable)
  190. {
  191. return CardEffectCommons.IsExistOnBattleArea(card);
  192. }
  193. }
  194. #endregion
  195. #region When Attacking
  196. if (timing == EffectTiming.OnAllyAttack)
  197. {
  198. ActivateClass activateClass = new ActivateClass();
  199. activateClass.SetUpICardEffect("Trash 1 face down digivolution card, to Recovery +1", CanUseCondition, card);
  200. activateClass.SetUpActivateClass(CanActivateCondition, _ => SharedActivateCoroutine(activateClass), 1, true, EffectDiscription());
  201. activateClass.SetHashString("Recovery_EX9_031");
  202. cardEffects.Add(activateClass);
  203. string EffectDiscription()
  204. {
  205. return "[When Attacking] [Once Per Turn] By trashing this Digimon's bottom face-down digivolution card, <Recovery +1 (Deck)> (Place the top card of your deck on top of your security stack).";
  206. }
  207. bool CanUseCondition(Hashtable hashtable)
  208. {
  209. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  210. }
  211. bool CanActivateCondition(Hashtable hashtable)
  212. {
  213. return CardEffectCommons.IsExistOnBattleArea(card);
  214. }
  215. }
  216. #endregion
  217. #region ESS
  218. if (timing == EffectTiming.OnLoseSecurity)
  219. {
  220. ActivateClass activateClass = new ActivateClass();
  221. activateClass.SetUpICardEffect("DP -4000", CanUseCondition, card);
  222. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  223. activateClass.SetHashString("ESS_EX9_031");
  224. activateClass.SetIsInheritedEffect(true);
  225. cardEffects.Add(activateClass);
  226. string EffectDiscription()
  227. {
  228. return "[All Turns] [Once Per Turn] When your security stack is removed from, 1 of your opponent's Digimon gets -4000 DP for the turn.";
  229. }
  230. bool CanSelectPermanentCondition(Permanent permanent)
  231. {
  232. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  233. }
  234. bool CanUseCondition(Hashtable hashtable)
  235. {
  236. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  237. CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner);
  238. }
  239. bool CanActivateCondition(Hashtable hashtable)
  240. {
  241. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  242. }
  243. IEnumerator ActivateCoroutine(Hashtable hashtable)
  244. {
  245. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  246. {
  247. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  248. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  249. selectPermanentEffect.SetUp(
  250. selectPlayer: card.Owner,
  251. canTargetCondition: CanSelectPermanentCondition,
  252. canTargetCondition_ByPreSelecetedList: null,
  253. canEndSelectCondition: null,
  254. maxCount: maxCount,
  255. canNoSelect: false,
  256. canEndNotMax: false,
  257. selectPermanentCoroutine: SelectPermanentCoroutine,
  258. afterSelectPermanentCoroutine: null,
  259. mode: SelectPermanentEffect.Mode.Custom,
  260. cardEffect: activateClass);
  261. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.", "The opponent is selecting 1 Digimon that will get DP -4000.");
  262. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  263. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  264. {
  265. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -4000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  266. }
  267. }
  268. }
  269. }
  270. #endregion
  271. return cardEffects;
  272. }
  273. }
  274. }