LM_066.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. // Zephagamon // Divine Tempest Ligero
  7. namespace DCGO.CardEffects.LM
  8. {
  9. public class LM_066 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Digimon Effects
  15. #region Alternate Digivolution Requirement
  16. if (timing == EffectTiming.None)
  17. {
  18. bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. return targetPermanent.TopCard.HasPlayCost
  21. && targetPermanent.TopCard.GetCostItself >= 11
  22. && targetPermanent.TopCard.EqualsTraits("Vortex Warriors");
  23. }
  24. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  25. permanentCondition: PermanentCondition,
  26. digivolutionCost: 2,
  27. ignoreDigivolutionRequirement: false,
  28. card: card,
  29. condition: null));
  30. }
  31. #endregion
  32. #region Piercing
  33. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  34. {
  35. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  36. }
  37. #endregion
  38. #region Vortex
  39. if (timing == EffectTiming.OnEndTurn)
  40. {
  41. cardEffects.Add(CardEffectFactory.VortexSelfEffect(isInheritedEffect: false, card: card,
  42. condition: null));
  43. }
  44. #endregion
  45. #region Blocker
  46. if (timing == EffectTiming.None)
  47. {
  48. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  49. }
  50. #endregion
  51. #region Shared WD / WA
  52. string SharedHashString = "LM_066_WD/WA";
  53. string SharedEffectName = "May unsuspend 1 Digimon, then may battle 1 enemy Digimon";
  54. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] You may unsuspend 1 Digimon. Then, this Digimon may battle 1 of your opponent's Digimon.";
  55. CardEffectFactory.ActivateClassesForSharedEffects
  56. (ref cardEffects, timing, card,
  57. SharedEffectName,
  58. SharedActivateCoroutine,
  59. SharedEffectDescription,
  60. optional: false,
  61. isSkippable: true,
  62. maxCountPerTurn: 1,
  63. hashValue: SharedHashString,
  64. whenDigivolving: true,
  65. whenAttacking: true);
  66. bool CanSelectUnsuspendCondition(Permanent permanent)
  67. {
  68. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  69. && permanent.IsSuspended
  70. && permanent.CanUnsuspend;
  71. }
  72. bool CanSelectBattleCondtion(Permanent permanent)
  73. {
  74. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  75. }
  76. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  77. {
  78. bool Used = false;
  79. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectUnsuspendCondition))
  80. {
  81. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  82. selectPermanentEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: CanSelectUnsuspendCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: 1,
  88. canNoSelect: true,
  89. canEndNotMax: false,
  90. selectPermanentCoroutine: SelectPermanentCoroutine,
  91. afterSelectPermanentCoroutine: null,
  92. mode: SelectPermanentEffect.Mode.UnTap,
  93. cardEffect: activateClass);
  94. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to unsuspend.", "The opponent is selecting 1 Digimon to unsuspend.");
  95. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  96. {
  97. if (permanent != null)
  98. {
  99. Used = true;
  100. yield return null;
  101. }
  102. }
  103. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  104. }
  105. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectBattleCondtion))
  106. {
  107. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  108. selectPermanentEffect.SetUp(
  109. selectPlayer: card.Owner,
  110. canTargetCondition: CanSelectBattleCondtion,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. maxCount: 1,
  114. canNoSelect: true,
  115. canEndNotMax: false,
  116. selectPermanentCoroutine: SelectPermanentCoroutine,
  117. afterSelectPermanentCoroutine: null,
  118. mode: SelectPermanentEffect.Mode.Custom,
  119. cardEffect: activateClass);
  120. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to battle.", "The opponent is selecting 1 Digimon to battle.");
  121. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  122. {
  123. if (permanent != null)
  124. {
  125. Used = true;
  126. yield return ContinuousController.instance.StartCoroutine(new IBattle(card.PermanentOfThisCard(), permanent, null, true).Battle());
  127. }
  128. }
  129. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  130. }
  131. if (!Used) activateClass.RemoveUse();
  132. }
  133. #endregion
  134. #region All Turns
  135. if (timing == EffectTiming.WhenRemoveField)
  136. {
  137. ActivateClass activateClass = new ActivateClass();
  138. activateClass.SetUpICardEffect("Suspend 1 Digimon to not leave", CanUseCondition, card);
  139. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  140. activateClass.SetHashString("LM_066_AT");
  141. activateClass.SetIsSkippable(true);
  142. cardEffects.Add(activateClass);
  143. string EffectDescription()
  144. {
  145. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area other than by your effects, by suspending 1 Digimon, it doesn't leave.";
  146. }
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  150. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)
  151. && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  152. }
  153. bool CanActivateCondition(Hashtable hashtable)
  154. {
  155. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  156. && CardEffectCommons.HasMatchConditionPermanent(CanSelectSuspendCondition);
  157. }
  158. bool CanSelectSuspendCondition(Permanent permanent)
  159. {
  160. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  161. && !permanent.IsSuspended
  162. && permanent.CanSuspend;
  163. }
  164. IEnumerator ActivateCoroutine(Hashtable hashtable)
  165. {
  166. bool Used = false;
  167. Permanent selectedPermament = null;
  168. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  169. selectPermanentEffect.SetUp(
  170. selectPlayer: card.Owner,
  171. canTargetCondition: CanSelectSuspendCondition,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. maxCount: 1,
  175. canNoSelect: true,
  176. canEndNotMax: false,
  177. selectPermanentCoroutine: SelectPermanentCoroutine,
  178. afterSelectPermanentCoroutine: null,
  179. mode: SelectPermanentEffect.Mode.Custom,
  180. cardEffect: activateClass);
  181. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  182. {
  183. selectedPermament = permanent;
  184. Used = true;
  185. yield return null;
  186. }
  187. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  188. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SuspendPeremanentAndProcessAccordingToResult(
  189. new List<Permanent>() { selectedPermament },
  190. activateClass,
  191. SuccessProcess,
  192. null));
  193. IEnumerator SuccessProcess(List<Permanent> suspendedPermaments)
  194. {
  195. card.PermanentOfThisCard().willBeRemoveField = false;
  196. card.PermanentOfThisCard().HideDeleteEffect();
  197. card.PermanentOfThisCard().HideHandBounceEffect();
  198. card.PermanentOfThisCard().HideDeckBounceEffect();
  199. card.PermanentOfThisCard().HideWillRemoveFieldEffect();
  200. yield return null;
  201. }
  202. if (!Used) activateClass.RemoveUse();
  203. }
  204. }
  205. #endregion
  206. #endregion
  207. #region Option Effects
  208. #region Reduce Play Cost
  209. if (timing == EffectTiming.BeforePayCost)
  210. {
  211. ActivateClass activateClass = new ActivateClass();
  212. activateClass.SetUpICardEffect("Reduce Use Cost -2", CanUseCondition, card);
  213. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  214. activateClass.SetIsSkippable(true);
  215. cardEffects.Add(activateClass);
  216. string EffectDescription()
  217. {
  218. return "When this card would be used, by suspending 2 Digimon, reduce the cost by 2.";
  219. }
  220. bool CanUseCondition(Hashtable hashtable)
  221. {
  222. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, cardSource => cardSource == card);
  223. }
  224. bool CanActivateCondition(Hashtable hashtable)
  225. {
  226. return CardEffectCommons.MatchConditionPermanentCount(CanSelectSuspendCondition) >= 2;
  227. }
  228. bool CanSelectSuspendCondition(Permanent permanent)
  229. {
  230. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  231. && !permanent.IsSuspended;
  232. }
  233. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  234. {
  235. bool canNoSelect = true;
  236. if (card.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) >
  237. card.Owner.MaxMemoryCost)
  238. {
  239. canNoSelect = false;
  240. }
  241. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  242. {
  243. foreach (Permanent permanent1 in permanents)
  244. {
  245. if (canNoSelect == false
  246. && !permanent1.CanSuspend)
  247. {
  248. return false;
  249. }
  250. }
  251. return true;
  252. }
  253. List<Permanent> selectedPermanents = new List<Permanent>();
  254. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  255. selectPermanentEffect.SetUp(
  256. selectPlayer: card.Owner,
  257. canTargetCondition: CanSelectSuspendCondition,
  258. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  259. canEndSelectCondition: null,
  260. maxCount: 2,
  261. canNoSelect: canNoSelect,
  262. canEndNotMax: false,
  263. selectPermanentCoroutine: SelectPermanentCoroutine,
  264. afterSelectPermanentCoroutine: null,
  265. mode: SelectPermanentEffect.Mode.Custom,
  266. cardEffect: activateClass);
  267. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  268. {
  269. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SuspendPeremanentAndProcessAccordingToResult(
  270. new List<Permanent>() { permanent },
  271. activateClass,
  272. SuccessProcess,
  273. null));
  274. }
  275. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  276. IEnumerator SuccessProcess(List<Permanent> selectedPermanents)
  277. {
  278. if (card.Owner.CanReduceCost(null, card)) ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  279. ChangeCostClass changeCostClass = new ChangeCostClass();
  280. changeCostClass.SetUpICardEffect("Use Cost -2", CanUseCondition1, card);
  281. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  282. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  283. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  284. bool CanUseCondition1(Hashtable hashtable) => true;
  285. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  286. {
  287. if (CardSourceCondition(cardSource)
  288. && RootCondition(root)
  289. && PermanentsCondition(targetPermanents))
  290. {
  291. Cost -= 2;
  292. }
  293. return Cost;
  294. }
  295. bool PermanentsCondition(List<Permanent> targetPermanents)
  296. {
  297. return targetPermanents == null
  298. || targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0;
  299. }
  300. bool CardSourceCondition(CardSource cardSource)
  301. {
  302. return cardSource != null
  303. && cardSource == card;
  304. }
  305. bool RootCondition(SelectCardEffect.Root root) => true;
  306. bool isUpDown() => true;
  307. }
  308. }
  309. }
  310. if (timing == EffectTiming.None)
  311. {
  312. ChangeCostClass changeCostClass = new ChangeCostClass();
  313. changeCostClass.SetUpICardEffect("Use Cost -2", CanUseCondition, card);
  314. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  315. changeCostClass.SetNotShowUI(true);
  316. cardEffects.Add(changeCostClass);
  317. bool CanUseCondition(Hashtable hashtable)
  318. {
  319. return CardEffectCommons.IsExistOnHand(card)
  320. && CardEffectCommons.MatchConditionPermanentCount(CanSelectSuspendCondition) >= 2;
  321. }
  322. bool CanSelectSuspendCondition(Permanent permanent)
  323. {
  324. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  325. && !permanent.IsSuspended;
  326. }
  327. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  328. {
  329. if (CardSourceCondition(cardSource)
  330. && RootCondition(root)
  331. && PermanentsCondition(targetPermanents))
  332. {
  333. Cost -= 2;
  334. }
  335. return Cost;
  336. }
  337. bool PermanentsCondition(List<Permanent> targetPermanents)
  338. {
  339. return targetPermanents == null
  340. || targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0;
  341. }
  342. bool CardSourceCondition(CardSource cardSource)
  343. {
  344. return cardSource != null
  345. && cardSource == card;
  346. }
  347. bool RootCondition(SelectCardEffect.Root root) => true;
  348. bool isUpDown() => true;
  349. }
  350. #endregion
  351. #region Main
  352. if (timing == EffectTiming.OptionSkill)
  353. {
  354. ActivateClass activateClass = new ActivateClass();
  355. activateClass.SetUpICardEffect("1 enemy Digimon/Tamer can't unsuspend till end of their turn, then for every 2 suspended Digimon, bot deck 1 enemy Digimon", CanUseCondition, card);
  356. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  357. cardEffects.Add(activateClass);
  358. string EffectDescription()
  359. => "[Main] 1 of your opponent's Digimon or tamers can't unsuspend until their turn ends. Then, for every 2 suspended Digimon, return 1 of their Digimon to the bottom of the deck.";
  360. bool CanUseCondition(Hashtable hashtable)
  361. {
  362. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  363. }
  364. bool CanSelectPermanentCondition(Permanent permanent)
  365. {
  366. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  367. && (permanent.IsDigimon
  368. || permanent.IsTamer);
  369. }
  370. bool CanCountDigimonCondition(Permanent permanent)
  371. {
  372. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  373. && permanent.IsSuspended;
  374. }
  375. bool CanSelectBotDeckCondition(Permanent permanent)
  376. {
  377. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  378. }
  379. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  380. {
  381. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  382. {
  383. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  384. selectPermanentEffect.SetUp(
  385. selectPlayer: card.Owner,
  386. canTargetCondition: CanSelectPermanentCondition,
  387. canTargetCondition_ByPreSelecetedList: null,
  388. canEndSelectCondition: null,
  389. maxCount: 1,
  390. canNoSelect: false,
  391. canEndNotMax: false,
  392. selectPermanentCoroutine: SelectPermanentCoroutine,
  393. afterSelectPermanentCoroutine: null,
  394. mode: SelectPermanentEffect.Mode.Custom,
  395. cardEffect: activateClass);
  396. selectPermanentEffect.SetUpCustomMessage(
  397. "Select a Digimon or Tamers that will be unable to unsuspend.",
  398. "The opponent is selecting a Digimon or Tamers that will be unable to unsuspend.");
  399. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  400. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  401. {
  402. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCantUnsuspendUntilOpponentTurnEnd(
  403. targetPermanent: permanent,
  404. activateClass: activateClass
  405. ));
  406. }
  407. }
  408. int maxCount = Math.Min(CardEffectCommons.MatchConditionPermanentCount(CanSelectBotDeckCondition), Mathf.FloorToInt(CardEffectCommons.MatchConditionPermanentCount(CanCountDigimonCondition) / 2));
  409. if (maxCount > 0)
  410. {
  411. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  412. selectPermanentEffect.SetUp(
  413. selectPlayer: card.Owner,
  414. canTargetCondition: CanSelectBotDeckCondition,
  415. canTargetCondition_ByPreSelecetedList: null,
  416. canEndSelectCondition: null,
  417. maxCount: maxCount,
  418. canNoSelect: false,
  419. canEndNotMax: false,
  420. selectPermanentCoroutine: null,
  421. afterSelectPermanentCoroutine: null,
  422. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  423. cardEffect: activateClass);
  424. selectPermanentEffect.SetUpCustomMessage($"Select {maxCount} Digimon to bottom deck.", $"The opponent is selecting {maxCount} Digimon to bottom deck.");
  425. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  426. }
  427. }
  428. }
  429. #endregion
  430. #region Arts Digivolution
  431. if (timing == EffectTiming.None)
  432. {
  433. cardEffects.Add(CardEffectFactory.ArtsDigivolveEffect(card));
  434. }
  435. #endregion
  436. #endregion
  437. return cardEffects;
  438. }
  439. }
  440. }