EX9_044.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using Photon.Pun;
  6. using UnityEngine;
  7. //Hydramon
  8. namespace DCGO.CardEffects.EX9
  9. {
  10. public class EX9_044 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Alternate Digivolution Requirement
  16. if (timing == EffectTiming.None)
  17. {
  18. static bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. return targetPermanent.TopCard.HasWGTraits && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region When Would be Played
  26. if (timing == EffectTiming.BeforePayCost)
  27. {
  28. ActivateClass activateClass = new ActivateClass();
  29. activateClass.SetUpICardEffect("Suspend 1 of your [WG] trait Digimon to get Play Cost -4", CanUseCondition, card);
  30. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  31. activateClass.SetHashString("PlayCost-4_EX9_044");
  32. cardEffects.Add(activateClass);
  33. activateClass.SetIsDigimonEffect(true);
  34. string EffectDescription()
  35. {
  36. return
  37. "When this card would be played, by suspending 1 of your [WG] trait Digimon, reduce the play cost by 4.";
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  42. }
  43. bool CardCondition(CardSource cardSource)
  44. {
  45. return cardSource == card && CardEffectCommons.IsExistOnHand(cardSource);
  46. }
  47. bool CanSelectPermanentCondition(Permanent permanent)
  48. {
  49. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  50. permanent != null &&
  51. permanent.TopCard &&
  52. !permanent.TopCard.CanNotBeAffected(activateClass) &&
  53. !permanent.IsSuspended && permanent.CanSuspend &&
  54. permanent.TopCard.HasWGTraits;
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. return CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  59. }
  60. IEnumerator ActivateCoroutine(Hashtable hashtable)
  61. {
  62. bool canNoSelect = true;
  63. CardSource cardFromHashtable = CardEffectCommons.GetCardFromHashtable(hashtable);
  64. if (cardFromHashtable && cardFromHashtable.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) >
  65. cardFromHashtable.Owner.MaxMemoryCost)
  66. {
  67. canNoSelect = false;
  68. }
  69. Permanent selectedPermanent = null;
  70. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectPermanentCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: 1,
  77. canNoSelect: canNoSelect,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: SelectPermanentCoroutine,
  80. afterSelectPermanentCoroutine: null,
  81. mode: SelectPermanentEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.",
  84. "The opponent is selecting 1 Digimon to suspend.");
  85. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  86. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  87. {
  88. selectedPermanent = permanent;
  89. yield return null;
  90. }
  91. if (selectedPermanent != null)
  92. {
  93. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { selectedPermanent }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  94. if (card.Owner.CanReduceCost(null, card))
  95. {
  96. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  97. ChangeCostClass changeCostClass = new ChangeCostClass();
  98. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  99. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition,
  100. rootCondition: RootCondition, isUpDown: IsUpDown, isCheckAvailability: () => false,
  101. isChangePayingCost: () => true);
  102. card.Owner.UntilCalculateFixedCostEffect.Add(_ => changeCostClass);
  103. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  104. }
  105. bool CanUseCondition1(Hashtable hashtable1)
  106. {
  107. return true;
  108. }
  109. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  110. List<Permanent> targetPermanents)
  111. {
  112. if (CardSourceCondition(cardSource) &&
  113. RootCondition(root) &&
  114. PermanentsCondition(targetPermanents))
  115. {
  116. cost -= 4;
  117. }
  118. return cost;
  119. }
  120. bool PermanentsCondition(List<Permanent> targetPermanents)
  121. {
  122. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  123. }
  124. bool CardSourceCondition(CardSource cardSource)
  125. {
  126. return cardSource == card;
  127. }
  128. bool RootCondition(SelectCardEffect.Root root)
  129. {
  130. return true;
  131. }
  132. bool IsUpDown()
  133. {
  134. return true;
  135. }
  136. }
  137. }
  138. }
  139. #endregion
  140. #region Reduce Play Cost - Not Shown
  141. if (timing == EffectTiming.None)
  142. {
  143. ChangeCostClass changeCostClass = new ChangeCostClass();
  144. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  145. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition,
  146. rootCondition: RootCondition, isUpDown: IsUpDown, isCheckAvailability: () => true,
  147. isChangePayingCost: () => true);
  148. changeCostClass.SetNotShowUI(true);
  149. cardEffects.Add(changeCostClass);
  150. bool CanUseCondition1(Hashtable hashtable1)
  151. {
  152. return CardEffectCommons.MatchConditionPermanentCount(PermanentCondition) >= 1;
  153. }
  154. bool PermanentCondition(Permanent permanent)
  155. {
  156. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  157. !permanent.IsSuspended && permanent.CanSuspend &&
  158. permanent.TopCard.HasWGTraits;
  159. }
  160. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  161. List<Permanent> targetPermanents)
  162. {
  163. if (CardSourceCondition(cardSource) &&
  164. RootCondition(root) &&
  165. PermanentsCondition(targetPermanents))
  166. {
  167. cost -= 4;
  168. }
  169. return cost;
  170. }
  171. bool PermanentsCondition(List<Permanent> targetPermanents)
  172. {
  173. return targetPermanents == null ||
  174. targetPermanents.Count(targetPermanent => CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(targetPermanent) &&
  175. targetPermanent != null &&
  176. targetPermanent.TopCard &&
  177. !targetPermanent.TopCard.CanNotBeAffected(changeCostClass) &&
  178. !targetPermanent.IsSuspended && targetPermanent.CanSuspend &&
  179. targetPermanent.TopCard.HasWGTraits) <= 1;
  180. }
  181. bool CardSourceCondition(CardSource cardSource)
  182. {
  183. return cardSource == card;
  184. }
  185. bool RootCondition(SelectCardEffect.Root root)
  186. {
  187. return true;
  188. }
  189. bool IsUpDown()
  190. {
  191. return true;
  192. }
  193. }
  194. #endregion
  195. #region On Play/When Digivolving Shared
  196. bool OpponentsDigimon(Permanent permanent)
  197. {
  198. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) &&
  199. (permanent.IsDigimon || permanent.IsTamer);
  200. }
  201. #endregion
  202. #region On Play
  203. if (timing == EffectTiming.OnEnterFieldAnyone)
  204. {
  205. ActivateClass activateClass = new ActivateClass();
  206. activateClass.SetUpICardEffect("Suspend 1 Digimon/Tamer, 1 Digimon/Tamer Can't Unsuspend", CanUseCondition, card);
  207. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  208. cardEffects.Add(activateClass);
  209. string EffectDiscription()
  210. {
  211. return "[On Play] Suspend 1 of your opponent's Digimon or Tamers. Then, 1 of their Digimon or Tamers can't unsuspend until their turn ends.";
  212. }
  213. bool CanUseCondition(Hashtable hashtable)
  214. {
  215. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  216. }
  217. bool CanActivateCondition(Hashtable hashtable)
  218. {
  219. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  220. }
  221. IEnumerator ActivateCoroutine(Hashtable hashtable)
  222. {
  223. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon))
  224. {
  225. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  226. selectPermanentEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: OpponentsDigimon,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: 1,
  232. canNoSelect: false,
  233. canEndNotMax: false,
  234. selectPermanentCoroutine: null,
  235. afterSelectPermanentCoroutine: null,
  236. mode: SelectPermanentEffect.Mode.Tap,
  237. cardEffect: activateClass);
  238. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  239. selectPermanentEffect.SetUp(
  240. selectPlayer: card.Owner,
  241. canTargetCondition: OpponentsDigimon,
  242. canTargetCondition_ByPreSelecetedList: null,
  243. canEndSelectCondition: null,
  244. maxCount: 1,
  245. canNoSelect: false,
  246. canEndNotMax: false,
  247. selectPermanentCoroutine: SelectPermanentCoroutine,
  248. afterSelectPermanentCoroutine: null,
  249. mode: SelectPermanentEffect.Mode.Custom,
  250. cardEffect: activateClass);
  251. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon/Tamers that will not unsuspend.", "The opponent is selecting 1 Digimon/Tamers that will not unsuspend.");
  252. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  253. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  254. {
  255. Permanent selectedPermanent = permanent;
  256. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  257. targetPermanent: selectedPermanent,
  258. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  259. activateClass: activateClass,
  260. condition: null,
  261. effectName: "Can't unsuspend"
  262. ));
  263. }
  264. }
  265. yield return null;
  266. }
  267. }
  268. #endregion
  269. #region When Digivolving
  270. if (timing == EffectTiming.OnEnterFieldAnyone)
  271. {
  272. ActivateClass activateClass = new ActivateClass();
  273. activateClass.SetUpICardEffect("Suspend 1 Digimon/Tamer, 1 Digimon/Tamer Can't Unsuspend", CanUseCondition, card);
  274. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  275. cardEffects.Add(activateClass);
  276. string EffectDiscription()
  277. {
  278. return "[On Play] [When Digivolving] Suspend 1 of your opponent's Digimon or Tamers. Then, 1 of their Digimon or Tamers can't unsuspend until their turn ends.";
  279. }
  280. bool CanUseCondition(Hashtable hashtable)
  281. {
  282. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  283. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  284. }
  285. bool CanActivateCondition(Hashtable hashtable)
  286. {
  287. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  288. }
  289. IEnumerator ActivateCoroutine(Hashtable hashtable)
  290. {
  291. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon))
  292. {
  293. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  294. selectPermanentEffect.SetUp(
  295. selectPlayer: card.Owner,
  296. canTargetCondition: OpponentsDigimon,
  297. canTargetCondition_ByPreSelecetedList: null,
  298. canEndSelectCondition: null,
  299. maxCount: 1,
  300. canNoSelect: false,
  301. canEndNotMax: false,
  302. selectPermanentCoroutine: null,
  303. afterSelectPermanentCoroutine: null,
  304. mode: SelectPermanentEffect.Mode.Tap,
  305. cardEffect: activateClass);
  306. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  307. selectPermanentEffect.SetUp(
  308. selectPlayer: card.Owner,
  309. canTargetCondition: OpponentsDigimon,
  310. canTargetCondition_ByPreSelecetedList: null,
  311. canEndSelectCondition: null,
  312. maxCount: 1,
  313. canNoSelect: false,
  314. canEndNotMax: false,
  315. selectPermanentCoroutine: SelectPermanentCoroutine,
  316. afterSelectPermanentCoroutine: null,
  317. mode: SelectPermanentEffect.Mode.Custom,
  318. cardEffect: activateClass);
  319. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon/Tamers that will not unsuspend.", "The opponent is selecting 1 Digimon/Tamers that will not unsuspend.");
  320. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  321. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  322. {
  323. Permanent selectedPermanent = permanent;
  324. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  325. targetPermanent: selectedPermanent,
  326. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  327. activateClass: activateClass,
  328. condition: null,
  329. effectName: "Can't unsuspend"
  330. ));
  331. }
  332. }
  333. yield return null;
  334. }
  335. }
  336. #endregion
  337. #region Your Turn
  338. if (timing == EffectTiming.OnEnterFieldAnyone)
  339. {
  340. ActivateClass activateClass = new ActivateClass();
  341. activateClass.SetUpICardEffect("DNA Digivolve.", CanUseCondition, card);
  342. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  343. activateClass.SetHashString("DNADigivolve_EX9_044");
  344. cardEffects.Add(activateClass);
  345. string EffectDescription()
  346. {
  347. return "[Your Turn] [Once Per Turn] When your Digimon are played or digivolve, if any of them have the [WG] trait, 2 of your Digimon may DNA digivolve into a Digimon card with the [WG] trait in the hand.";
  348. }
  349. bool PermanentConditionWGEnterField(Permanent permanent)
  350. {
  351. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  352. {
  353. if (permanent.TopCard.HasWGTraits)
  354. {
  355. return true;
  356. }
  357. }
  358. return false;
  359. }
  360. bool CanUseCondition(Hashtable hashtable)
  361. {
  362. if (CardEffectCommons.IsExistOnBattleArea(card))
  363. {
  364. if (CardEffectCommons.IsOwnerTurn(card))
  365. {
  366. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentConditionWGEnterField))
  367. {
  368. return true;
  369. }
  370. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentConditionWGEnterField))
  371. {
  372. return true;
  373. }
  374. }
  375. }
  376. return false;
  377. }
  378. bool CanActivateCondition(Hashtable hashtable)
  379. {
  380. if (CardEffectCommons.IsExistOnBattleArea(card))
  381. {
  382. return true;
  383. }
  384. return false;
  385. }
  386. bool CanSelectDNACardCondition(CardSource cardSource)
  387. {
  388. return cardSource.IsDigimon &&
  389. cardSource.CanPlayJogress(true) &&
  390. cardSource.HasWGTraits;
  391. }
  392. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  393. {
  394. yield return ContinuousController.instance.StartCoroutine(
  395. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  396. CanSelectDNACardCondition,
  397. payCost: true,
  398. isHand: true,
  399. activateClass
  400. ));
  401. }
  402. }
  403. #endregion
  404. return cardEffects;
  405. }
  406. }
  407. }