BT16_065.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. namespace DCGO.CardEffects.BT16
  8. {
  9. public class BT16_065 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. bool HasBossTraitInPlay(Permanent permanent)
  15. {
  16. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  17. {
  18. if (permanent.IsDigimon)
  19. {
  20. if (permanent.TopCard.CardTraits.Contains("Boss"))
  21. {
  22. return true;
  23. }
  24. }
  25. }
  26. return false;
  27. }
  28. bool CanSelectDBrigadeCondition(CardSource cardSource)
  29. {
  30. return cardSource.CardTraits.Contains("D-Brigade");
  31. }
  32. #region Before Pay Cost - Condition Effect
  33. if (timing == EffectTiming.BeforePayCost)
  34. {
  35. ActivateClass activateClass = new ActivateClass();
  36. activateClass.SetUpICardEffect("Return 6 [D-Brigade] to get Play Cost -6", CanUseCondition, card);
  37. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  38. activateClass.SetHashString("PlayCost-12_BT16_065");
  39. cardEffects.Add(activateClass);
  40. string EffectDiscription()
  41. {
  42. return "When this card would be played, if there is a Digimon with the [Boss] trait, reduce the play cost by 6. By returning 6 cards with the [D-Brigade] trait from your trash to the top of the deck, reduce the play cost by 6.";
  43. }
  44. bool CardCondition(CardSource cardSource)
  45. {
  46. if (cardSource == card)
  47. {
  48. if (CardEffectCommons.IsExistOnHand(cardSource))
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. bool CanNoSelect(CardSource cardSource)
  56. {
  57. if (cardSource != null)
  58. {
  59. if (cardSource.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) > cardSource.Owner.MaxMemoryCost)
  60. {
  61. return false;
  62. }
  63. }
  64. return true;
  65. }
  66. bool CanUseCondition(Hashtable hashtable)
  67. {
  68. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  69. }
  70. bool CanActivateCondition(Hashtable hashtable)
  71. {
  72. if (CardEffectCommons.IsExistOnHand(card))
  73. {
  74. if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectDBrigadeCondition) >= 6)
  75. {
  76. return true;
  77. }
  78. if (CardEffectCommons.HasMatchConditionPermanent(HasBossTraitInPlay))
  79. {
  80. return true;
  81. }
  82. }
  83. return false;
  84. }
  85. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  86. {
  87. List<CardSource> selectedCards = new List<CardSource>();
  88. if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectDBrigadeCondition) >= 6)
  89. {
  90. bool noSelect = CanNoSelect(CardEffectCommons.GetCardFromHashtable(_hashtable));
  91. int maxCount = 6;
  92. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  93. selectCardEffect.SetUp(
  94. canTargetCondition: CanSelectDBrigadeCondition,
  95. canTargetCondition_ByPreSelecetedList: null,
  96. canEndSelectCondition: null,
  97. canNoSelect: () => noSelect,
  98. selectCardCoroutine: SelectCardCoroutine,
  99. afterSelectCardCoroutine: null,
  100. message: "Select cards to add to the top your deck\n(cards will be placed back to the top of the deck so that cards with lower numbers are on top).",
  101. maxCount: maxCount,
  102. canEndNotMax: false,
  103. isShowOpponent: true,
  104. mode: SelectCardEffect.Mode.Custom,
  105. root: SelectCardEffect.Root.Trash,
  106. customRootCardList: null,
  107. canLookReverseCard: true,
  108. selectPlayer: card.Owner,
  109. cardEffect: activateClass);
  110. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  111. IEnumerator SelectCardCoroutine(CardSource cardSource)
  112. {
  113. selectedCards.Add(cardSource);
  114. yield return null;
  115. }
  116. if (selectedCards.Count == 6)
  117. {
  118. selectedCards.Reverse();
  119. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryTopCards(selectedCards));
  120. }
  121. }
  122. if (card.Owner.CanReduceCost(null, card))
  123. {
  124. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  125. }
  126. ChangeCostClass changeCostClass = new ChangeCostClass();
  127. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition1, card);
  128. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  129. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  130. bool CanUseCondition1(Hashtable hashtable)
  131. {
  132. return true;
  133. }
  134. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  135. {
  136. if (CardSourceCondition(cardSource))
  137. {
  138. if (RootCondition(root))
  139. {
  140. if (PermanentsCondition(targetPermanents))
  141. {
  142. int targetCost = 0;
  143. if (CardEffectCommons.HasMatchConditionPermanent(HasBossTraitInPlay))
  144. targetCost += 6;
  145. if (selectedCards.Count >= 6)
  146. targetCost += 6;
  147. Cost -= targetCost;
  148. }
  149. }
  150. }
  151. return Cost;
  152. }
  153. bool PermanentsCondition(List<Permanent> targetPermanents)
  154. {
  155. if (targetPermanents == null)
  156. {
  157. return true;
  158. }
  159. else
  160. {
  161. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  162. {
  163. return true;
  164. }
  165. }
  166. return false;
  167. }
  168. bool CardSourceCondition(CardSource cardSource)
  169. {
  170. return cardSource == card;
  171. }
  172. bool RootCondition(SelectCardEffect.Root root)
  173. {
  174. return true;
  175. }
  176. bool isUpDown()
  177. {
  178. return true;
  179. }
  180. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  181. }
  182. }
  183. #endregion
  184. #region Reduce Play Cost - Not Shown
  185. if (timing == EffectTiming.None)
  186. {
  187. ChangeCostClass changeCostClass = new ChangeCostClass();
  188. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition, card);
  189. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  190. changeCostClass.SetNotShowUI(true);
  191. cardEffects.Add(changeCostClass);
  192. bool CanUseCondition(Hashtable hashtable)
  193. {
  194. if (card.Owner.HandCards.Contains(card))
  195. {
  196. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Return 6 [D-Brigade] to get Play Cost -6");
  197. if (activateClass != null)
  198. {
  199. if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectDBrigadeCondition) >= 6)
  200. {
  201. return true;
  202. }
  203. if (CardEffectCommons.HasMatchConditionPermanent(HasBossTraitInPlay))
  204. {
  205. return true;
  206. }
  207. }
  208. }
  209. return false;
  210. }
  211. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  212. {
  213. if (CardSourceCondition(cardSource))
  214. {
  215. if (RootCondition(root))
  216. {
  217. if (PermanentsCondition(targetPermanents))
  218. {
  219. int trashCount = CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectDBrigadeCondition);
  220. int targetCount = 0;
  221. if (trashCount >= 6)
  222. targetCount += 6;
  223. if (CardEffectCommons.HasMatchConditionPermanent(HasBossTraitInPlay))
  224. targetCount += 6;
  225. Cost -= targetCount;
  226. }
  227. }
  228. }
  229. return Cost;
  230. }
  231. bool PermanentsCondition(List<Permanent> targetPermanents)
  232. {
  233. if (targetPermanents == null)
  234. {
  235. return true;
  236. }
  237. else
  238. {
  239. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  240. {
  241. return true;
  242. }
  243. }
  244. return false;
  245. }
  246. bool CardSourceCondition(CardSource cardSource)
  247. {
  248. if (cardSource != null)
  249. {
  250. if (cardSource == card)
  251. {
  252. return true;
  253. }
  254. }
  255. return false;
  256. }
  257. bool RootCondition(SelectCardEffect.Root root)
  258. {
  259. return true;
  260. }
  261. bool isUpDown()
  262. {
  263. return true;
  264. }
  265. }
  266. #endregion
  267. #region On Play
  268. if (timing == EffectTiming.OnEnterFieldAnyone)
  269. {
  270. ActivateClass activateClass = new ActivateClass();
  271. activateClass.SetUpICardEffect("Reveal top 3, then delete 1 digimon.", CanUseCondition, card);
  272. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  273. cardEffects.Add(activateClass);
  274. string EffectDiscription()
  275. {
  276. return "[On Play] Reveal the top 3 cards of your deck. Delete 1 of your opponent's Digimon with play cost less than or equal to the play cost of 1 of the cards among them. Trash the revealed cards.";
  277. }
  278. bool RevealSelectCardCondition(CardSource cardSource)
  279. {
  280. if (cardSource.IsDigimon)
  281. {
  282. if (cardSource.HasPlayCost)
  283. {
  284. return true;
  285. }
  286. }
  287. return false;
  288. }
  289. bool CanUseCondition(Hashtable hashtable)
  290. {
  291. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  292. }
  293. bool CanActivateCondition(Hashtable hashtable)
  294. {
  295. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  296. {
  297. if (card.Owner.LibraryCards.Count >= 1)
  298. {
  299. return true;
  300. }
  301. }
  302. return false;
  303. }
  304. IEnumerator ActivateCoroutine(Hashtable hashtable)
  305. {
  306. int costDeletion = 0;
  307. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  308. revealCount: 3,
  309. simplifiedSelectCardConditions:
  310. new SimplifiedSelectCardConditionClass[]
  311. {
  312. new SimplifiedSelectCardConditionClass(
  313. canTargetCondition:RevealSelectCardCondition,
  314. message: "Select Play cost to use",
  315. mode: SelectCardEffect.Mode.Custom,
  316. maxCount: 1,
  317. selectCardCoroutine: SelectCardCoroutine)
  318. },
  319. remainingCardsPlace: RemainingCardsPlace.Trash,
  320. activateClass: activateClass,
  321. isSendAllCardsToSamePlace: true
  322. ));
  323. IEnumerator SelectCardCoroutine(CardSource cardSource)
  324. {
  325. costDeletion = cardSource.GetCostItself;
  326. yield return null;
  327. }
  328. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  329. {
  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: null,
  340. afterSelectPermanentCoroutine: null,
  341. mode: SelectPermanentEffect.Mode.Destroy,
  342. cardEffect: activateClass);
  343. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  344. }
  345. bool CanSelectPermanentCondition(Permanent permanent)
  346. {
  347. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  348. {
  349. if (permanent.TopCard.HasPlayCost)
  350. {
  351. if (permanent.TopCard.GetCostItself <= costDeletion)
  352. {
  353. return true;
  354. }
  355. }
  356. }
  357. return false;
  358. }
  359. yield return null;
  360. }
  361. }
  362. #endregion
  363. #region When Digivolving
  364. if (timing == EffectTiming.OnEnterFieldAnyone)
  365. {
  366. ActivateClass activateClass = new ActivateClass();
  367. activateClass.SetUpICardEffect("Reveal top 3, then delete 1 digimon.", CanUseCondition, card);
  368. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  369. cardEffects.Add(activateClass);
  370. string EffectDiscription()
  371. {
  372. return "[When Digivolving] Reveal the top 3 cards of your deck. Delete 1 of your opponent's Digimon with play cost less than or equal to the play cost of 1 of the cards among them. Trash the revealed cards.";
  373. }
  374. bool RevealSelectCardCondition(CardSource cardSource)
  375. {
  376. if (cardSource.IsDigimon)
  377. {
  378. if (cardSource.HasPlayCost)
  379. {
  380. return true;
  381. }
  382. }
  383. return false;
  384. }
  385. bool CanUseCondition(Hashtable hashtable)
  386. {
  387. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  388. }
  389. bool CanActivateCondition(Hashtable hashtable)
  390. {
  391. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  392. {
  393. if (card.Owner.LibraryCards.Count >= 1)
  394. {
  395. return true;
  396. }
  397. }
  398. return false;
  399. }
  400. IEnumerator ActivateCoroutine(Hashtable hashtable)
  401. {
  402. int costDeletion = 0;
  403. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  404. revealCount: 3,
  405. simplifiedSelectCardConditions:
  406. new SimplifiedSelectCardConditionClass[]
  407. {
  408. new SimplifiedSelectCardConditionClass(
  409. canTargetCondition:RevealSelectCardCondition,
  410. message: "Select Play cost to use",
  411. mode: SelectCardEffect.Mode.Custom,
  412. maxCount: 1,
  413. selectCardCoroutine: SelectCardCoroutine)
  414. },
  415. remainingCardsPlace: RemainingCardsPlace.Trash,
  416. activateClass: activateClass,
  417. isSendAllCardsToSamePlace: true
  418. ));
  419. IEnumerator SelectCardCoroutine(CardSource cardSource)
  420. {
  421. costDeletion = cardSource.GetCostItself;
  422. yield return null;
  423. }
  424. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  425. {
  426. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  427. selectPermanentEffect.SetUp(
  428. selectPlayer: card.Owner,
  429. canTargetCondition: CanSelectPermanentCondition,
  430. canTargetCondition_ByPreSelecetedList: null,
  431. canEndSelectCondition: null,
  432. maxCount: 1,
  433. canNoSelect: false,
  434. canEndNotMax: false,
  435. selectPermanentCoroutine: null,
  436. afterSelectPermanentCoroutine: null,
  437. mode: SelectPermanentEffect.Mode.Destroy,
  438. cardEffect: activateClass);
  439. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  440. }
  441. bool CanSelectPermanentCondition(Permanent permanent)
  442. {
  443. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  444. {
  445. if (permanent.TopCard.HasPlayCost)
  446. {
  447. if (permanent.TopCard.GetCostItself <= costDeletion)
  448. {
  449. return true;
  450. }
  451. }
  452. }
  453. return false;
  454. }
  455. yield return null;
  456. }
  457. }
  458. #endregion
  459. #region End of Turn
  460. if (timing == EffectTiming.OnEndTurn)
  461. {
  462. ActivateClass activateClass = new ActivateClass();
  463. activateClass.SetUpICardEffect("DNA digivolve into [Chaosmon]", CanUseCondition, card);
  464. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  465. cardEffects.Add(activateClass);
  466. string EffectDiscription()
  467. {
  468. return "[End of Your Turn] 2 of your Digimon may DNA digivolve into a [Chaosmon] in your hand.";
  469. }
  470. bool CanSelectDNACardCondition(CardSource cardSource)
  471. {
  472. if (cardSource.IsDigimon)
  473. {
  474. if (cardSource.CanPlayJogress(true))
  475. {
  476. if (cardSource.CardNames.Contains("Chaosmon"))
  477. {
  478. return true;
  479. }
  480. }
  481. }
  482. return false;
  483. }
  484. bool CanUseCondition(Hashtable hashtable)
  485. {
  486. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  487. }
  488. bool CanActivateCondition(Hashtable hashtable)
  489. {
  490. if (!CardEffectCommons.IsOwnerTurn(card))
  491. return false;
  492. if (card.Owner.GetBattleAreaDigimons().Count < 2)
  493. return false;
  494. if (card.Owner.HandCards.Count(CanSelectDNACardCondition) < 1)
  495. return false;
  496. return true;
  497. }
  498. IEnumerator ActivateCoroutine(Hashtable hashtable)
  499. {
  500. yield return ContinuousController.instance.StartCoroutine(
  501. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  502. CanSelectDNACardCondition,
  503. payCost: true,
  504. isHand: true,
  505. activateClass
  506. ));
  507. }
  508. }
  509. #endregion
  510. return cardEffects;
  511. }
  512. }
  513. }