EX8_074.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX8
  5. {
  6. public class EX8_074 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region When Would be Played
  12. if (timing == EffectTiming.BeforePayCost)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Suspend 2 Digimon to get Play Cost -4", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  17. activateClass.SetHashString("PlayCost-4_EX8_074");
  18. cardEffects.Add(activateClass);
  19. activateClass.SetIsDigimonEffect(true);
  20. string EffectDescription()
  21. {
  22. return
  23. "When this card would be played, by suspending 2 Digimon, reduce the play cost by 4.";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  28. }
  29. bool CardCondition(CardSource cardSource)
  30. {
  31. return cardSource == card && CardEffectCommons.IsExistOnHand(cardSource);
  32. }
  33. bool CanSelectPermanentCondition(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
  36. permanent != null &&
  37. permanent.TopCard &&
  38. !permanent.TopCard.CanNotBeAffected(activateClass) &&
  39. !permanent.IsSuspended && permanent.CanSuspend;
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition) >= 2;
  44. }
  45. IEnumerator ActivateCoroutine(Hashtable hashtable)
  46. {
  47. bool canNoSelect = true;
  48. CardSource cardFromHashtable = CardEffectCommons.GetCardFromHashtable(hashtable);
  49. if (cardFromHashtable && cardFromHashtable.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) >
  50. cardFromHashtable.Owner.MaxMemoryCost)
  51. {
  52. canNoSelect = false;
  53. }
  54. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  55. selectPermanentEffect.SetUp(
  56. selectPlayer: card.Owner,
  57. canTargetCondition: CanSelectPermanentCondition,
  58. canTargetCondition_ByPreSelecetedList: null,
  59. canEndSelectCondition: null,
  60. maxCount: 2,
  61. canNoSelect: canNoSelect,
  62. canEndNotMax: false,
  63. selectPermanentCoroutine: null,
  64. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  65. mode: SelectPermanentEffect.Mode.Custom,
  66. cardEffect: activateClass);
  67. selectPermanentEffect.SetUpCustomMessage("Select 2 Digimon to suspend.",
  68. "The opponent is selecting 2 Digimon to suspend.");
  69. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  70. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  71. {
  72. if (permanents.Count == 2)
  73. {
  74. foreach (var selectedPermanent in permanents)
  75. {
  76. yield return ContinuousController.instance.StartCoroutine(
  77. new SuspendPermanentsClass(new List<Permanent>() { selectedPermanent },
  78. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  79. }
  80. if (card.Owner.CanReduceCost(null, card))
  81. {
  82. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  83. }
  84. ChangeCostClass changeCostClass = new ChangeCostClass();
  85. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  86. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition,
  87. rootCondition: RootCondition, isUpDown: IsUpDown, isCheckAvailability: () => false,
  88. isChangePayingCost: () => true);
  89. card.Owner.UntilCalculateFixedCostEffect.Add(_ => changeCostClass);
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  91. bool CanUseCondition1(Hashtable hashtable1)
  92. {
  93. return true;
  94. }
  95. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  96. List<Permanent> targetPermanents)
  97. {
  98. if (CardSourceCondition(cardSource) &&
  99. RootCondition(root) &&
  100. PermanentsCondition(targetPermanents))
  101. {
  102. cost -= 4;
  103. }
  104. return cost;
  105. }
  106. bool PermanentsCondition(List<Permanent> targetPermanents)
  107. {
  108. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  109. }
  110. bool CardSourceCondition(CardSource cardSource)
  111. {
  112. return cardSource == card;
  113. }
  114. bool RootCondition(SelectCardEffect.Root root)
  115. {
  116. return true;
  117. }
  118. bool IsUpDown()
  119. {
  120. return true;
  121. }
  122. }
  123. }
  124. }
  125. }
  126. #endregion
  127. #region Reduce Play Cost - Not Shown
  128. if (timing == EffectTiming.None)
  129. {
  130. ChangeCostClass changeCostClass = new ChangeCostClass();
  131. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  132. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition,
  133. rootCondition: RootCondition, isUpDown: IsUpDown, isCheckAvailability: () => true,
  134. isChangePayingCost: () => true);
  135. changeCostClass.SetNotShowUI(true);
  136. cardEffects.Add(changeCostClass);
  137. bool CanUseCondition1(Hashtable hashtable1)
  138. {
  139. return CardEffectCommons.MatchConditionPermanentCount(PermanentCondition) >= 2;
  140. }
  141. bool PermanentCondition(Permanent permanent)
  142. {
  143. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
  144. !permanent.IsSuspended && permanent.CanSuspend;
  145. }
  146. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  147. List<Permanent> targetPermanents)
  148. {
  149. if (CardSourceCondition(cardSource) &&
  150. RootCondition(root) &&
  151. PermanentsCondition(targetPermanents))
  152. {
  153. cost -= 4;
  154. }
  155. return cost;
  156. }
  157. bool PermanentsCondition(List<Permanent> targetPermanents)
  158. {
  159. return targetPermanents == null ||
  160. targetPermanents.Count(targetPermanent => CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(targetPermanent) &&
  161. targetPermanent != null &&
  162. targetPermanent.TopCard &&
  163. !targetPermanent.TopCard.CanNotBeAffected(changeCostClass) &&
  164. !targetPermanent.IsSuspended && targetPermanent.CanSuspend) < 2;
  165. }
  166. bool CardSourceCondition(CardSource cardSource)
  167. {
  168. return cardSource == card;
  169. }
  170. bool RootCondition(SelectCardEffect.Root root)
  171. {
  172. return true;
  173. }
  174. bool IsUpDown()
  175. {
  176. return true;
  177. }
  178. }
  179. #endregion
  180. #region Alliance
  181. if (timing == EffectTiming.OnAllyAttack)
  182. {
  183. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  184. }
  185. #endregion
  186. #region Vortex
  187. if (timing == EffectTiming.OnEndTurn)
  188. {
  189. cardEffects.Add(CardEffectFactory.VortexSelfEffect(isInheritedEffect: false, card: card,
  190. condition: null));
  191. }
  192. #endregion
  193. #region When Digivolving
  194. if (timing == EffectTiming.OnEnterFieldAnyone)
  195. {
  196. ActivateClass activateClass = new ActivateClass();
  197. activateClass.SetUpICardEffect("Suspend 1 Digimon then Delete 1 Digimon", CanUseCondition, card);
  198. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  199. cardEffects.Add(activateClass);
  200. string EffectDescription()
  201. {
  202. return
  203. "[When Digivolving] You may suspend 1 Digimon. Then, you may delete 1 of your opponent's 8000 DP or lower Digimon. For each other suspended Digimon, add 3000 to this DP deletion effect's maximum.";
  204. }
  205. bool CanUseCondition(Hashtable hashtable)
  206. {
  207. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  208. }
  209. bool CanSelectSuspendPermanentCondition(Permanent permanent)
  210. {
  211. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  212. }
  213. int DeletionMaxDP()
  214. {
  215. return 8000 + (3000 * CardEffectCommons.MatchConditionPermanentCount(permanent => permanent.IsDigimon && permanent.IsSuspended && permanent != card.PermanentOfThisCard()));
  216. }
  217. bool CanSelectDeletePermanentCondition(Permanent permanent)
  218. {
  219. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  220. permanent.DP <= card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass);
  221. }
  222. bool CanActivateCondition(Hashtable hashtable)
  223. {
  224. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  225. }
  226. IEnumerator ActivateCoroutine(Hashtable hashtable)
  227. {
  228. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectSuspendPermanentCondition))
  229. {
  230. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  231. selectPermanentEffect.SetUp(
  232. selectPlayer: card.Owner,
  233. canTargetCondition: CanSelectSuspendPermanentCondition,
  234. canTargetCondition_ByPreSelecetedList: null,
  235. canEndSelectCondition: null,
  236. maxCount: 1,
  237. canNoSelect: true,
  238. canEndNotMax: false,
  239. selectPermanentCoroutine: null,
  240. afterSelectPermanentCoroutine: null,
  241. mode: SelectPermanentEffect.Mode.Tap,
  242. cardEffect: activateClass);
  243. selectPermanentEffect.SetUpCustomMessage(
  244. "Select 1 Digimon that will suspend.",
  245. "The opponent is selecting 1 Digimon that will suspend.");
  246. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  247. }
  248. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDeletePermanentCondition))
  249. {
  250. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  251. selectPermanentEffect.SetUp(
  252. selectPlayer: card.Owner,
  253. canTargetCondition: CanSelectDeletePermanentCondition,
  254. canTargetCondition_ByPreSelecetedList: null,
  255. canEndSelectCondition: null,
  256. maxCount: 1,
  257. canNoSelect: true,
  258. canEndNotMax: false,
  259. selectPermanentCoroutine: null,
  260. afterSelectPermanentCoroutine: null,
  261. mode: SelectPermanentEffect.Mode.Destroy,
  262. cardEffect: activateClass);
  263. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  264. }
  265. }
  266. }
  267. #endregion
  268. #region All Turns
  269. if (timing == EffectTiming.OnEnterFieldAnyone)
  270. {
  271. ActivateClass activateClass = new ActivateClass();
  272. activateClass.SetUpICardEffect("Activate 1 of this Digimon's [When Digivolving] effects", CanUseCondition, card);
  273. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  274. activateClass.SetHashString("PlayActivate_EX8_074");
  275. cardEffects.Add(activateClass);
  276. string EffectDescription()
  277. {
  278. return
  279. "[All Turns] (Once Per Turn) When Digimon are played, you may activate 1 of this Digimon's [When Digivolving] effects.";
  280. }
  281. bool PermanentCondition(Permanent permanent)
  282. {
  283. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  284. }
  285. bool CanUseCondition(Hashtable hashtable)
  286. {
  287. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  288. CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition);
  289. }
  290. bool CanActivateCondition(Hashtable hashtable)
  291. {
  292. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  293. }
  294. IEnumerator ActivateCoroutine(Hashtable hashtable)
  295. {
  296. List<ICardEffect> candidateEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone)
  297. .Clone()
  298. .Filter(cardEffect =>
  299. cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  300. if (candidateEffects.Count >= 1)
  301. {
  302. ICardEffect selectedEffect = null;
  303. if (candidateEffects.Count == 1)
  304. {
  305. selectedEffect = candidateEffects[0];
  306. }
  307. else
  308. {
  309. List<SkillInfo> skillInfos = candidateEffects
  310. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  311. List<CardSource> cardSources = candidateEffects
  312. .Map(cardEffect => cardEffect.EffectSourceCard);
  313. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  314. selectCardEffect.SetUp(
  315. canTargetCondition: _ => true,
  316. canTargetCondition_ByPreSelecetedList: null,
  317. canEndSelectCondition: null,
  318. canNoSelect: () => false,
  319. selectCardCoroutine: null,
  320. afterSelectCardCoroutine: null,
  321. message: "Select 1 effect to activate.",
  322. maxCount: 1,
  323. canEndNotMax: false,
  324. isShowOpponent: false,
  325. mode: SelectCardEffect.Mode.Custom,
  326. root: SelectCardEffect.Root.Custom,
  327. customRootCardList: cardSources,
  328. canLookReverseCard: true,
  329. selectPlayer: card.Owner,
  330. cardEffect: activateClass);
  331. selectCardEffect.SetNotShowCard();
  332. selectCardEffect.SetUpSkillInfos(skillInfos);
  333. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  334. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  335. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  336. {
  337. if (selectedIndexes.Count == 1)
  338. {
  339. selectedEffect = candidateEffects[selectedIndexes[0]];
  340. yield return null;
  341. }
  342. }
  343. }
  344. if (selectedEffect != null)
  345. {
  346. if (!selectedEffect.IsDisabled)
  347. {
  348. Hashtable effectHashtable =
  349. CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  350. selectedEffect.SetIsDigimonEffect(true);
  351. yield return ContinuousController.instance.StartCoroutine(
  352. ((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  353. }
  354. }
  355. }
  356. }
  357. }
  358. #endregion
  359. return cardEffects;
  360. }
  361. }
  362. }