BT13_080.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_080 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.BeforePayCost)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Delete your 1 Digimon in breeding area to get Play Cost -2", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. activateClass.SetHashString("PlayCost-2_BT13_080");
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "When you would play this card, by deleting 1 of your level 2 Digimon in the breeding area, reduce the play cost by 2.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card))
  26. {
  27. if (permanent.IsDigimon)
  28. {
  29. if (permanent.Level == 2)
  30. {
  31. if (permanent.TopCard.HasLevel)
  32. {
  33. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  34. {
  35. if (permanent.CanBeDestroyedBySkill(activateClass))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, cardSource => cardSource == card))
  49. {
  50. return true;
  51. }
  52. return false;
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (card.Owner.GetBreedingAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  57. {
  58. return true;
  59. }
  60. return false;
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  63. {
  64. if (card.Owner.GetBreedingAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  65. {
  66. bool CanNoSelect =
  67. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable) != null &&
  68. card.PayingCost(
  69. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable).Root,
  70. null,
  71. checkAvailability: false)
  72. <= card.Owner.MaxMemoryCost;
  73. int maxCount = 1;
  74. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  75. selectPermanentEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectPermanentCondition,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: maxCount,
  81. canNoSelect: CanNoSelect,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: SelectPermanentCoroutine,
  84. afterSelectPermanentCoroutine: null,
  85. mode: SelectPermanentEffect.Mode.Custom,
  86. cardEffect: activateClass);
  87. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  88. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  89. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  92. IEnumerator SuccessProcess()
  93. {
  94. if (card.Owner.CanReduceCost(null, card))
  95. {
  96. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  97. }
  98. ChangeCostClass changeCostClass = new ChangeCostClass();
  99. changeCostClass.SetUpICardEffect("Play Cost -2", CanUseCondition1, card);
  100. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  101. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  102. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  103. bool CanUseCondition1(Hashtable hashtable)
  104. {
  105. return true;
  106. }
  107. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  108. {
  109. if (CardSourceCondition(cardSource))
  110. {
  111. if (RootCondition(root))
  112. {
  113. if (PermanentsCondition(targetPermanents))
  114. {
  115. Cost -= 2;
  116. }
  117. }
  118. }
  119. return Cost;
  120. }
  121. bool PermanentsCondition(List<Permanent> targetPermanents)
  122. {
  123. if (targetPermanents == null)
  124. {
  125. return true;
  126. }
  127. else
  128. {
  129. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  130. {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. bool CardSourceCondition(CardSource cardSource)
  137. {
  138. if (cardSource != null)
  139. {
  140. if (cardSource == card)
  141. {
  142. return true;
  143. }
  144. }
  145. return false;
  146. }
  147. bool RootCondition(SelectCardEffect.Root root)
  148. {
  149. return true;
  150. }
  151. bool isUpDown()
  152. {
  153. return true;
  154. }
  155. yield return null;
  156. }
  157. }
  158. }
  159. }
  160. }
  161. if (timing == EffectTiming.None)
  162. {
  163. ChangeCostClass changeCostClass = new ChangeCostClass();
  164. changeCostClass.SetUpICardEffect("Play Cost -2", CanUseCondition, card);
  165. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  166. changeCostClass.SetNotShowUI(true);
  167. cardEffects.Add(changeCostClass);
  168. bool CanSelectPermanentCondition(Permanent permanent, ICardEffect activateClass)
  169. {
  170. if (CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card))
  171. {
  172. if (permanent.IsDigimon)
  173. {
  174. if (permanent.Level == 2)
  175. {
  176. if (permanent.TopCard.HasLevel)
  177. {
  178. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  179. {
  180. if (permanent.CanBeDestroyedBySkill(activateClass))
  181. {
  182. return true;
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. return false;
  190. }
  191. bool CanUseCondition(Hashtable hashtable)
  192. {
  193. if (card.PermanentOfThisCard() == null)
  194. {
  195. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Delete your 1 Digimon in breeding area to get Play Cost -2");
  196. if (activateClass != null)
  197. {
  198. if (card.Owner.GetBreedingAreaPermanents().Count((permanent) => CanSelectPermanentCondition(permanent, activateClass)) >= 1)
  199. {
  200. return true;
  201. }
  202. }
  203. }
  204. return false;
  205. }
  206. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  207. {
  208. if (CardSourceCondition(cardSource))
  209. {
  210. if (RootCondition(root))
  211. {
  212. if (PermanentsCondition(targetPermanents))
  213. {
  214. Cost -= 2;
  215. }
  216. }
  217. }
  218. return Cost;
  219. }
  220. bool PermanentsCondition(List<Permanent> targetPermanents)
  221. {
  222. if (targetPermanents == null)
  223. {
  224. return true;
  225. }
  226. else
  227. {
  228. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  229. {
  230. return true;
  231. }
  232. }
  233. return false;
  234. }
  235. bool CardSourceCondition(CardSource cardSource)
  236. {
  237. if (cardSource != null)
  238. {
  239. if (cardSource == card)
  240. {
  241. return true;
  242. }
  243. }
  244. return false;
  245. }
  246. bool RootCondition(SelectCardEffect.Root root)
  247. {
  248. return true;
  249. }
  250. bool isUpDown()
  251. {
  252. return true;
  253. }
  254. }
  255. if (timing == EffectTiming.OnEnterFieldAnyone)
  256. {
  257. ActivateClass activateClass = new ActivateClass();
  258. activateClass.SetUpICardEffect("Draw 1 and trash 1 card from hand", CanUseCondition, card);
  259. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  260. cardEffects.Add(activateClass);
  261. string EffectDiscription()
  262. {
  263. return "[On Play] <Draw 1>. Then, trash 1 card in your hand.";
  264. }
  265. bool CanUseCondition(Hashtable hashtable)
  266. {
  267. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  268. }
  269. bool CanActivateCondition(Hashtable hashtable)
  270. {
  271. if (CardEffectCommons.IsExistOnBattleArea(card))
  272. {
  273. if (card.Owner.LibraryCards.Count >= 1)
  274. {
  275. return true;
  276. }
  277. if (card.Owner.HandCards.Count >= 1)
  278. {
  279. return true;
  280. }
  281. }
  282. return false;
  283. }
  284. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  285. {
  286. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  287. if (card.Owner.HandCards.Count >= 1)
  288. {
  289. int discardCount = 1;
  290. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  291. selectHandEffect.SetUp(
  292. selectPlayer: card.Owner,
  293. canTargetCondition: (cardSource) => true,
  294. canTargetCondition_ByPreSelecetedList: null,
  295. canEndSelectCondition: null,
  296. maxCount: discardCount,
  297. canNoSelect: false,
  298. canEndNotMax: false,
  299. isShowOpponent: true,
  300. selectCardCoroutine: null,
  301. afterSelectCardCoroutine: null,
  302. mode: SelectHandEffect.Mode.Discard,
  303. cardEffect: activateClass);
  304. yield return StartCoroutine(selectHandEffect.Activate());
  305. }
  306. }
  307. }
  308. if (timing == EffectTiming.None)
  309. {
  310. bool Condition()
  311. {
  312. if (CardEffectCommons.IsExistOnBattleArea(card))
  313. {
  314. return true;
  315. }
  316. return false;
  317. }
  318. cardEffects.Add(CardEffectFactory.CanNotDigivolveStaticSelfEffect(
  319. cardCondition: null,
  320. isInheritedEffect: false,
  321. card: card,
  322. condition: Condition,
  323. effectName: "Can't digivolve")
  324. );
  325. }
  326. if (timing == EffectTiming.OnDestroyedAnyone)
  327. {
  328. ActivateClass activateClass = new ActivateClass();
  329. activateClass.SetUpICardEffect("Play 1 [Gizmon: AT] from trash", CanUseCondition, card);
  330. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  331. cardEffects.Add(activateClass);
  332. string EffectDiscription()
  333. {
  334. return "[On Deletion] By returning 2 cards with [Gizmon] in their names from your trash to the bottom of the deck in any order, you may play 1 [Gizmon: AT] from your trash without paying the cost.";
  335. }
  336. bool CanSelectCardCondition(CardSource cardSource)
  337. {
  338. return cardSource.ContainsCardName("Gizmon");
  339. }
  340. bool CanSelectCardCondition1(CardSource cardSource)
  341. {
  342. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass, root: SelectCardEffect.Root.Trash))
  343. {
  344. if (cardSource.CardNames.Contains("Gizmon: AT"))
  345. {
  346. return true;
  347. }
  348. if (cardSource.CardNames.Contains("Gizmon:AT"))
  349. {
  350. return true;
  351. }
  352. }
  353. return false;
  354. }
  355. bool CanUseCondition(Hashtable hashtable)
  356. {
  357. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  358. }
  359. bool CanActivateCondition(Hashtable hashtable)
  360. {
  361. if (CardEffectCommons.IsExistOnTrash(card))
  362. {
  363. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 2)
  364. {
  365. return true;
  366. }
  367. }
  368. return false;
  369. }
  370. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  371. {
  372. bool returned = false;
  373. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 2)
  374. {
  375. int maxCount = 2;
  376. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  377. selectCardEffect.SetUp(
  378. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  379. canTargetCondition_ByPreSelecetedList: null,
  380. canEndSelectCondition: null,
  381. canNoSelect: () => false,
  382. selectCardCoroutine: null,
  383. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  384. message: "Select cards to place at the bottom of the deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
  385. maxCount: maxCount,
  386. canEndNotMax: false,
  387. isShowOpponent: false,
  388. mode: SelectCardEffect.Mode.Custom,
  389. root: SelectCardEffect.Root.Trash,
  390. customRootCardList: null,
  391. canLookReverseCard: true,
  392. selectPlayer: card.Owner,
  393. cardEffect: activateClass);
  394. selectCardEffect.SetNotShowCard();
  395. selectCardEffect.SetNotAddLog();
  396. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  397. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  398. {
  399. if (cardSources.Count == 2)
  400. {
  401. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  402. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  403. returned = true;
  404. }
  405. }
  406. }
  407. if (returned)
  408. {
  409. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition1(cardSource)))
  410. {
  411. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition1(cardSource)));
  412. List<CardSource> selectedCards = new List<CardSource>();
  413. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  414. selectCardEffect.SetUp(
  415. canTargetCondition: CanSelectCardCondition1,
  416. canTargetCondition_ByPreSelecetedList: null,
  417. canEndSelectCondition: null,
  418. canNoSelect: () => true,
  419. selectCardCoroutine: SelectCardCoroutine,
  420. afterSelectCardCoroutine: null,
  421. message: "Select 1 card to play.",
  422. maxCount: maxCount,
  423. canEndNotMax: false,
  424. isShowOpponent: true,
  425. mode: SelectCardEffect.Mode.Custom,
  426. root: SelectCardEffect.Root.Trash,
  427. customRootCardList: null,
  428. canLookReverseCard: true,
  429. selectPlayer: card.Owner,
  430. cardEffect: activateClass);
  431. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  432. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  433. yield return StartCoroutine(selectCardEffect.Activate());
  434. IEnumerator SelectCardCoroutine(CardSource cardSource)
  435. {
  436. selectedCards.Add(cardSource);
  437. yield return null;
  438. }
  439. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  440. }
  441. }
  442. }
  443. }
  444. return cardEffects;
  445. }
  446. }
  447. }