P_171.cs 22 KB

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