EX5_043.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. public class EX5_043 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.None)
  11. {
  12. static bool PermanentCondition(Permanent targetPermanent)
  13. {
  14. return targetPermanent.TopCard.ContainsCardName("Leopardmon")
  15. && targetPermanent.TopCard.HasLevel
  16. && targetPermanent.TopCard.Level == 6
  17. && !targetPermanent.TopCard.HasXAntibodyTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. int ReduceCost()
  22. {
  23. int reduceCost = 4;
  24. if (card != null)
  25. {
  26. if (CardEffectCommons.IsExistOnBattleArea(card))
  27. {
  28. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.ContainsCardName("Leopardmon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  29. {
  30. reduceCost += 3;
  31. }
  32. }
  33. }
  34. return reduceCost;
  35. }
  36. if (timing == EffectTiming.OnEnterFieldAnyone)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  40. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  41. activateClass.SetHashString("PlayDigimon_EX5_043");
  42. cardEffects.Add(activateClass);
  43. string EffectDiscription()
  44. {
  45. return "[When Digivolving] [Once Per Turn] You may play 1 green Digimon card from your hand with the play cost reduced by 4. If a card with [Leopardmon] in its name or [X Antibody] is in this Digimon's digivolution cards, further reduce it by 3.";
  46. }
  47. bool CanSelectCardCondition(CardSource cardSource)
  48. {
  49. if (cardSource.IsDigimon)
  50. {
  51. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass))
  52. {
  53. if (cardSource.HasCardColor(CardColor.Green))
  54. {
  55. return true;
  56. }
  57. }
  58. }
  59. return false;
  60. }
  61. bool CanUseCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  64. }
  65. bool CanActivateCondition(Hashtable hashtable)
  66. {
  67. if (CardEffectCommons.IsExistOnBattleArea(card))
  68. {
  69. if (card.Owner.HandCards.Count >= 1)
  70. {
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  77. {
  78. #region Reduce Cost Effect
  79. ChangeCostClass changeCostClass = new ChangeCostClass();
  80. changeCostClass.SetUpICardEffect("Reduce Play Cost", CanUseCondition1, card);
  81. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  82. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  83. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  84. ICardEffect GetCardEffect(EffectTiming _timing)
  85. {
  86. if (_timing == EffectTiming.None)
  87. {
  88. return changeCostClass;
  89. }
  90. return null;
  91. }
  92. bool CanUseCondition1(Hashtable hashtable)
  93. {
  94. return true;
  95. }
  96. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  97. {
  98. if (CardSourceCondition(cardSource))
  99. {
  100. if (RootCondition(root))
  101. {
  102. if (PermanentsCondition(targetPermanents))
  103. {
  104. Cost -= ReduceCost();
  105. }
  106. }
  107. }
  108. return Cost;
  109. }
  110. bool PermanentsCondition(List<Permanent> targetPermanents)
  111. {
  112. if (targetPermanents == null)
  113. {
  114. return true;
  115. }
  116. else
  117. {
  118. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  119. {
  120. return true;
  121. }
  122. }
  123. return false;
  124. }
  125. bool CardSourceCondition(CardSource cardSource)
  126. {
  127. if (cardSource != null)
  128. {
  129. if (cardSource.Owner == card.Owner)
  130. {
  131. if (cardSource.HasCardColor(CardColor.Green))
  132. {
  133. if (cardSource.IsDigimon)
  134. {
  135. return true;
  136. }
  137. }
  138. }
  139. }
  140. return false;
  141. }
  142. bool RootCondition(SelectCardEffect.Root root)
  143. {
  144. return true;
  145. }
  146. bool isUpDown()
  147. {
  148. return true;
  149. }
  150. #endregion
  151. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  152. {
  153. List<CardSource> selectedCards = new List<CardSource>();
  154. int maxCount = 1;
  155. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  156. selectHandEffect.SetUp(
  157. selectPlayer: card.Owner,
  158. canTargetCondition: CanSelectCardCondition,
  159. canTargetCondition_ByPreSelecetedList: null,
  160. canEndSelectCondition: null,
  161. maxCount: maxCount,
  162. canNoSelect: true,
  163. canEndNotMax: false,
  164. isShowOpponent: true,
  165. selectCardCoroutine: SelectCardCoroutine,
  166. afterSelectCardCoroutine: null,
  167. mode: SelectHandEffect.Mode.Custom,
  168. cardEffect: activateClass);
  169. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  170. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  171. yield return StartCoroutine(selectHandEffect.Activate());
  172. IEnumerator SelectCardCoroutine(CardSource cardSource)
  173. {
  174. selectedCards.Add(cardSource);
  175. yield return null;
  176. }
  177. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  178. cardSources: selectedCards,
  179. activateClass: activateClass,
  180. payCost: true, isTapped: false,
  181. root: SelectCardEffect.Root.Hand,
  182. activateETB: true));
  183. }
  184. #region Remove Reduce Cost Effect
  185. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  186. #endregion
  187. }
  188. }
  189. if (timing == EffectTiming.OnDeclaration)
  190. {
  191. ActivateClass activateClass = new ActivateClass();
  192. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  193. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription());
  194. activateClass.SetHashString("PlayDigimon_EX5_043");
  195. cardEffects.Add(activateClass);
  196. string EffectDiscription()
  197. {
  198. return "[Main] [Once Per Turn] You may play 1 green Digimon card from your hand with the play cost reduced by 4. If a card with [Leopardmon] in its name or [X Antibody] is in this Digimon's digivolution cards, further reduce it by 3.";
  199. }
  200. bool CanSelectCardCondition(CardSource cardSource)
  201. {
  202. if (cardSource.IsDigimon)
  203. {
  204. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass))
  205. {
  206. if (cardSource.HasRoyalKnightTraits)
  207. {
  208. return true;
  209. }
  210. if (cardSource.HasCardColor(CardColor.Green))
  211. {
  212. return true;
  213. }
  214. }
  215. }
  216. return false;
  217. }
  218. bool CanUseCondition(Hashtable hashtable)
  219. {
  220. if (CardEffectCommons.IsExistOnBattleArea(card))
  221. {
  222. bool canPlay = false;
  223. #region Reduce Cost Effect
  224. ChangeCostClass changeCostClass = new ChangeCostClass();
  225. changeCostClass.SetUpICardEffect("Reduce Play Cost", CanUseCondition1, card);
  226. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  227. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  228. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  229. ICardEffect GetCardEffect(EffectTiming _timing)
  230. {
  231. if (_timing == EffectTiming.None)
  232. {
  233. return changeCostClass;
  234. }
  235. return null;
  236. }
  237. bool CanUseCondition1(Hashtable hashtable)
  238. {
  239. return true;
  240. }
  241. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  242. {
  243. if (CardSourceCondition(cardSource))
  244. {
  245. if (RootCondition(root))
  246. {
  247. if (PermanentsCondition(targetPermanents))
  248. {
  249. Cost -= ReduceCost();
  250. }
  251. }
  252. }
  253. return Cost;
  254. }
  255. bool PermanentsCondition(List<Permanent> targetPermanents)
  256. {
  257. if (targetPermanents == null)
  258. {
  259. return true;
  260. }
  261. else
  262. {
  263. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  264. {
  265. return true;
  266. }
  267. }
  268. return false;
  269. }
  270. bool CardSourceCondition(CardSource cardSource)
  271. {
  272. if (cardSource != null)
  273. {
  274. if (cardSource.Owner == card.Owner)
  275. {
  276. if (cardSource.HasCardColor(CardColor.Green))
  277. {
  278. if (cardSource.IsDigimon)
  279. {
  280. return true;
  281. }
  282. }
  283. }
  284. }
  285. return false;
  286. }
  287. bool RootCondition(SelectCardEffect.Root root)
  288. {
  289. return true;
  290. }
  291. bool isUpDown()
  292. {
  293. return true;
  294. }
  295. #endregion
  296. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  297. {
  298. canPlay = true;
  299. }
  300. #region Remove Reduce Cost Effect
  301. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  302. #endregion
  303. if (canPlay)
  304. {
  305. return true;
  306. }
  307. }
  308. return false;
  309. }
  310. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  311. {
  312. #region Reduce Cost Effect
  313. ChangeCostClass changeCostClass = new ChangeCostClass();
  314. changeCostClass.SetUpICardEffect("Reduce Play Cost", CanUseCondition1, card);
  315. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  316. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  317. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  318. ICardEffect GetCardEffect(EffectTiming _timing)
  319. {
  320. if (_timing == EffectTiming.None)
  321. {
  322. return changeCostClass;
  323. }
  324. return null;
  325. }
  326. bool CanUseCondition1(Hashtable hashtable)
  327. {
  328. return true;
  329. }
  330. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  331. {
  332. if (CardSourceCondition(cardSource))
  333. {
  334. if (RootCondition(root))
  335. {
  336. if (PermanentsCondition(targetPermanents))
  337. {
  338. Cost -= ReduceCost();
  339. }
  340. }
  341. }
  342. return Cost;
  343. }
  344. bool PermanentsCondition(List<Permanent> targetPermanents)
  345. {
  346. if (targetPermanents == null)
  347. {
  348. return true;
  349. }
  350. else
  351. {
  352. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  353. {
  354. return true;
  355. }
  356. }
  357. return false;
  358. }
  359. bool CardSourceCondition(CardSource cardSource)
  360. {
  361. if (cardSource != null)
  362. {
  363. if (cardSource.Owner == card.Owner)
  364. {
  365. if (cardSource.HasCardColor(CardColor.Green))
  366. {
  367. if (cardSource.IsDigimon)
  368. {
  369. return true;
  370. }
  371. }
  372. }
  373. }
  374. return false;
  375. }
  376. bool RootCondition(SelectCardEffect.Root root)
  377. {
  378. return true;
  379. }
  380. bool isUpDown()
  381. {
  382. return true;
  383. }
  384. #endregion
  385. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  386. {
  387. List<CardSource> selectedCards = new List<CardSource>();
  388. int maxCount = 1;
  389. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  390. selectHandEffect.SetUp(
  391. selectPlayer: card.Owner,
  392. canTargetCondition: CanSelectCardCondition,
  393. canTargetCondition_ByPreSelecetedList: null,
  394. canEndSelectCondition: null,
  395. maxCount: maxCount,
  396. canNoSelect: true,
  397. canEndNotMax: false,
  398. isShowOpponent: true,
  399. selectCardCoroutine: SelectCardCoroutine,
  400. afterSelectCardCoroutine: null,
  401. mode: SelectHandEffect.Mode.Custom,
  402. cardEffect: activateClass);
  403. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  404. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  405. yield return StartCoroutine(selectHandEffect.Activate());
  406. IEnumerator SelectCardCoroutine(CardSource cardSource)
  407. {
  408. selectedCards.Add(cardSource);
  409. yield return null;
  410. }
  411. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  412. cardSources: selectedCards,
  413. activateClass: activateClass,
  414. payCost: true, isTapped: false,
  415. root: SelectCardEffect.Root.Hand,
  416. activateETB: true));
  417. }
  418. #region Remove Reduce Cost Effect
  419. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  420. #endregion
  421. }
  422. }
  423. if (timing == EffectTiming.OnEnterFieldAnyone)
  424. {
  425. ActivateClass activateClass = new ActivateClass();
  426. activateClass.SetUpICardEffect("Return 1 Digimon to hand", CanUseCondition, card);
  427. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  428. activateClass.SetHashString("Bounce_EX5_043");
  429. cardEffects.Add(activateClass);
  430. string EffectDiscription()
  431. {
  432. return "[Your Turn] [Once Per Turn] When one of your Digimon is played, you may return 1 of your opponent's 5000 DP or lower Digimon to the hand. For each of your other Digimon, add 3000 to the maximum DP this effect can choose.";
  433. }
  434. int maxDP()
  435. {
  436. int maxDP = 5000;
  437. maxDP += 3000 * card.Owner.GetBattleAreaDigimons().Count(permanent => permanent != card.PermanentOfThisCard());
  438. return maxDP;
  439. }
  440. bool CanSelectPermanentCondition(Permanent permanent)
  441. {
  442. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  443. {
  444. if (permanent.DP <= maxDP())
  445. {
  446. return true;
  447. }
  448. }
  449. return false;
  450. }
  451. bool PermanentCondition(Permanent permanent)
  452. {
  453. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  454. }
  455. bool CanUseCondition(Hashtable hashtable)
  456. {
  457. if (CardEffectCommons.IsExistOnBattleArea(card))
  458. {
  459. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  460. {
  461. if (CardEffectCommons.IsOwnerTurn(card))
  462. {
  463. return true;
  464. }
  465. }
  466. }
  467. return false;
  468. }
  469. bool CanActivateCondition(Hashtable hashtable)
  470. {
  471. if (CardEffectCommons.IsExistOnBattleArea(card))
  472. {
  473. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  474. {
  475. return true;
  476. }
  477. }
  478. return false;
  479. }
  480. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  481. {
  482. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  483. {
  484. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  485. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  486. selectPermanentEffect.SetUp(
  487. selectPlayer: card.Owner,
  488. canTargetCondition: CanSelectPermanentCondition,
  489. canTargetCondition_ByPreSelecetedList: null,
  490. canEndSelectCondition: null,
  491. maxCount: maxCount,
  492. canNoSelect: false,
  493. canEndNotMax: false,
  494. selectPermanentCoroutine: null,
  495. afterSelectPermanentCoroutine: null,
  496. mode: SelectPermanentEffect.Mode.Bounce,
  497. cardEffect: activateClass);
  498. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  499. }
  500. }
  501. }
  502. return cardEffects;
  503. }
  504. }