BT21_030.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Shoutmon X7: Superior Mode
  6. namespace DCGO.CardEffects.BT21
  7. {
  8. public class BT21_030 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. if (targetPermanent.TopCard.Level == 6 && targetPermanent.TopCard.EqualsTraits("Hero"))
  19. {
  20. return true;
  21. }
  22. return false;
  23. }
  24. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  25. permanentCondition: PermanentCondition,
  26. digivolutionCost:5,
  27. ignoreDigivolutionRequirement: false,
  28. card: card,
  29. condition: null)
  30. );
  31. }
  32. #endregion
  33. #region DigiXros
  34. if (timing == EffectTiming.None)
  35. {
  36. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  37. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  38. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  39. addDigiXrosConditionClass.SetNotShowUI(true);
  40. cardEffects.Add(addDigiXrosConditionClass);
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return true;
  44. }
  45. DigiXrosCondition GetDigiXros(CardSource cardSource)
  46. {
  47. if (cardSource == card)
  48. {
  49. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "1 Digimon card with [Xros Heart] or [Blue Flare] trait");
  50. bool CanSelectCardCondition(CardSource cardSource)
  51. {
  52. if (cardSource != null)
  53. {
  54. if (cardSource.Owner == card.Owner)
  55. {
  56. if (cardSource.IsDigimon)
  57. {
  58. if (cardSource.EqualsTraits("Xros Heart"))
  59. {
  60. return true;
  61. }
  62. if (cardSource.EqualsTraits("Blue Flare"))
  63. {
  64. return true;
  65. }
  66. }
  67. }
  68. }
  69. return false;
  70. }
  71. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>();
  72. for (int i = 0; i < 50; i++)
  73. {
  74. elements.Add(element);
  75. }
  76. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  77. {
  78. List<string> cardIDs = new List<string>();
  79. foreach (CardSource cardSource1 in cardSources)
  80. {
  81. if (!cardIDs.Contains(cardSource1.CardID))
  82. {
  83. cardIDs.Add(cardSource1.CardID);
  84. }
  85. }
  86. if (cardIDs.Contains(cardSource.CardID))
  87. {
  88. return false;
  89. }
  90. return true;
  91. }
  92. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, CanTargetCondition_ByPreSelecetedList, 1);
  93. return digiXrosCondition;
  94. }
  95. return null;
  96. }
  97. }
  98. #endregion
  99. #region DigiXros Special
  100. if (timing == EffectTiming.BeforePayCost)
  101. {
  102. ActivateClass activateClass = new ActivateClass();
  103. activateClass.SetUpICardEffect("Play Cost -1 and select trash cards for a DigiXros", CanUseCondition, card);
  104. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  105. activateClass.SetHashString("PlayCost-1_BT21_030");
  106. cardEffects.Add(activateClass);
  107. string EffectDiscription()
  108. {
  109. return "When you would play this card, by placing 1 [Shoutmon] as a digivolution card under this Digimon, reduce its play cost by 1 and place the cards in your trash as digivolution cards for a DigiXros.";
  110. }
  111. bool CanSelectPermanentCondition(Permanent permanent)
  112. {
  113. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  114. {
  115. if (permanent.TopCard.CardNames.Contains("Shoutmon"))
  116. {
  117. if (permanent.CanSelectBySkill(activateClass))
  118. {
  119. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  120. {
  121. if (!permanent.IsToken)
  122. {
  123. return true;
  124. }
  125. }
  126. }
  127. }
  128. }
  129. return false;
  130. }
  131. bool CardCondition(CardSource cardSource)
  132. {
  133. return cardSource == card;
  134. }
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  138. {
  139. return true;
  140. }
  141. return false;
  142. }
  143. bool CanActivateCondition(Hashtable hashtable)
  144. {
  145. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  146. {
  147. return true;
  148. }
  149. return false;
  150. }
  151. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  152. {
  153. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  154. {
  155. int maxCount = 1;
  156. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  157. selectPermanentEffect.SetUp(
  158. selectPlayer: card.Owner,
  159. canTargetCondition: CanSelectPermanentCondition,
  160. canTargetCondition_ByPreSelecetedList: null,
  161. canEndSelectCondition: null,
  162. maxCount: maxCount,
  163. canNoSelect: true,
  164. canEndNotMax: false,
  165. selectPermanentCoroutine: null,
  166. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  167. mode: SelectPermanentEffect.Mode.Custom,
  168. cardEffect: activateClass);
  169. selectPermanentEffect.SetUpCustomMessage("Select 1 [Shoutmon].", "The opponent is selecting 1 [Shoutmon].");
  170. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  171. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  172. {
  173. yield return null;
  174. if (permanents.Count >= 1)
  175. {
  176. Permanent selectedPermanent = permanents[0];
  177. if (selectedPermanent != null)
  178. {
  179. if (selectedPermanent.TopCard != null)
  180. {
  181. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  182. {
  183. GManager.instance.GetComponent<SelectDigiXrosClass>().AddDigivolutionCardInfos(new AddDigivolutionCardsInfo(activateClass, new List<CardSource>() { selectedPermanent.TopCard }));
  184. if (card.Owner.CanReduceCost(null, card))
  185. {
  186. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  187. }
  188. ChangeCostClass changeCostClass = new ChangeCostClass();
  189. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition1, card);
  190. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  191. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  192. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  193. bool CanUseCondition1(Hashtable hashtable)
  194. {
  195. return true;
  196. }
  197. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  198. {
  199. if (CardSourceCondition(cardSource))
  200. {
  201. if (RootCondition(root))
  202. {
  203. if (PermanentsCondition(targetPermanents))
  204. {
  205. Cost -= 1;
  206. }
  207. }
  208. }
  209. return Cost;
  210. }
  211. bool PermanentsCondition(List<Permanent> targetPermanents)
  212. {
  213. if (targetPermanents == null)
  214. {
  215. return true;
  216. }
  217. else
  218. {
  219. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  220. {
  221. return true;
  222. }
  223. }
  224. return false;
  225. }
  226. bool CardSourceCondition(CardSource cardSource)
  227. {
  228. return cardSource == card;
  229. }
  230. bool RootCondition(SelectCardEffect.Root root)
  231. {
  232. return true;
  233. }
  234. bool isUpDown()
  235. {
  236. return true;
  237. }
  238. #region can select digixros cards from trash
  239. AddMaxTrashCountDigiXrosClass addMaxTrashCountDigiXrosClass = new AddMaxTrashCountDigiXrosClass();
  240. addMaxTrashCountDigiXrosClass.SetUpICardEffect("Can select DigiXros cards from trash", CanUseCondition1, card);
  241. addMaxTrashCountDigiXrosClass.SetUpAddMaxTrashCountDigiXrosClass(getMaxTrashCount: GetCount);
  242. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  243. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  244. ICardEffect GetCardEffect(EffectTiming _timing)
  245. {
  246. if (_timing == EffectTiming.None)
  247. {
  248. return addMaxTrashCountDigiXrosClass;
  249. }
  250. return null;
  251. }
  252. int GetCount(CardSource cardSource)
  253. {
  254. return 100;
  255. }
  256. #endregion
  257. }
  258. }
  259. }
  260. }
  261. }
  262. }
  263. }
  264. }
  265. #endregion
  266. #region On Play / When Digivolving Shared
  267. bool SharedCanSelectPermanent(Permanent permanent)
  268. {
  269. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  270. {
  271. return true;
  272. }
  273. return false;
  274. }
  275. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  276. {
  277. if (CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectPermanent))
  278. {
  279. Permanent selectedPermanent = null;
  280. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SharedCanSelectPermanent));
  281. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  282. selectPermanentEffect.SetUp(
  283. selectPlayer: card.Owner,
  284. canTargetCondition: SharedCanSelectPermanent,
  285. canTargetCondition_ByPreSelecetedList: null,
  286. canEndSelectCondition: null,
  287. maxCount: maxCount,
  288. canNoSelect: false,
  289. canEndNotMax: false,
  290. selectPermanentCoroutine: SelectPermanentCoroutine,
  291. afterSelectPermanentCoroutine: null,
  292. mode: SelectPermanentEffect.Mode.Custom,
  293. cardEffect: activateClass);
  294. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon.", "The opponent is selecting 1 Digimon.");
  295. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  296. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  297. {
  298. selectedPermanent = permanent;
  299. yield return null;
  300. }
  301. if (selectedPermanent != null)
  302. {
  303. yield return ContinuousController.instance.StartCoroutine(new ITrashStack(selectedPermanent, 10, activateClass).TrashStack());
  304. }
  305. }
  306. }
  307. #endregion
  308. #region On Play
  309. if (timing == EffectTiming.OnEnterFieldAnyone)
  310. {
  311. ActivateClass activateClass = new ActivateClass();
  312. activateClass.SetUpICardEffect("Trash top 10 stack cards", CanUseCondition, card);
  313. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  314. cardEffects.Add(activateClass);
  315. string EffectDiscription()
  316. {
  317. return "[On Play] Trash the top 10 stacked cards of 1 of your opponent's Digimon.";
  318. }
  319. bool CanUseCondition(Hashtable hashtable)
  320. {
  321. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  322. {
  323. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  324. {
  325. return true;
  326. }
  327. }
  328. return false;
  329. }
  330. bool CanActivateCondition(Hashtable hashtable)
  331. {
  332. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  333. {
  334. if (CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectPermanent))
  335. {
  336. return true;
  337. }
  338. }
  339. return false;
  340. }
  341. }
  342. #endregion
  343. #region When Digivolving
  344. if (timing == EffectTiming.OnEnterFieldAnyone)
  345. {
  346. ActivateClass activateClass = new ActivateClass();
  347. activateClass.SetUpICardEffect("Trash top 10 stack cards", CanUseCondition, card);
  348. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  349. cardEffects.Add(activateClass);
  350. string EffectDiscription()
  351. {
  352. return "[When Digivolving] Trash the top 10 stacked cards of 1 of your opponent's Digimon.";
  353. }
  354. bool CanUseCondition(Hashtable hashtable)
  355. {
  356. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  357. {
  358. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  359. {
  360. return true;
  361. }
  362. }
  363. return false;
  364. }
  365. bool CanActivateCondition(Hashtable hashtable)
  366. {
  367. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  368. {
  369. if (CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectPermanent))
  370. {
  371. return true;
  372. }
  373. }
  374. return false;
  375. }
  376. }
  377. #endregion
  378. #region When Attacking
  379. if (timing == EffectTiming.OnAllyAttack)
  380. {
  381. ActivateClass activateClass = new ActivateClass();
  382. activateClass.SetUpICardEffect("Bottom deck digimon with no digivolution cards", CanUseCondition, card);
  383. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  384. activateClass.SetHashString("BottomDeck_BT21-030");
  385. cardEffects.Add(activateClass);
  386. string EffectDiscription()
  387. {
  388. return "[When Attacking] [Once Per Turn] You may return 1 of your opponent's Digimon with no digivolution cards to the bottom of the deck.";
  389. }
  390. bool CanUseCondition(Hashtable hashtable)
  391. {
  392. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  393. {
  394. if (CardEffectCommons.CanTriggerOnAttack(hashtable, card))
  395. {
  396. return true;
  397. }
  398. }
  399. return false;
  400. }
  401. bool CanActivateCondition(Hashtable hashtable)
  402. {
  403. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  404. {
  405. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  406. {
  407. return true;
  408. }
  409. }
  410. return false;
  411. }
  412. bool CanSelectPermanentCondition(Permanent permanent)
  413. {
  414. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  415. {
  416. if (permanent.HasNoDigivolutionCards)
  417. {
  418. return true;
  419. }
  420. }
  421. return false;
  422. }
  423. IEnumerator ActivateCoroutine(Hashtable hashtable)
  424. {
  425. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  426. {
  427. Permanent selectedPermanent = null;
  428. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  429. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  430. selectPermanentEffect.SetUp(
  431. selectPlayer: card.Owner,
  432. canTargetCondition: CanSelectPermanentCondition,
  433. canTargetCondition_ByPreSelecetedList: null,
  434. canEndSelectCondition: null,
  435. maxCount: maxCount,
  436. canNoSelect: true,
  437. canEndNotMax: false,
  438. selectPermanentCoroutine: SelectPermanentCoroutine,
  439. afterSelectPermanentCoroutine: null,
  440. mode: SelectPermanentEffect.Mode.Custom,
  441. cardEffect: activateClass);
  442. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon.", "The opponent is selecting 1 Digimon.");
  443. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  444. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  445. {
  446. selectedPermanent = permanent;
  447. yield return null;
  448. }
  449. if (selectedPermanent != null)
  450. {
  451. yield return ContinuousController.instance.StartCoroutine(new DeckBottomBounceClass(new List<Permanent>() { selectedPermanent }, CardEffectCommons.CardEffectHashtable(activateClass)).DeckBounce());
  452. }
  453. }
  454. }
  455. }
  456. #endregion
  457. return cardEffects;
  458. }
  459. }
  460. }