BT14_046.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT14
  6. {
  7. public class BT14_046 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. ActivateClass activateClass1 = new ActivateClass();
  13. activateClass1.SetUpICardEffect("Play Cost -3", CanUseCondition1, card);
  14. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, 1, true, EffectDiscription1());
  15. activateClass1.SetHashString("Playcost-3_BT14_046");
  16. string EffectDiscription1()
  17. {
  18. return "[Your Turn][Once Per Turn] When you would play a green Tamer card from your hand, by suspending 1 of your green Digimon, reduce the play cost by 3.";
  19. }
  20. bool CardCondition(CardSource cardSource)
  21. {
  22. if (cardSource != null)
  23. {
  24. if (cardSource.IsTamer)
  25. {
  26. if (cardSource.HasCardColor(CardColor.Green))
  27. {
  28. if (cardSource.Owner.HandCards.Contains(cardSource))
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanSelectPermanentCondition1(Permanent permanent)
  38. {
  39. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  40. {
  41. if (permanent.TopCard.CardColors.Contains(CardColor.Green))
  42. {
  43. if (CardEffectCommons.CanActivateSuspendCostEffect(permanent.TopCard))
  44. {
  45. return true;
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanUseCondition1(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.IsExistOnBattleArea(card))
  54. {
  55. if (CardEffectCommons.IsOwnerTurn(card))
  56. {
  57. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  58. {
  59. return true;
  60. }
  61. }
  62. }
  63. return false;
  64. }
  65. bool CanActivateCondition1(Hashtable hashtable)
  66. {
  67. if (CardEffectCommons.IsExistOnBattleArea(card))
  68. {
  69. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  70. {
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine1(Hashtable _hashtable)
  77. {
  78. bool suspended = false;
  79. Permanent selectedPermanent = null;
  80. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  81. {
  82. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  83. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  84. selectPermanentEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: CanSelectPermanentCondition1,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: maxCount,
  90. canNoSelect: true,
  91. canEndNotMax: false,
  92. selectPermanentCoroutine: SelectPermanentCoroutine,
  93. afterSelectPermanentCoroutine: null,
  94. mode: SelectPermanentEffect.Mode.Custom,
  95. cardEffect: activateClass1);
  96. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  97. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  98. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  99. {
  100. selectedPermanent = permanent;
  101. yield return null;
  102. }
  103. }
  104. if (selectedPermanent != null)
  105. {
  106. if (selectedPermanent.TopCard != null)
  107. {
  108. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass1))
  109. {
  110. if (!selectedPermanent.IsSuspended && selectedPermanent.CanSuspend)
  111. {
  112. Permanent suspendTargetPermanent = selectedPermanent;
  113. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { suspendTargetPermanent }, CardEffectCommons.CardEffectHashtable(activateClass1)).Tap());
  114. if (suspendTargetPermanent.TopCard != null)
  115. {
  116. if (suspendTargetPermanent.IsSuspended)
  117. {
  118. suspended = true;
  119. }
  120. }
  121. }
  122. }
  123. }
  124. }
  125. if (suspended)
  126. {
  127. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  128. ChangeCostClass changeCostClass = new ChangeCostClass();
  129. changeCostClass.SetUpICardEffect("Play Cost -3", CanUseCondition3, card);
  130. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  131. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  132. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  133. bool CanUseCondition3(Hashtable hashtable)
  134. {
  135. return true;
  136. }
  137. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  138. {
  139. if (CardSourceCondition(cardSource))
  140. {
  141. if (RootCondition(root))
  142. {
  143. if (PermanentsCondition(targetPermanents))
  144. {
  145. Cost -= 3;
  146. }
  147. }
  148. }
  149. return Cost;
  150. }
  151. bool PermanentsCondition(List<Permanent> targetPermanents)
  152. {
  153. if (targetPermanents == null)
  154. {
  155. return true;
  156. }
  157. else
  158. {
  159. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  160. {
  161. return true;
  162. }
  163. }
  164. return false;
  165. }
  166. bool CardSourceCondition(CardSource cardSource)
  167. {
  168. return cardSource.HasCardColor(CardColor.Green) && cardSource.IsTamer;
  169. }
  170. bool RootCondition(SelectCardEffect.Root root)
  171. {
  172. return root == SelectCardEffect.Root.Hand;
  173. }
  174. bool isUpDown()
  175. {
  176. return true;
  177. }
  178. }
  179. }
  180. if (timing == EffectTiming.BeforePayCost)
  181. {
  182. cardEffects.Add(activateClass1);
  183. }
  184. if (timing == EffectTiming.None)
  185. {
  186. ChangeCostClass changeCostClass = new ChangeCostClass();
  187. changeCostClass.SetUpICardEffect("Play Cost -3", CanUseCondition, card);
  188. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  189. changeCostClass.SetNotShowUI(true);
  190. cardEffects.Add(changeCostClass);
  191. bool CanSelectPermanentCondition(Permanent permanent)
  192. {
  193. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  194. {
  195. if (permanent.TopCard.CardColors.Contains(CardColor.Green))
  196. {
  197. if (CardEffectCommons.CanActivateSuspendCostEffect(permanent.TopCard))
  198. {
  199. if (activateClass1 != null)
  200. {
  201. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass1, activateClass1.MaxCountPerTurn))
  202. {
  203. return true;
  204. }
  205. }
  206. }
  207. }
  208. }
  209. return false;
  210. }
  211. bool CanUseCondition(Hashtable hashtable)
  212. {
  213. if (!card.Owner.isYou && GManager.instance.IsAI)
  214. {
  215. return false;
  216. }
  217. if (CardEffectCommons.IsExistOnBattleArea(card))
  218. {
  219. if (CardEffectCommons.IsOwnerTurn(card))
  220. {
  221. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  222. {
  223. return true;
  224. }
  225. }
  226. }
  227. return false;
  228. }
  229. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  230. {
  231. if (CardSourceCondition(cardSource))
  232. {
  233. if (RootCondition(root))
  234. {
  235. if (PermanentsCondition(targetPermanents))
  236. {
  237. Cost -= 3;
  238. }
  239. }
  240. }
  241. return Cost;
  242. }
  243. bool PermanentsCondition(List<Permanent> targetPermanents)
  244. {
  245. if (targetPermanents == null)
  246. {
  247. return true;
  248. }
  249. else
  250. {
  251. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  252. {
  253. return true;
  254. }
  255. }
  256. return false;
  257. }
  258. bool CardSourceCondition(CardSource cardSource)
  259. {
  260. if (cardSource.Owner == card.Owner)
  261. {
  262. if (cardSource.IsTamer)
  263. {
  264. if (cardSource.HasCardColor(CardColor.Green))
  265. {
  266. if (cardSource.Owner.HandCards.Contains(cardSource))
  267. {
  268. return true;
  269. }
  270. }
  271. }
  272. }
  273. return false;
  274. }
  275. bool RootCondition(SelectCardEffect.Root root)
  276. {
  277. return root == SelectCardEffect.Root.Hand;
  278. }
  279. bool isUpDown()
  280. {
  281. return true;
  282. }
  283. }
  284. ActivateClass activateClass2 = new ActivateClass();
  285. activateClass2.SetUpICardEffect("Digivolution Cost -1", CanUseCondition2, card);
  286. activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, 1, false, EffectDiscription2());
  287. activateClass2.SetIsInheritedEffect(true);
  288. activateClass2.SetNotShowUI(true);
  289. activateClass2.SetIsBackgroundProcess(true);
  290. activateClass2.SetHashString("DigivolutionCost-1_BT14_046");
  291. string EffectDiscription2()
  292. {
  293. return "";
  294. }
  295. bool CanUseCondition2(Hashtable hashtable)
  296. {
  297. if (CardEffectCommons.IsExistOnBattleArea(card))
  298. {
  299. if (CardEffectCommons.IsOwnerTurn(card))
  300. {
  301. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  302. {
  303. List<CardSource> evoRootTops = CardEffectCommons.GetEvoRootTopsFromEnterFieldHashtable(
  304. hashtable,
  305. permanent => permanent.cardSources.Contains(card));
  306. if (evoRootTops != null)
  307. {
  308. if (!evoRootTops.Contains(card))
  309. {
  310. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) =>
  311. permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer))
  312. {
  313. return true;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. }
  320. return false;
  321. }
  322. bool CanActivateCondition2(Hashtable hashtable)
  323. {
  324. return CardEffectCommons.IsExistOnBattleArea(card);
  325. }
  326. IEnumerator ActivateCoroutine2(Hashtable _hashtable)
  327. {
  328. yield return null;
  329. }
  330. if (timing == EffectTiming.OnEnterFieldAnyone)
  331. {
  332. cardEffects.Add(activateClass2);
  333. }
  334. if (timing == EffectTiming.None)
  335. {
  336. ChangeCostClass changeCostClass = new ChangeCostClass();
  337. changeCostClass.SetUpICardEffect($"Digivolution Cost -1", CanUseCondition, card);
  338. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  339. changeCostClass.SetIsInheritedEffect(true);
  340. cardEffects.Add(changeCostClass);
  341. changeCostClass.SetMaxCountPerTurn(1);
  342. bool CanUseCondition(Hashtable hashtable)
  343. {
  344. if (CardEffectCommons.IsExistOnBattleArea(card))
  345. {
  346. if (CardEffectCommons.IsOwnerTurn(card))
  347. {
  348. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) =>
  349. permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer))
  350. {
  351. return true;
  352. }
  353. }
  354. }
  355. return false;
  356. }
  357. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  358. {
  359. if (CardSourceCondition(cardSource))
  360. {
  361. if (RootCondition(root))
  362. {
  363. if (PermanentsCondition(targetPermanents))
  364. {
  365. Cost -= 1;
  366. }
  367. }
  368. }
  369. return Cost;
  370. }
  371. bool PermanentsCondition(List<Permanent> targetPermanents)
  372. {
  373. if (targetPermanents != null)
  374. {
  375. if (targetPermanents.Count(PermanentCondition) >= 1)
  376. {
  377. return true;
  378. }
  379. }
  380. return false;
  381. }
  382. bool PermanentCondition(Permanent targetPermanent)
  383. {
  384. return targetPermanent == card.PermanentOfThisCard();
  385. }
  386. bool CardSourceCondition(CardSource cardSource)
  387. {
  388. return cardSource.Owner == card.Owner;
  389. }
  390. bool RootCondition(SelectCardEffect.Root root)
  391. {
  392. return true;
  393. }
  394. bool isUpDown()
  395. {
  396. return true;
  397. }
  398. }
  399. return cardEffects;
  400. }
  401. }
  402. }