P_172.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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 CanUseCondition(Hashtable hashtable)
  131. {
  132. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  133. }
  134. bool CanActivateCondition(Hashtable hashtable)
  135. {
  136. if (CardEffectCommons.IsExistOnHand(card))
  137. {
  138. if (CardEffectCommons.HasMatchConditionOwnersSecurity(card, HasNatureSpiritsCondition, false))
  139. {
  140. return true;
  141. }
  142. }
  143. return false;
  144. }
  145. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  146. {
  147. if (card.Owner.CanReduceCost(null, card))
  148. {
  149. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  150. }
  151. ChangeCostClass changeCostClass = new ChangeCostClass();
  152. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  153. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  154. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  155. bool CanUseCondition1(Hashtable hashtable)
  156. {
  157. return true;
  158. }
  159. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  160. {
  161. if (CardSourceCondition(cardSource))
  162. {
  163. if (RootCondition(root))
  164. {
  165. if (PermanentsCondition(targetPermanents))
  166. {
  167. int targetCost = 0;
  168. if (CardEffectCommons.HasMatchConditionOwnersSecurity(card, HasNatureSpiritsCondition, false))
  169. targetCost += 4;
  170. Cost -= targetCost;
  171. }
  172. }
  173. }
  174. return Cost;
  175. }
  176. bool PermanentsCondition(List<Permanent> targetPermanents)
  177. {
  178. if (targetPermanents == null)
  179. {
  180. return true;
  181. }
  182. else
  183. {
  184. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  185. {
  186. return true;
  187. }
  188. }
  189. return false;
  190. }
  191. bool CardSourceCondition(CardSource cardSource)
  192. {
  193. return cardSource == card;
  194. }
  195. bool RootCondition(SelectCardEffect.Root root)
  196. {
  197. return true;
  198. }
  199. bool isUpDown()
  200. {
  201. return true;
  202. }
  203. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  204. }
  205. }
  206. #endregion
  207. #region Reduce Play Cost - Not Shown
  208. if (timing == EffectTiming.None)
  209. {
  210. ChangeCostClass changeCostClass = new ChangeCostClass();
  211. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition, card);
  212. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  213. changeCostClass.SetNotShowUI(true);
  214. cardEffects.Add(changeCostClass);
  215. bool CanUseCondition(Hashtable hashtable)
  216. {
  217. if (card.Owner.HandCards.Contains(card))
  218. {
  219. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "If [Nature Spirits] is in your face up security cards get Play Cost -4");
  220. if (activateClass != null)
  221. {
  222. if (CardEffectCommons.HasMatchConditionOwnersSecurity(card, HasNatureSpiritsCondition, false))
  223. {
  224. return true;
  225. }
  226. }
  227. }
  228. return false;
  229. }
  230. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  231. {
  232. if (CardSourceCondition(cardSource))
  233. {
  234. if (RootCondition(root))
  235. {
  236. if (PermanentsCondition(targetPermanents))
  237. {
  238. int targetCount = 0;
  239. if (CardEffectCommons.HasMatchConditionOwnersSecurity(card, HasNatureSpiritsCondition, false))
  240. targetCount += 4;
  241. Cost -= targetCount;
  242. }
  243. }
  244. }
  245. return Cost;
  246. }
  247. bool PermanentsCondition(List<Permanent> targetPermanents)
  248. {
  249. if (targetPermanents == null)
  250. {
  251. return true;
  252. }
  253. else
  254. {
  255. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  256. {
  257. return true;
  258. }
  259. }
  260. return false;
  261. }
  262. bool CardSourceCondition(CardSource cardSource)
  263. {
  264. if (cardSource != null)
  265. {
  266. if (cardSource == card)
  267. {
  268. return true;
  269. }
  270. }
  271. return false;
  272. }
  273. bool RootCondition(SelectCardEffect.Root root)
  274. {
  275. return true;
  276. }
  277. bool isUpDown()
  278. {
  279. return true;
  280. }
  281. }
  282. #endregion
  283. #endregion
  284. #region Blocker
  285. if (timing == EffectTiming.None)
  286. {
  287. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  288. }
  289. #endregion
  290. #region On Play
  291. if (timing == EffectTiming.OnEnterFieldAnyone)
  292. {
  293. ActivateClass activateClass = new ActivateClass();
  294. activateClass.SetUpICardEffect("1 Digimon gets -5000DP, then delete 1 with 5000DP or less", CanUseCondition, card);
  295. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  296. cardEffects.Add(activateClass);
  297. string EffectDiscription()
  298. {
  299. 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.";
  300. }
  301. bool IsDigimonWithCorrectDP(Permanent permanent)
  302. {
  303. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  304. {
  305. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(5000, activateClass))
  306. {
  307. return true;
  308. }
  309. }
  310. return false;
  311. }
  312. bool CanSelectPermanentCondition(Permanent permanent)
  313. {
  314. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  315. }
  316. bool CanUseCondition(Hashtable hashtable)
  317. {
  318. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  319. }
  320. bool CanActivateCondition(Hashtable hashtable)
  321. {
  322. return CardEffectCommons.IsExistOnBattleArea(card) &&
  323. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  324. }
  325. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  326. {
  327. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  328. {
  329. Permanent selectedPermanent = null;
  330. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  331. selectPermanentEffect.SetUp(
  332. selectPlayer: card.Owner,
  333. canTargetCondition: CanSelectPermanentCondition,
  334. canTargetCondition_ByPreSelecetedList: null,
  335. canEndSelectCondition: null,
  336. maxCount: 1,
  337. canNoSelect: false,
  338. canEndNotMax: false,
  339. selectPermanentCoroutine: SelectTargetCoroutine,
  340. afterSelectPermanentCoroutine: null,
  341. mode: SelectPermanentEffect.Mode.Custom,
  342. cardEffect: activateClass);
  343. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  344. IEnumerator SelectTargetCoroutine(Permanent permanent)
  345. {
  346. selectedPermanent = permanent;
  347. yield return null;
  348. }
  349. if(selectedPermanent != null)
  350. {
  351. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  352. targetPermanent: selectedPermanent,
  353. changeValue: -5000,
  354. effectDuration: EffectDuration.UntilEachTurnEnd,
  355. activateClass: activateClass));
  356. }
  357. }
  358. if (CardEffectCommons.HasMatchConditionPermanent(IsDigimonWithCorrectDP))
  359. {
  360. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  361. selectPermanentEffect.SetUp(
  362. selectPlayer: card.Owner,
  363. canTargetCondition: IsDigimonWithCorrectDP,
  364. canTargetCondition_ByPreSelecetedList: null,
  365. canEndSelectCondition: null,
  366. maxCount: 1,
  367. canNoSelect: false,
  368. canEndNotMax: false,
  369. selectPermanentCoroutine: null,
  370. afterSelectPermanentCoroutine: null,
  371. mode: SelectPermanentEffect.Mode.Destroy,
  372. cardEffect: activateClass);
  373. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  374. }
  375. }
  376. }
  377. #endregion
  378. #region On Deletion
  379. if (timing == EffectTiming.OnDestroyedAnyone)
  380. {
  381. ActivateClass activateClass = new ActivateClass();
  382. activateClass.SetUpICardEffect("1 Digimon gets -5000DP, then delete 1 with 5000DP or less", CanUseCondition, card);
  383. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  384. cardEffects.Add(activateClass);
  385. string EffectDiscription()
  386. {
  387. 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.";
  388. }
  389. bool IsDigimonWithCorrectDP(Permanent permanent)
  390. {
  391. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  392. {
  393. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(5000, activateClass))
  394. {
  395. return true;
  396. }
  397. }
  398. return false;
  399. }
  400. bool CanSelectPermanentCondition(Permanent permanent)
  401. {
  402. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  403. }
  404. bool CanUseCondition(Hashtable hashtable)
  405. {
  406. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  407. }
  408. bool CanActivateCondition(Hashtable hashtable)
  409. {
  410. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  411. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  412. }
  413. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  414. {
  415. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  416. {
  417. Permanent selectedPermanent = null;
  418. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  419. selectPermanentEffect.SetUp(
  420. selectPlayer: card.Owner,
  421. canTargetCondition: CanSelectPermanentCondition,
  422. canTargetCondition_ByPreSelecetedList: null,
  423. canEndSelectCondition: null,
  424. maxCount: 1,
  425. canNoSelect: false,
  426. canEndNotMax: false,
  427. selectPermanentCoroutine: SelectTargetCoroutine,
  428. afterSelectPermanentCoroutine: null,
  429. mode: SelectPermanentEffect.Mode.Custom,
  430. cardEffect: activateClass);
  431. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  432. IEnumerator SelectTargetCoroutine(Permanent permanent)
  433. {
  434. selectedPermanent = permanent;
  435. yield return null;
  436. }
  437. if (selectedPermanent != null)
  438. {
  439. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  440. targetPermanent: selectedPermanent,
  441. changeValue: -5000,
  442. effectDuration: EffectDuration.UntilEachTurnEnd,
  443. activateClass: activateClass));
  444. }
  445. }
  446. if (CardEffectCommons.HasMatchConditionPermanent(IsDigimonWithCorrectDP))
  447. {
  448. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  449. selectPermanentEffect.SetUp(
  450. selectPlayer: card.Owner,
  451. canTargetCondition: IsDigimonWithCorrectDP,
  452. canTargetCondition_ByPreSelecetedList: null,
  453. canEndSelectCondition: null,
  454. maxCount: 1,
  455. canNoSelect: false,
  456. canEndNotMax: false,
  457. selectPermanentCoroutine: null,
  458. afterSelectPermanentCoroutine: null,
  459. mode: SelectPermanentEffect.Mode.Destroy,
  460. cardEffect: activateClass);
  461. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  462. }
  463. }
  464. }
  465. #endregion
  466. return cardEffects;
  467. }
  468. }
  469. }