BT13_086.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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_086 : 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 level 4 Digimon to get Play Cost -6", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. activateClass.SetHashString("PlayCost-6_BT13_086");
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "When you would play this card, by deleting 1 of your level 4 Digimon, reduce the play cost by 6.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.Level == 4)
  28. {
  29. if (permanent.TopCard.HasLevel)
  30. {
  31. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  32. {
  33. if (permanent.CanBeDestroyedBySkill(activateClass))
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, cardSource => cardSource == card))
  46. {
  47. return true;
  48. }
  49. return false;
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  54. {
  55. return true;
  56. }
  57. return false;
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  60. {
  61. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  62. {
  63. bool CanNoSelect =
  64. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable) != null &&
  65. card.PayingCost(
  66. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable).Root,
  67. null,
  68. checkAvailability: false)
  69. <= card.Owner.MaxMemoryCost;
  70. int maxCount = 1;
  71. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  72. selectPermanentEffect.SetUp(
  73. selectPlayer: card.Owner,
  74. canTargetCondition: CanSelectPermanentCondition,
  75. canTargetCondition_ByPreSelecetedList: null,
  76. canEndSelectCondition: null,
  77. maxCount: maxCount,
  78. canNoSelect: CanNoSelect,
  79. canEndNotMax: false,
  80. selectPermanentCoroutine: SelectPermanentCoroutine,
  81. afterSelectPermanentCoroutine: null,
  82. mode: SelectPermanentEffect.Mode.Custom,
  83. cardEffect: activateClass);
  84. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  85. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  86. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  87. {
  88. yield return ContinuousController.instance.StartCoroutine(
  89. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  90. targetPermanents: new List<Permanent>() { permanent },
  91. activateClass: activateClass,
  92. successProcess: permanents => SuccessProcess(),
  93. failureProcess: null));
  94. IEnumerator SuccessProcess()
  95. {
  96. if (card.Owner.CanReduceCost(null, card))
  97. {
  98. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  99. }
  100. ChangeCostClass changeCostClass = new ChangeCostClass();
  101. changeCostClass.SetUpICardEffect("Play Cost -6", CanUseCondition1, card);
  102. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  103. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  104. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  105. bool CanUseCondition1(Hashtable hashtable)
  106. {
  107. return true;
  108. }
  109. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  110. {
  111. if (CardSourceCondition(cardSource))
  112. {
  113. if (RootCondition(root))
  114. {
  115. if (PermanentsCondition(targetPermanents))
  116. {
  117. Cost -= 6;
  118. }
  119. }
  120. }
  121. return Cost;
  122. }
  123. bool PermanentsCondition(List<Permanent> targetPermanents)
  124. {
  125. if (targetPermanents == null)
  126. {
  127. return true;
  128. }
  129. else
  130. {
  131. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  132. {
  133. return true;
  134. }
  135. }
  136. return false;
  137. }
  138. bool CardSourceCondition(CardSource cardSource)
  139. {
  140. if (cardSource != null)
  141. {
  142. if (cardSource == card)
  143. {
  144. return true;
  145. }
  146. }
  147. return false;
  148. }
  149. bool RootCondition(SelectCardEffect.Root root)
  150. {
  151. return true;
  152. }
  153. bool isUpDown()
  154. {
  155. return true;
  156. }
  157. yield return null;
  158. }
  159. }
  160. }
  161. }
  162. }
  163. if (timing == EffectTiming.None)
  164. {
  165. ChangeCostClass changeCostClass = new ChangeCostClass();
  166. changeCostClass.SetUpICardEffect("Play Cost -6", CanUseCondition, card);
  167. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  168. changeCostClass.SetNotShowUI(true);
  169. cardEffects.Add(changeCostClass);
  170. bool CanSelectPermanentCondition(Permanent permanent, ICardEffect activateClass)
  171. {
  172. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  173. {
  174. if (permanent.Level == 4)
  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. return false;
  189. }
  190. bool CanUseCondition(Hashtable hashtable)
  191. {
  192. if (card.PermanentOfThisCard() == null)
  193. {
  194. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Delete your 1 level 4 Digimon to get Play Cost -6");
  195. if (activateClass != null)
  196. {
  197. if (CardEffectCommons.HasMatchConditionPermanent(
  198. (permanent) => CanSelectPermanentCondition(permanent, activateClass)))
  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 -= 6;
  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.None)
  256. {
  257. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  258. }
  259. if (timing == EffectTiming.OnEnterFieldAnyone)
  260. {
  261. ActivateClass activateClass = new ActivateClass();
  262. activateClass.SetUpICardEffect("Play 1 [Akihiro Kurata] from trash", CanUseCondition, card);
  263. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  264. cardEffects.Add(activateClass);
  265. string EffectDiscription()
  266. {
  267. return "[On Play] Play 1 [Akihiro Kurata] from your trash without paying the cost.";
  268. }
  269. bool CanSelectCardCondition(CardSource cardSource)
  270. {
  271. if (cardSource.CardNames.Contains("Akihiro Kurata") || cardSource.CardNames.Contains("AkihiroKurata"))
  272. {
  273. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  274. {
  275. return true;
  276. }
  277. }
  278. return false;
  279. }
  280. bool CanUseCondition(Hashtable hashtable)
  281. {
  282. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  283. }
  284. bool CanActivateCondition(Hashtable hashtable)
  285. {
  286. if (CardEffectCommons.IsExistOnBattleArea(card))
  287. {
  288. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  289. {
  290. return true;
  291. }
  292. }
  293. return false;
  294. }
  295. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  296. {
  297. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  298. {
  299. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  300. List<CardSource> selectedCards = new List<CardSource>();
  301. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  302. selectCardEffect.SetUp(
  303. canTargetCondition: CanSelectCardCondition,
  304. canTargetCondition_ByPreSelecetedList: null,
  305. canEndSelectCondition: null,
  306. canNoSelect: () => false,
  307. selectCardCoroutine: SelectCardCoroutine,
  308. afterSelectCardCoroutine: null,
  309. message: "Select 1 card to play.",
  310. maxCount: maxCount,
  311. canEndNotMax: false,
  312. isShowOpponent: true,
  313. mode: SelectCardEffect.Mode.Custom,
  314. root: SelectCardEffect.Root.Trash,
  315. customRootCardList: null,
  316. canLookReverseCard: true,
  317. selectPlayer: card.Owner,
  318. cardEffect: activateClass);
  319. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  320. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  321. yield return StartCoroutine(selectCardEffect.Activate());
  322. IEnumerator SelectCardCoroutine(CardSource cardSource)
  323. {
  324. selectedCards.Add(cardSource);
  325. yield return null;
  326. }
  327. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  328. }
  329. }
  330. }
  331. if (timing == EffectTiming.None)
  332. {
  333. bool Condition()
  334. {
  335. if (CardEffectCommons.IsExistOnBattleArea(card))
  336. {
  337. return true;
  338. }
  339. return false;
  340. }
  341. cardEffects.Add(CardEffectFactory.CanNotDigivolveStaticSelfEffect(
  342. cardCondition: null,
  343. isInheritedEffect: false,
  344. card: card,
  345. condition: Condition,
  346. effectName: "Can't digivolve")
  347. );
  348. }
  349. if (timing == EffectTiming.OnDestroyedAnyone)
  350. {
  351. ActivateClass activateClass = new ActivateClass();
  352. activateClass.SetUpICardEffect("Play 1 [ProtoGizmon] from trash", CanUseCondition, card);
  353. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  354. cardEffects.Add(activateClass);
  355. string EffectDiscription()
  356. {
  357. return "[On Deletion] You may play 1 [ProtoGizmon] from your trash without paying the cost.";
  358. }
  359. bool CanSelectCardCondition(CardSource cardSource)
  360. {
  361. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  362. {
  363. if (cardSource.CardNames.Contains("ProtoGizmon"))
  364. {
  365. return true;
  366. }
  367. }
  368. return false;
  369. }
  370. bool CanUseCondition(Hashtable hashtable)
  371. {
  372. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  373. }
  374. bool CanActivateCondition(Hashtable hashtable)
  375. {
  376. if (CardEffectCommons.IsExistOnTrash(card))
  377. {
  378. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  379. {
  380. return true;
  381. }
  382. }
  383. return false;
  384. }
  385. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  386. {
  387. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  388. {
  389. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  390. List<CardSource> selectedCards = new List<CardSource>();
  391. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  392. selectCardEffect.SetUp(
  393. canTargetCondition: CanSelectCardCondition,
  394. canTargetCondition_ByPreSelecetedList: null,
  395. canEndSelectCondition: null,
  396. canNoSelect: () => true,
  397. selectCardCoroutine: SelectCardCoroutine,
  398. afterSelectCardCoroutine: null,
  399. message: "Select 1 card to play.",
  400. maxCount: maxCount,
  401. canEndNotMax: false,
  402. isShowOpponent: true,
  403. mode: SelectCardEffect.Mode.Custom,
  404. root: SelectCardEffect.Root.Trash,
  405. customRootCardList: null,
  406. canLookReverseCard: true,
  407. selectPlayer: card.Owner,
  408. cardEffect: activateClass);
  409. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  410. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  411. yield return StartCoroutine(selectCardEffect.Activate());
  412. IEnumerator SelectCardCoroutine(CardSource cardSource)
  413. {
  414. selectedCards.Add(cardSource);
  415. yield return null;
  416. }
  417. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  418. }
  419. }
  420. }
  421. return cardEffects;
  422. }
  423. }
  424. }