P_171.cs 22 KB

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