P_191.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. // Apollomon
  8. namespace DCGO.CardEffects.P
  9. {
  10. public class P_191 : 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
  16. if (timing == EffectTiming.None)
  17. {
  18. bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. return targetPermanent.TopCard.IsLevel5 &&
  21. targetPermanent.TopCard.HasLightFangOrNightClawTraits;
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  24. }
  25. #endregion
  26. #region BlastDigivolve
  27. if (timing == EffectTiming.OnCounterTiming)
  28. {
  29. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  30. }
  31. #endregion
  32. #region On Play
  33. if (timing == EffectTiming.OnEnterFieldAnyone)
  34. {
  35. ActivateClass activateClass = new ActivateClass();
  36. activateClass.SetUpICardEffect($"-{DPChangeValue()}DP to 1 digimon for the turn, then delete up to 7k worth of digimon", CanUseCondition, card);
  37. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  38. cardEffects.Add(activateClass);
  39. string EffectDiscription()
  40. {
  41. return "[On Play] To 1 of your opponent’s Digimon, give -4000 DP for the turn for each of your Digimon with the [Olympos XII] trait. Then, delete up to 7000 DP total worth of their Digimon.";
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  46. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  51. }
  52. bool CanSelectPermanentCondition(Permanent permanent)
  53. {
  54. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  55. }
  56. int DPChangeValue() => card.Owner.GetBattleAreaDigimons().Filter(x => x.TopCard.EqualsTraits("Olympos XII")).Count * 4000;
  57. int DeletionMaxDP() => 7000;
  58. bool CanSelectDeletePermanentCondition(Permanent permanent)
  59. {
  60. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  61. {
  62. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable hashtable)
  70. {
  71. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  72. {
  73. Permanent selectedPermanent = null;
  74. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  75. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  76. selectPermanentEffect.SetUp(
  77. selectPlayer: card.Owner,
  78. canTargetCondition: CanSelectPermanentCondition,
  79. canTargetCondition_ByPreSelecetedList: null,
  80. canEndSelectCondition: null,
  81. maxCount: maxCount,
  82. canNoSelect: false,
  83. canEndNotMax: false,
  84. selectPermanentCoroutine: SelectPermanentCoroutine,
  85. afterSelectPermanentCoroutine: null,
  86. mode: SelectPermanentEffect.Mode.Custom,
  87. cardEffect: activateClass);
  88. selectPermanentEffect.SetUpCustomMessage(customMessageArray: CardEffectCommons.customPermanentMessageArray_ChangeDP(changeValue: -DPChangeValue(), maxCount: maxCount));
  89. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  90. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  91. {
  92. selectedPermanent = permanent;
  93. yield return null;
  94. }
  95. if (selectedPermanent != null)
  96. {
  97. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: selectedPermanent, changeValue: -DPChangeValue(), effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  98. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDeletePermanentCondition))
  99. {
  100. int maxCount1 = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectDeletePermanentCondition),
  101. CardEffectCommons.MatchConditionPermanentCount(CanSelectDeletePermanentCondition));
  102. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  103. selectPermanentEffect1.SetUp(
  104. selectPlayer: card.Owner,
  105. canTargetCondition: CanSelectDeletePermanentCondition,
  106. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  107. canEndSelectCondition: CanEndSelectCondition,
  108. maxCount: maxCount1,
  109. canNoSelect: false,
  110. canEndNotMax: true,
  111. selectPermanentCoroutine: null,
  112. afterSelectPermanentCoroutine: null,
  113. mode: SelectPermanentEffect.Mode.Destroy,
  114. cardEffect: activateClass);
  115. selectPermanentEffect.SetUpCustomMessage("Choose digimon to delete", "Opponent is choosing digimon to delete");
  116. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  117. bool CanEndSelectCondition(List<Permanent> permanents)
  118. {
  119. if (permanents.Count <= 0)
  120. {
  121. return false;
  122. }
  123. int sumDP = 0;
  124. foreach (Permanent permanent in permanents)
  125. {
  126. sumDP += permanent.DP;
  127. }
  128. if (sumDP > card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  129. {
  130. return false;
  131. }
  132. return true;
  133. }
  134. bool CanTargetConditionByPreSelectedList(List<Permanent> permanents, Permanent permanent)
  135. {
  136. int sumDP = 0;
  137. foreach (Permanent permanent1 in permanents)
  138. {
  139. sumDP += permanent1.DP;
  140. }
  141. sumDP += permanent.DP;
  142. if (sumDP > card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  143. {
  144. return false;
  145. }
  146. return true;
  147. }
  148. }
  149. }
  150. }
  151. }
  152. }
  153. #endregion
  154. #region When Digivolving
  155. if (timing == EffectTiming.OnEnterFieldAnyone)
  156. {
  157. ActivateClass activateClass = new ActivateClass();
  158. activateClass.SetUpICardEffect($"-{DPChangeValue()}DP to 1 digimon for the turn, then delete up to 7k worth of digimon", CanUseCondition, card);
  159. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  160. cardEffects.Add(activateClass);
  161. string EffectDiscription()
  162. {
  163. return "[When Digivolving] To 1 of your opponent’s Digimon, give -4000 DP for the turn for each of your Digimon with the [Olympos XII] trait. Then, delete up to 7000 DP total worth of their Digimon.";
  164. }
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  168. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  169. }
  170. bool CanActivateCondition(Hashtable hashtable)
  171. {
  172. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  173. }
  174. bool CanSelectPermanentCondition(Permanent permanent)
  175. {
  176. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  177. }
  178. int DPChangeValue() => card.Owner.GetBattleAreaDigimons().Filter(x => x.TopCard.EqualsTraits("Olympos XII")).Count * 4000;
  179. int DeletionMaxDP() => 7000;
  180. bool CanSelectDeletePermanentCondition(Permanent permanent)
  181. {
  182. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  183. {
  184. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  185. {
  186. return true;
  187. }
  188. }
  189. return false;
  190. }
  191. IEnumerator ActivateCoroutine(Hashtable hashtable)
  192. {
  193. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  194. {
  195. Permanent selectedPermanent = null;
  196. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  197. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  198. selectPermanentEffect.SetUp(
  199. selectPlayer: card.Owner,
  200. canTargetCondition: CanSelectPermanentCondition,
  201. canTargetCondition_ByPreSelecetedList: null,
  202. canEndSelectCondition: null,
  203. maxCount: maxCount,
  204. canNoSelect: false,
  205. canEndNotMax: false,
  206. selectPermanentCoroutine: SelectPermanentCoroutine,
  207. afterSelectPermanentCoroutine: null,
  208. mode: SelectPermanentEffect.Mode.Custom,
  209. cardEffect: activateClass);
  210. selectPermanentEffect.SetUpCustomMessage(customMessageArray: CardEffectCommons.customPermanentMessageArray_ChangeDP(changeValue: -DPChangeValue(), maxCount: maxCount));
  211. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  212. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  213. {
  214. selectedPermanent = permanent;
  215. yield return null;
  216. }
  217. if (selectedPermanent != null)
  218. {
  219. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: selectedPermanent, changeValue: -DPChangeValue(), effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  220. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDeletePermanentCondition))
  221. {
  222. int maxCount1 = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectDeletePermanentCondition),
  223. CardEffectCommons.MatchConditionPermanentCount(CanSelectDeletePermanentCondition));
  224. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  225. selectPermanentEffect1.SetUp(
  226. selectPlayer: card.Owner,
  227. canTargetCondition: CanSelectDeletePermanentCondition,
  228. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  229. canEndSelectCondition: CanEndSelectCondition,
  230. maxCount: maxCount1,
  231. canNoSelect: false,
  232. canEndNotMax: true,
  233. selectPermanentCoroutine: null,
  234. afterSelectPermanentCoroutine: null,
  235. mode: SelectPermanentEffect.Mode.Destroy,
  236. cardEffect: activateClass);
  237. selectPermanentEffect.SetUpCustomMessage("Choose digimon to delete", "Opponent is choosing digimon to delete");
  238. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  239. bool CanEndSelectCondition(List<Permanent> permanents)
  240. {
  241. if (permanents.Count <= 0)
  242. {
  243. return false;
  244. }
  245. int sumDP = 0;
  246. foreach (Permanent permanent in permanents)
  247. {
  248. sumDP += permanent.DP;
  249. }
  250. if (sumDP > card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  251. {
  252. return false;
  253. }
  254. return true;
  255. }
  256. bool CanTargetConditionByPreSelectedList(List<Permanent> permanents, Permanent permanent)
  257. {
  258. int sumDP = 0;
  259. foreach (Permanent permanent1 in permanents)
  260. {
  261. sumDP += permanent1.DP;
  262. }
  263. sumDP += permanent.DP;
  264. if (sumDP > card.Owner.MaxDP_DeleteEffect(DeletionMaxDP(), activateClass))
  265. {
  266. return false;
  267. }
  268. return true;
  269. }
  270. }
  271. }
  272. }
  273. }
  274. }
  275. #endregion
  276. #region End of Your Turn
  277. if (timing == EffectTiming.OnEndTurn)
  278. {
  279. ActivateClass activateClass = new ActivateClass();
  280. activateClass.SetUpICardEffect("DNA into [GraceNovamon]", CanUseCondition, card);
  281. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  282. cardEffects.Add(activateClass);
  283. string EffectDiscription()
  284. {
  285. return "[End of Your Turn] 2 of your Digimon may DNA digivolve into [GraceNovamon] in the hand. Then, 1 of your Digimon may attack.";
  286. }
  287. bool CanSelectDNACardCondition(CardSource cardSource)
  288. {
  289. return cardSource.IsDigimon &&
  290. cardSource.EqualsCardName("GraceNovamon") &&
  291. cardSource.CanPlayJogress(true);
  292. }
  293. bool IsYourAttackingDigimon(Permanent permanent)
  294. {
  295. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  296. permanent.CanAttack(activateClass);
  297. }
  298. bool CanUseCondition(Hashtable hashtable)
  299. {
  300. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  301. CardEffectCommons.IsOwnerTurn(card);
  302. }
  303. bool CanActivateCondition(Hashtable hashtable)
  304. {
  305. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  306. }
  307. IEnumerator ActivateCoroutine(Hashtable hashtable)
  308. {
  309. yield return ContinuousController.instance.StartCoroutine(
  310. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  311. CanSelectDNACardCondition,
  312. payCost: true,
  313. isHand: true,
  314. activateClass
  315. ));
  316. if (CardEffectCommons.HasMatchConditionPermanent(IsYourAttackingDigimon))
  317. {
  318. Permanent selectedPermanent = null;
  319. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  320. selectPermanentEffect.SetUp(
  321. selectPlayer: card.Owner,
  322. canTargetCondition: IsYourAttackingDigimon,
  323. canTargetCondition_ByPreSelecetedList: null,
  324. canEndSelectCondition: null,
  325. maxCount: 1,
  326. canNoSelect: true,
  327. canEndNotMax: false,
  328. selectPermanentCoroutine: SelectPermanentCoroutine,
  329. afterSelectPermanentCoroutine: null,
  330. mode: SelectPermanentEffect.Mode.Custom,
  331. cardEffect: activateClass);
  332. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  333. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  334. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  335. {
  336. selectedPermanent = permanent;
  337. yield return null;
  338. }
  339. if (selectedPermanent != null)
  340. {
  341. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  342. selectAttackEffect.SetUp(
  343. attacker: selectedPermanent,
  344. canAttackPlayerCondition: () => true,
  345. defenderCondition: _ => true,
  346. cardEffect: activateClass);
  347. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  348. }
  349. }
  350. }
  351. }
  352. #endregion
  353. #region ESS
  354. if (timing == EffectTiming.OnEndTurn)
  355. {
  356. ActivateClass activateClass = new ActivateClass();
  357. activateClass.SetUpICardEffect("1 digimon may attack", CanUseCondition, card);
  358. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  359. activateClass.SetIsInheritedEffect(true);
  360. activateClass.SetHashString("P_191_EndOfYourTurn");
  361. cardEffects.Add(activateClass);
  362. string EffectDiscription()
  363. {
  364. return "[End of Your Turn] [Once Per Turn] 1 of your Digimon may attack.";
  365. }
  366. bool CanUseCondition(Hashtable hashtable)
  367. {
  368. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  369. CardEffectCommons.IsOwnerTurn(card);
  370. }
  371. bool CanActivateCondition(Hashtable hashtable)
  372. {
  373. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  374. }
  375. bool IsYourAttackingDigimon(Permanent permanent)
  376. {
  377. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  378. permanent.CanAttack(activateClass);
  379. }
  380. IEnumerator ActivateCoroutine(Hashtable hashtable)
  381. {
  382. if (CardEffectCommons.HasMatchConditionPermanent(IsYourAttackingDigimon))
  383. {
  384. Permanent selectedPermanent = null;
  385. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  386. selectPermanentEffect.SetUp(
  387. selectPlayer: card.Owner,
  388. canTargetCondition: IsYourAttackingDigimon,
  389. canTargetCondition_ByPreSelecetedList: null,
  390. canEndSelectCondition: null,
  391. maxCount: 1,
  392. canNoSelect: true,
  393. canEndNotMax: false,
  394. selectPermanentCoroutine: SelectPermanentCoroutine,
  395. afterSelectPermanentCoroutine: null,
  396. mode: SelectPermanentEffect.Mode.Custom,
  397. cardEffect: activateClass);
  398. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  399. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  400. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  401. {
  402. selectedPermanent = permanent;
  403. yield return null;
  404. }
  405. if (selectedPermanent != null)
  406. {
  407. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  408. selectAttackEffect.SetUp(
  409. attacker: selectedPermanent,
  410. canAttackPlayerCondition: () => true,
  411. defenderCondition: _ => true,
  412. cardEffect: activateClass);
  413. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  414. }
  415. }
  416. }
  417. }
  418. #endregion
  419. return cardEffects;
  420. }
  421. }
  422. }