BT17_026.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_026 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Hand - Main
  13. if (timing == EffectTiming.OnDeclaration)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Your [Koji Minamoto] digivolves into this card", CanUseCondition,
  17. card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  19. cardEffects.Add(activateClass);
  20. string EffectDescription()
  21. {
  22. return
  23. "[Hand] [Main] By placing 1 [Lobomon] and [KendoGarurumon] from your trash under 1 of your [Koji Minamoto]s, digivolve it into this card as if that card is a level 4 blue Digimon for a digivolution cost of 3.";
  24. }
  25. bool CanSelectLobomonCardCondition(CardSource cardSource)
  26. {
  27. if (cardSource != null)
  28. {
  29. if (cardSource.Owner == card.Owner)
  30. {
  31. if (cardSource.EqualsCardName("Lobomon"))
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanSelectKendoGarurumonCardCondition(CardSource cardSource)
  40. {
  41. if (cardSource != null)
  42. {
  43. if (cardSource.Owner == card.Owner)
  44. {
  45. if (cardSource.EqualsCardName("KendoGarurumon"))
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanSelectPermanentCondition(Permanent permanent)
  54. {
  55. if (permanent != null)
  56. {
  57. if (permanent.TopCard != null)
  58. {
  59. if (permanent.TopCard.Owner == card.Owner)
  60. {
  61. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  62. {
  63. if (!permanent.IsToken)
  64. {
  65. if (permanent.TopCard.EqualsCardName("Koji Minamoto") ||
  66. permanent.TopCard.EqualsCardName("KojiMinamoto"))
  67. {
  68. return true;
  69. }
  70. }
  71. }
  72. }
  73. }
  74. }
  75. return false;
  76. }
  77. bool CanUseCondition(Hashtable hashtable)
  78. {
  79. if (card.Owner.HandCards.Contains(card))
  80. {
  81. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  82. {
  83. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  84. CanSelectLobomonCardCondition))
  85. {
  86. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  87. CanSelectKendoGarurumonCardCondition))
  88. {
  89. return true;
  90. }
  91. }
  92. }
  93. }
  94. return false;
  95. }
  96. IEnumerator ActivateCoroutine(Hashtable hashtable)
  97. {
  98. if (card.Owner.HandCards.Contains(card))
  99. {
  100. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  101. {
  102. Permanent selectedPermanent = null;
  103. int maxCount = Math.Min(1,
  104. card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  105. SelectPermanentEffect selectPermanentEffect =
  106. GManager.instance.GetComponent<SelectPermanentEffect>();
  107. selectPermanentEffect.SetUp(
  108. selectPlayer: card.Owner,
  109. canTargetCondition: CanSelectPermanentCondition,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. maxCount: maxCount,
  113. canNoSelect: false,
  114. canEndNotMax: false,
  115. selectPermanentCoroutine: SelectPermanentCoroutine,
  116. afterSelectPermanentCoroutine: null,
  117. mode: SelectPermanentEffect.Mode.Custom,
  118. cardEffect: activateClass);
  119. selectPermanentEffect.SetUpCustomMessage("Select 1 [Koji Minamoto].",
  120. "The opponent is selecting 1 [Koji Minamoto].");
  121. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  122. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  123. {
  124. selectedPermanent = permanent;
  125. yield return null;
  126. }
  127. if (selectedPermanent != null)
  128. {
  129. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  130. (cardSource) =>
  131. CanSelectLobomonCardCondition(cardSource) ||
  132. CanSelectKendoGarurumonCardCondition(cardSource)))
  133. {
  134. bool digivolve = false;
  135. maxCount = 2;
  136. if (card.Owner.TrashCards.Count((cardSource) =>
  137. CanSelectLobomonCardCondition(cardSource) ||
  138. CanSelectKendoGarurumonCardCondition(cardSource)) <
  139. maxCount)
  140. {
  141. maxCount = card.Owner.TrashCards.Count((cardSource) =>
  142. CanSelectLobomonCardCondition(cardSource) ||
  143. CanSelectKendoGarurumonCardCondition(cardSource));
  144. }
  145. List<CardSource> selectedCards = new List<CardSource>();
  146. SelectCardEffect selectCardEffect =
  147. GManager.instance.GetComponent<SelectCardEffect>();
  148. selectCardEffect.SetUp(
  149. canTargetCondition: (cardSource) =>
  150. CanSelectLobomonCardCondition(cardSource) ||
  151. CanSelectKendoGarurumonCardCondition(cardSource),
  152. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  153. canEndSelectCondition: CanEndSelectCondition,
  154. canNoSelect: () => false,
  155. selectCardCoroutine: SelectCardCoroutine,
  156. afterSelectCardCoroutine: null,
  157. message:
  158. "Select cards to place on the bottom of Digivolution cards\n(cards will be placed in the digivolution cards so that cards with lower numbers are on top).",
  159. maxCount: maxCount,
  160. canEndNotMax: false,
  161. isShowOpponent: true,
  162. mode: SelectCardEffect.Mode.Custom,
  163. root: SelectCardEffect.Root.Trash,
  164. customRootCardList: null,
  165. canLookReverseCard: true,
  166. selectPlayer: card.Owner,
  167. cardEffect: activateClass);
  168. yield return ContinuousController.instance.StartCoroutine(
  169. selectCardEffect.Activate());
  170. bool CanTargetConditionByPreSelectedList(List<CardSource> cardSources,
  171. CardSource cardSource)
  172. {
  173. if (cardSources.Count(CanSelectLobomonCardCondition) >= 1)
  174. {
  175. if (CanSelectLobomonCardCondition(cardSource))
  176. {
  177. return false;
  178. }
  179. }
  180. if (cardSources.Count(CanSelectKendoGarurumonCardCondition) >= 1)
  181. {
  182. if (CanSelectKendoGarurumonCardCondition(cardSource))
  183. {
  184. return false;
  185. }
  186. }
  187. return true;
  188. }
  189. bool CanEndSelectCondition(List<CardSource> cardSources)
  190. {
  191. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  192. CanSelectLobomonCardCondition))
  193. {
  194. if (cardSources.Count(CanSelectLobomonCardCondition) == 0)
  195. {
  196. return false;
  197. }
  198. }
  199. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  200. CanSelectKendoGarurumonCardCondition))
  201. {
  202. if (cardSources.Count(CanSelectKendoGarurumonCardCondition) == 0)
  203. {
  204. return false;
  205. }
  206. }
  207. if (cardSources.Count(CanSelectLobomonCardCondition) >= 2)
  208. {
  209. return false;
  210. }
  211. if (cardSources.Count(CanSelectKendoGarurumonCardCondition) >= 2)
  212. {
  213. return false;
  214. }
  215. return true;
  216. }
  217. IEnumerator SelectCardCoroutine(CardSource cardSource)
  218. {
  219. selectedCards.Add(cardSource);
  220. yield return null;
  221. }
  222. if (selectedCards.Count >= 1)
  223. {
  224. yield return ContinuousController.instance.StartCoroutine(
  225. selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  226. if (selectedCards.Count == 2)
  227. {
  228. digivolve = true;
  229. }
  230. }
  231. if (digivolve)
  232. {
  233. CardSource topCard = selectedPermanent.TopCard;
  234. ChangeCardColorClass changeCardColorClass = new ChangeCardColorClass();
  235. changeCardColorClass.SetUpICardEffect($"Treated as blue",
  236. CanUseChangeColorCondition,
  237. card);
  238. changeCardColorClass.SetUpChangeCardColorClass(
  239. ChangeCardColors: ChangeCardColors);
  240. changeCardColorClass.SetNotShowUI(true);
  241. bool CanUseChangeColorCondition(Hashtable ccHashtable)
  242. {
  243. if (selectedPermanent.TopCard != null)
  244. {
  245. if (card.Owner.GetBattleAreaPermanents().Contains(selectedPermanent))
  246. {
  247. if (topCard == selectedPermanent.TopCard)
  248. {
  249. return true;
  250. }
  251. }
  252. }
  253. return false;
  254. }
  255. List<CardColor> ChangeCardColors(CardSource cardSource,
  256. List<CardColor> cardColors)
  257. {
  258. if (cardSource == selectedPermanent.TopCard)
  259. {
  260. cardColors.Add(CardColor.Red);
  261. }
  262. return cardColors;
  263. }
  264. ChangePermanentLevelClass changePermanentLevelClass =
  265. new ChangePermanentLevelClass();
  266. changePermanentLevelClass.SetUpICardEffect($"Treated as level 4",
  267. CanUseChangeColorCondition, card);
  268. changePermanentLevelClass.SetUpChangePermanentLevelClass(GetLevel: GetLevel);
  269. changePermanentLevelClass.SetNotShowUI(true);
  270. int GetLevel(Permanent permanent, int level)
  271. {
  272. if (selectedPermanent.TopCard != null)
  273. {
  274. if (permanent == selectedPermanent)
  275. {
  276. level = 4;
  277. }
  278. }
  279. return level;
  280. }
  281. TreatAsDigimonClass treatAsDigimonClass = new TreatAsDigimonClass();
  282. treatAsDigimonClass.SetUpICardEffect($"Treated as Digimon",
  283. CanUseChangeColorCondition,
  284. card);
  285. treatAsDigimonClass.SetUpTreatAsDigimonClass(
  286. permanentCondition: PermanentCondition);
  287. treatAsDigimonClass.SetNotShowUI(true);
  288. bool PermanentCondition(Permanent permanent)
  289. {
  290. if (selectedPermanent.TopCard != null)
  291. {
  292. if (permanent == selectedPermanent)
  293. {
  294. return true;
  295. }
  296. }
  297. return false;
  298. }
  299. DontHaveDPClass dontHaveDPClass = new DontHaveDPClass();
  300. dontHaveDPClass.SetUpICardEffect("Don't have DP", CanUseChangeColorCondition,
  301. card);
  302. dontHaveDPClass.SetUpDontHaveDPClass(PermanentCondition: PermanentCondition);
  303. dontHaveDPClass.SetNotShowUI(true);
  304. List<Func<EffectTiming, ICardEffect>> getCardEffects =
  305. new List<Func<EffectTiming, ICardEffect>>()
  306. {
  307. _ => changeCardColorClass,
  308. _ => changePermanentLevelClass,
  309. _ => treatAsDigimonClass,
  310. _ => dontHaveDPClass,
  311. };
  312. foreach (Func<EffectTiming, ICardEffect> getCardEffect in getCardEffects)
  313. {
  314. card.Owner.PermanentEffects.Add(getCardEffect);
  315. }
  316. if (card.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, true,
  317. activateClass))
  318. {
  319. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  320. targetPermanent: selectedPermanent,
  321. cardCondition: source => source == card,
  322. payCost: true,
  323. reduceCostTuple: null,
  324. fixedCostTuple: (fixedCost: 3, fixedCostCardCondition: null),
  325. ignoreDigivolutionRequirementFixedCost: -1,
  326. isHand: true,
  327. activateClass: activateClass,
  328. successProcess: null,
  329. failedProcess: DigivolvedFailed(),
  330. isOptional: false));
  331. }
  332. else
  333. {
  334. yield return ContinuousController.instance.StartCoroutine("DigivolvedFailed");
  335. }
  336. IEnumerator DigivolvedFailed()
  337. {
  338. IDiscardHand discard = new IDiscardHand(card, hashtable);
  339. discard.Discard();
  340. yield return null;
  341. }
  342. foreach (Func<EffectTiming, ICardEffect> getCardEffect in getCardEffects)
  343. {
  344. card.Owner.PermanentEffects.Remove(getCardEffect);
  345. }
  346. }
  347. }
  348. }
  349. }
  350. }
  351. }
  352. }
  353. #endregion
  354. #region When Digivolving
  355. if (timing == EffectTiming.OnEnterFieldAnyone)
  356. {
  357. ActivateClass activateClass = new ActivateClass();
  358. activateClass.SetUpICardEffect("Return 1 digivolution card and 1 of your opponent's Digimon can't suspend", CanUseCondition,
  359. card);
  360. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  361. cardEffects.Add(activateClass);
  362. string EffectDescription()
  363. {
  364. return
  365. "[When Digivolving] By returning 1 card with the [Hybrid] trait from this Digimon's digivolution cards to the hand, 1 of your opponent's Digimon or Tamers can't suspend until the end of their turn.";
  366. }
  367. bool CanUseCondition(Hashtable hashtable)
  368. {
  369. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  370. }
  371. bool CanSelectSourceCardCondition(CardSource cardSource)
  372. {
  373. return cardSource.CardTraits.Contains("Hybrid");
  374. }
  375. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  376. {
  377. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  378. {
  379. return permanent.IsDigimon || permanent.IsTamer;
  380. }
  381. return false;
  382. }
  383. bool CanActivateCondition(Hashtable hashtable)
  384. {
  385. if (CardEffectCommons.IsExistOnBattleArea(card))
  386. {
  387. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectSourceCardCondition) >= 1)
  388. {
  389. return true;
  390. }
  391. }
  392. return false;
  393. }
  394. IEnumerator ActivateCoroutine(Hashtable hashtable)
  395. {
  396. Permanent selectedPermanent = card.PermanentOfThisCard();
  397. if (selectedPermanent.DigivolutionCards.Count(CanSelectSourceCardCondition) >= 1)
  398. {
  399. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectSourceCardCondition));
  400. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  401. selectCardEffect.SetUp(
  402. canTargetCondition: CanSelectSourceCardCondition,
  403. canTargetCondition_ByPreSelecetedList: null,
  404. canEndSelectCondition: null,
  405. canNoSelect: () => false,
  406. selectCardCoroutine: null,
  407. afterSelectCardCoroutine: null,
  408. message: "Select 1 card to add to your hand.",
  409. maxCount: maxCount,
  410. canEndNotMax: false,
  411. isShowOpponent: true,
  412. mode: SelectCardEffect.Mode.AddHand,
  413. root: SelectCardEffect.Root.Custom,
  414. customRootCardList: selectedPermanent.DigivolutionCards,
  415. canLookReverseCard: true,
  416. selectPlayer: card.Owner,
  417. cardEffect: activateClass);
  418. yield return StartCoroutine(selectCardEffect.Activate());
  419. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentPermanentCondition))
  420. {
  421. maxCount = Math.Min(1,
  422. CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  423. SelectPermanentEffect selectPermanentEffect =
  424. GManager.instance.GetComponent<SelectPermanentEffect>();
  425. selectPermanentEffect.SetUp(
  426. selectPlayer: card.Owner,
  427. canTargetCondition_ByPreSelecetedList: null,
  428. canTargetCondition: CanSelectOpponentPermanentCondition,
  429. canEndSelectCondition: null,
  430. maxCount: maxCount,
  431. canNoSelect: false,
  432. canEndNotMax: false,
  433. selectPermanentCoroutine: SelectPermanentCoroutine,
  434. afterSelectPermanentCoroutine: null,
  435. mode: SelectPermanentEffect.Mode.Custom,
  436. cardEffect: activateClass);
  437. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon/Tamer that will be unable to suspend.",
  438. "The opponent is selecting 1 Digimon/Tamer that will be unable to suspend.");
  439. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  440. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  441. {
  442. selectedPermanent = permanent;
  443. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  444. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCanNotSuspendCondition, card);
  445. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCanNotSuspendCondition);
  446. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => canNotSuspendClass);
  447. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  448. {
  449. yield return ContinuousController.instance.StartCoroutine(GManager.instance
  450. .GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  451. }
  452. bool CanUseCanNotSuspendCondition(Hashtable hashtableCanNotSuspend)
  453. {
  454. if (selectedPermanent.TopCard != null)
  455. {
  456. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  457. {
  458. return true;
  459. }
  460. }
  461. return false;
  462. }
  463. bool PermanentCanNotSuspendCondition(Permanent permanentCanNotSuspend)
  464. {
  465. if (permanentCanNotSuspend == selectedPermanent)
  466. {
  467. return true;
  468. }
  469. return false;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. }
  476. #endregion
  477. #region When Attacking - ESS
  478. if (timing == EffectTiming.OnAllyAttack)
  479. {
  480. ActivateClass activateClass = new ActivateClass();
  481. activateClass.SetUpICardEffect("Return 1 of your opponent's Digimon to hand", CanUseCondition, card);
  482. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  483. activateClass.SetIsInheritedEffect(true);
  484. cardEffects.Add(activateClass);
  485. string EffectDescription()
  486. {
  487. return
  488. "[When Attacking] [Once Per Turn] If this Digimon has the [Hybrid]/[Ten Warriors] trait, return 1 of your opponent's level 4 or lower Digimon to the hand.";
  489. }
  490. bool CanUseCondition(Hashtable hashtable)
  491. {
  492. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  493. }
  494. bool CanSelectPermanentCondition(Permanent permanent)
  495. {
  496. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  497. {
  498. if (permanent.Level <= 4)
  499. {
  500. return true;
  501. }
  502. }
  503. return false;
  504. }
  505. bool CanActivateCondition(Hashtable hashtable)
  506. {
  507. if (CardEffectCommons.IsExistOnBattleArea(card))
  508. {
  509. if (card.PermanentOfThisCard().TopCard.ContainsTraits("Hybrid") ||
  510. card.PermanentOfThisCard().TopCard.ContainsTraits("Ten Warriors") ||
  511. card.PermanentOfThisCard().TopCard.ContainsTraits("TenWarriors"))
  512. {
  513. return true;
  514. }
  515. }
  516. return false;
  517. }
  518. IEnumerator ActivateCoroutine(Hashtable hashtable)
  519. {
  520. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  521. {
  522. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  523. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  524. selectPermanentEffect.SetUp(
  525. selectPlayer: card.Owner,
  526. canTargetCondition: CanSelectPermanentCondition,
  527. canTargetCondition_ByPreSelecetedList: null,
  528. canEndSelectCondition: null,
  529. maxCount: maxCount,
  530. canNoSelect: false,
  531. canEndNotMax: false,
  532. selectPermanentCoroutine: null,
  533. afterSelectPermanentCoroutine: null,
  534. mode: SelectPermanentEffect.Mode.Bounce,
  535. cardEffect: activateClass);
  536. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  537. }
  538. }
  539. }
  540. #endregion
  541. return cardEffects;
  542. }
  543. }
  544. }