P_172.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.P
  5. {
  6. public class P_172 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution Requirement
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsTraits("NSp") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region DNA
  22. if (timing == EffectTiming.None)
  23. {
  24. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  25. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  26. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  27. addJogressConditionClass.SetNotShowUI(true);
  28. cardEffects.Add(addJogressConditionClass);
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. return true;
  32. }
  33. JogressCondition GetJogress(CardSource cardSource)
  34. {
  35. if (cardSource == card)
  36. {
  37. bool PermanentCondition1(Permanent permanent)
  38. {
  39. if (permanent != null)
  40. {
  41. if (permanent.TopCard != null)
  42. {
  43. if (permanent.TopCard.Owner == card.Owner)
  44. {
  45. if (permanent.IsDigimon)
  46. {
  47. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  48. {
  49. if (permanent.TopCard.CardColors.Contains(CardColor.Yellow) || permanent.TopCard.CardColors.Contains(CardColor.Red))
  50. {
  51. if (permanent.Levels_ForJogress(card).Contains(5))
  52. {
  53. return true;
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }
  61. return false;
  62. }
  63. bool PermanentCondition2(Permanent permanent)
  64. {
  65. if (permanent != null)
  66. {
  67. if (permanent.TopCard != null)
  68. {
  69. if (permanent.TopCard.Owner == card.Owner)
  70. {
  71. if (permanent.IsDigimon)
  72. {
  73. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  74. {
  75. if (permanent.TopCard.CardColors.Contains(CardColor.Green) || permanent.TopCard.CardColors.Contains(CardColor.Black))
  76. {
  77. if (permanent.Levels_ForJogress(card).Contains(5))
  78. {
  79. return true;
  80. }
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
  87. return false;
  88. }
  89. JogressConditionElement[] elements = new JogressConditionElement[]
  90. {
  91. new JogressConditionElement(PermanentCondition1, "a level 5 Yellow/Red Digimon"),
  92. new JogressConditionElement(PermanentCondition2, "a level 5 Green/Black Digimon"),
  93. };
  94. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  95. return jogressCondition;
  96. }
  97. return null;
  98. }
  99. }
  100. #endregion
  101. #region Reduce Play Cost
  102. bool HasNatureSpiritsCondition(CardSource cardSource)
  103. {
  104. return CardEffectCommons.IsExistInSecurity(cardSource) &&
  105. cardSource.EqualsCardName("Nature Spirits");
  106. }
  107. #region Before Pay Cost - Condition Effect
  108. if (timing == EffectTiming.BeforePayCost)
  109. {
  110. ActivateClass activateClass = new ActivateClass();
  111. activateClass.SetUpICardEffect("If [Nature Spirits] is in your face up security cards get Play Cost -4", CanUseCondition, card);
  112. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  113. activateClass.SetHashString("PlayCost-4_P_172");
  114. cardEffects.Add(activateClass);
  115. string EffectDiscription()
  116. {
  117. return "When this card would be played, if [Nature Spirits] is in your face up security cards, reduce the play cost by 4.";
  118. }
  119. bool CardCondition(CardSource cardSource)
  120. {
  121. if (cardSource == card)
  122. {
  123. if (CardEffectCommons.IsExistOnHand(cardSource))
  124. {
  125. return true;
  126. }
  127. }
  128. return false;
  129. }
  130. bool CanNoSelect(CardSource cardSource)
  131. {
  132. if (cardSource != null)
  133. {
  134. if (cardSource.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) > cardSource.Owner.MaxMemoryCost)
  135. {
  136. return false;
  137. }
  138. }
  139. return true;
  140. }
  141. bool CanUseCondition(Hashtable hashtable)
  142. {
  143. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  144. }
  145. bool CanActivateCondition(Hashtable hashtable)
  146. {
  147. if (CardEffectCommons.IsExistOnHand(card))
  148. {
  149. if (CardEffectCommons.HasMatchConditionOwnersSecurity(card, HasNatureSpiritsCondition, false))
  150. {
  151. return true;
  152. }
  153. }
  154. return false;
  155. }
  156. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  157. {
  158. if (card.Owner.CanReduceCost(null, card))
  159. {
  160. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  161. }
  162. ChangeCostClass changeCostClass = new ChangeCostClass();
  163. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  164. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  165. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  166. bool CanUseCondition1(Hashtable hashtable)
  167. {
  168. return true;
  169. }
  170. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  171. {
  172. if (CardSourceCondition(cardSource))
  173. {
  174. if (RootCondition(root))
  175. {
  176. if (PermanentsCondition(targetPermanents))
  177. {
  178. int targetCost = 0;
  179. if (CardEffectCommons.HasMatchConditionOwnersSecurity(card, HasNatureSpiritsCondition, false))
  180. targetCost += 4;
  181. Cost -= targetCost;
  182. }
  183. }
  184. }
  185. return Cost;
  186. }
  187. bool PermanentsCondition(List<Permanent> targetPermanents)
  188. {
  189. if (targetPermanents == null)
  190. {
  191. return true;
  192. }
  193. else
  194. {
  195. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  196. {
  197. return true;
  198. }
  199. }
  200. return false;
  201. }
  202. bool CardSourceCondition(CardSource cardSource)
  203. {
  204. return cardSource == card;
  205. }
  206. bool RootCondition(SelectCardEffect.Root root)
  207. {
  208. return true;
  209. }
  210. bool isUpDown()
  211. {
  212. return true;
  213. }
  214. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  215. }
  216. }
  217. #endregion
  218. #region Reduce Play Cost - Not Shown
  219. if (timing == EffectTiming.None)
  220. {
  221. ChangeCostClass changeCostClass = new ChangeCostClass();
  222. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition, card);
  223. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  224. changeCostClass.SetNotShowUI(true);
  225. cardEffects.Add(changeCostClass);
  226. bool CanUseCondition(Hashtable hashtable)
  227. {
  228. if (card.Owner.HandCards.Contains(card))
  229. {
  230. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "If [Nature Spirits] is in your face up security cards get Play Cost -4");
  231. if (activateClass != null)
  232. {
  233. if (CardEffectCommons.HasMatchConditionOwnersSecurity(card, HasNatureSpiritsCondition, false))
  234. {
  235. return true;
  236. }
  237. }
  238. }
  239. return false;
  240. }
  241. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  242. {
  243. if (CardSourceCondition(cardSource))
  244. {
  245. if (RootCondition(root))
  246. {
  247. if (PermanentsCondition(targetPermanents))
  248. {
  249. int targetCount = 0;
  250. if (CardEffectCommons.HasMatchConditionOwnersSecurity(card, HasNatureSpiritsCondition, false))
  251. targetCount += 4;
  252. Cost -= targetCount;
  253. }
  254. }
  255. }
  256. return Cost;
  257. }
  258. bool PermanentsCondition(List<Permanent> targetPermanents)
  259. {
  260. if (targetPermanents == null)
  261. {
  262. return true;
  263. }
  264. else
  265. {
  266. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  267. {
  268. return true;
  269. }
  270. }
  271. return false;
  272. }
  273. bool CardSourceCondition(CardSource cardSource)
  274. {
  275. if (cardSource != null)
  276. {
  277. if (cardSource == card)
  278. {
  279. return true;
  280. }
  281. }
  282. return false;
  283. }
  284. bool RootCondition(SelectCardEffect.Root root)
  285. {
  286. return true;
  287. }
  288. bool isUpDown()
  289. {
  290. return true;
  291. }
  292. }
  293. #endregion
  294. #endregion
  295. #region Blocker
  296. if (timing == EffectTiming.None)
  297. {
  298. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  299. }
  300. #endregion
  301. #region On Play
  302. if (timing == EffectTiming.OnEnterFieldAnyone)
  303. {
  304. ActivateClass activateClass = new ActivateClass();
  305. activateClass.SetUpICardEffect("1 Digimon gets -5000DP, then delete 1 with 5000DP or less", CanUseCondition, card);
  306. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  307. cardEffects.Add(activateClass);
  308. string EffectDiscription()
  309. {
  310. return "[On Play] 1 of your opponent's Digimon gets -5000 DP for the turn. Then, delete 1 of their Digimon with 5000 DP or less.";
  311. }
  312. bool IsDigimonWithCorrectDP(Permanent permanent)
  313. {
  314. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  315. {
  316. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(5000, activateClass))
  317. {
  318. return true;
  319. }
  320. }
  321. return false;
  322. }
  323. bool CanSelectPermanentCondition(Permanent permanent)
  324. {
  325. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  326. }
  327. bool CanUseCondition(Hashtable hashtable)
  328. {
  329. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  330. }
  331. bool CanActivateCondition(Hashtable hashtable)
  332. {
  333. return CardEffectCommons.IsExistOnBattleArea(card) &&
  334. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  335. }
  336. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  337. {
  338. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  339. {
  340. Permanent selectedPermanent = null;
  341. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  342. selectPermanentEffect.SetUp(
  343. selectPlayer: card.Owner,
  344. canTargetCondition: CanSelectPermanentCondition,
  345. canTargetCondition_ByPreSelecetedList: null,
  346. canEndSelectCondition: null,
  347. maxCount: 1,
  348. canNoSelect: false,
  349. canEndNotMax: false,
  350. selectPermanentCoroutine: SelectTargetCoroutine,
  351. afterSelectPermanentCoroutine: null,
  352. mode: SelectPermanentEffect.Mode.Custom,
  353. cardEffect: activateClass);
  354. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  355. IEnumerator SelectTargetCoroutine(Permanent permanent)
  356. {
  357. selectedPermanent = permanent;
  358. yield return null;
  359. }
  360. if(selectedPermanent != null)
  361. {
  362. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  363. targetPermanent: selectedPermanent,
  364. changeValue: -5000,
  365. effectDuration: EffectDuration.UntilEachTurnEnd,
  366. activateClass: activateClass));
  367. }
  368. }
  369. if (CardEffectCommons.HasMatchConditionPermanent(IsDigimonWithCorrectDP))
  370. {
  371. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  372. selectPermanentEffect.SetUp(
  373. selectPlayer: card.Owner,
  374. canTargetCondition: IsDigimonWithCorrectDP,
  375. canTargetCondition_ByPreSelecetedList: null,
  376. canEndSelectCondition: null,
  377. maxCount: 1,
  378. canNoSelect: false,
  379. canEndNotMax: false,
  380. selectPermanentCoroutine: null,
  381. afterSelectPermanentCoroutine: null,
  382. mode: SelectPermanentEffect.Mode.Destroy,
  383. cardEffect: activateClass);
  384. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  385. }
  386. }
  387. }
  388. #endregion
  389. #region On Deletion
  390. if (timing == EffectTiming.OnDestroyedAnyone)
  391. {
  392. ActivateClass activateClass = new ActivateClass();
  393. activateClass.SetUpICardEffect("1 Digimon gets -5000DP, then delete 1 with 5000DP or less", CanUseCondition, card);
  394. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  395. cardEffects.Add(activateClass);
  396. string EffectDiscription()
  397. {
  398. return "[On Deletion] 1 of your opponent's Digimon gets -5000 DP for the turn. Then, delete 1 of their Digimon with 5000 DP or less.";
  399. }
  400. bool IsDigimonWithCorrectDP(Permanent permanent)
  401. {
  402. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  403. {
  404. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(5000, activateClass))
  405. {
  406. return true;
  407. }
  408. }
  409. return false;
  410. }
  411. bool CanSelectPermanentCondition(Permanent permanent)
  412. {
  413. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  414. }
  415. bool CanUseCondition(Hashtable hashtable)
  416. {
  417. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  418. }
  419. bool CanActivateCondition(Hashtable hashtable)
  420. {
  421. return CardEffectCommons.CanActivateOnDeletion(card) &&
  422. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  423. }
  424. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  425. {
  426. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  427. {
  428. Permanent selectedPermanent = null;
  429. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  430. selectPermanentEffect.SetUp(
  431. selectPlayer: card.Owner,
  432. canTargetCondition: CanSelectPermanentCondition,
  433. canTargetCondition_ByPreSelecetedList: null,
  434. canEndSelectCondition: null,
  435. maxCount: 1,
  436. canNoSelect: false,
  437. canEndNotMax: false,
  438. selectPermanentCoroutine: SelectTargetCoroutine,
  439. afterSelectPermanentCoroutine: null,
  440. mode: SelectPermanentEffect.Mode.Custom,
  441. cardEffect: activateClass);
  442. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  443. IEnumerator SelectTargetCoroutine(Permanent permanent)
  444. {
  445. selectedPermanent = permanent;
  446. yield return null;
  447. }
  448. if (selectedPermanent != null)
  449. {
  450. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  451. targetPermanent: selectedPermanent,
  452. changeValue: -5000,
  453. effectDuration: EffectDuration.UntilEachTurnEnd,
  454. activateClass: activateClass));
  455. }
  456. }
  457. if (CardEffectCommons.HasMatchConditionPermanent(IsDigimonWithCorrectDP))
  458. {
  459. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  460. selectPermanentEffect.SetUp(
  461. selectPlayer: card.Owner,
  462. canTargetCondition: IsDigimonWithCorrectDP,
  463. canTargetCondition_ByPreSelecetedList: null,
  464. canEndSelectCondition: null,
  465. maxCount: 1,
  466. canNoSelect: false,
  467. canEndNotMax: false,
  468. selectPermanentCoroutine: null,
  469. afterSelectPermanentCoroutine: null,
  470. mode: SelectPermanentEffect.Mode.Destroy,
  471. cardEffect: activateClass);
  472. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  473. }
  474. }
  475. }
  476. #endregion
  477. return cardEffects;
  478. }
  479. }
  480. }