GizimonXT_BT13_086.cs 20 KB

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