BT17_026.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  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. }
  330. foreach (Func<EffectTiming, ICardEffect> getCardEffect in getCardEffects)
  331. {
  332. card.Owner.PermanentEffects.Remove(getCardEffect);
  333. }
  334. }
  335. }
  336. }
  337. }
  338. }
  339. }
  340. }
  341. #endregion
  342. #region When Digivolving
  343. if (timing == EffectTiming.OnEnterFieldAnyone)
  344. {
  345. ActivateClass activateClass = new ActivateClass();
  346. activateClass.SetUpICardEffect("Return 1 digivolution card and 1 of your opponent's Digimon can't suspend", CanUseCondition,
  347. card);
  348. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  349. cardEffects.Add(activateClass);
  350. string EffectDescription()
  351. {
  352. return
  353. "[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.";
  354. }
  355. bool CanUseCondition(Hashtable hashtable)
  356. {
  357. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  358. }
  359. bool CanSelectSourceCardCondition(CardSource cardSource)
  360. {
  361. return cardSource.CardTraits.Contains("Hybrid");
  362. }
  363. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  364. {
  365. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  366. {
  367. return permanent.IsDigimon || permanent.IsTamer;
  368. }
  369. return false;
  370. }
  371. bool CanActivateCondition(Hashtable hashtable)
  372. {
  373. if (CardEffectCommons.IsExistOnBattleArea(card))
  374. {
  375. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectSourceCardCondition) >= 1)
  376. {
  377. return true;
  378. }
  379. }
  380. return false;
  381. }
  382. IEnumerator ActivateCoroutine(Hashtable hashtable)
  383. {
  384. Permanent selectedPermanent = card.PermanentOfThisCard();
  385. if (selectedPermanent.DigivolutionCards.Count(CanSelectSourceCardCondition) >= 1)
  386. {
  387. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectSourceCardCondition));
  388. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  389. selectCardEffect.SetUp(
  390. canTargetCondition: CanSelectSourceCardCondition,
  391. canTargetCondition_ByPreSelecetedList: null,
  392. canEndSelectCondition: null,
  393. canNoSelect: () => false,
  394. selectCardCoroutine: null,
  395. afterSelectCardCoroutine: null,
  396. message: "Select 1 card to add to your hand.",
  397. maxCount: maxCount,
  398. canEndNotMax: false,
  399. isShowOpponent: true,
  400. mode: SelectCardEffect.Mode.AddHand,
  401. root: SelectCardEffect.Root.Custom,
  402. customRootCardList: selectedPermanent.DigivolutionCards,
  403. canLookReverseCard: true,
  404. selectPlayer: card.Owner,
  405. cardEffect: activateClass);
  406. yield return StartCoroutine(selectCardEffect.Activate());
  407. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentPermanentCondition))
  408. {
  409. maxCount = Math.Min(1,
  410. CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  411. SelectPermanentEffect selectPermanentEffect =
  412. GManager.instance.GetComponent<SelectPermanentEffect>();
  413. selectPermanentEffect.SetUp(
  414. selectPlayer: card.Owner,
  415. canTargetCondition_ByPreSelecetedList: null,
  416. canTargetCondition: CanSelectOpponentPermanentCondition,
  417. canEndSelectCondition: null,
  418. maxCount: maxCount,
  419. canNoSelect: false,
  420. canEndNotMax: false,
  421. selectPermanentCoroutine: SelectPermanentCoroutine,
  422. afterSelectPermanentCoroutine: null,
  423. mode: SelectPermanentEffect.Mode.Custom,
  424. cardEffect: activateClass);
  425. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon/Tamer that will be unable to suspend.",
  426. "The opponent is selecting 1 Digimon/Tamer that will be unable to suspend.");
  427. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  428. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  429. {
  430. selectedPermanent = permanent;
  431. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  432. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCanNotSuspendCondition, card);
  433. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCanNotSuspendCondition);
  434. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => canNotSuspendClass);
  435. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  436. {
  437. yield return ContinuousController.instance.StartCoroutine(GManager.instance
  438. .GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  439. }
  440. bool CanUseCanNotSuspendCondition(Hashtable hashtableCanNotSuspend)
  441. {
  442. if (selectedPermanent.TopCard != null)
  443. {
  444. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  445. {
  446. return true;
  447. }
  448. }
  449. return false;
  450. }
  451. bool PermanentCanNotSuspendCondition(Permanent permanentCanNotSuspend)
  452. {
  453. if (permanentCanNotSuspend == selectedPermanent)
  454. {
  455. return true;
  456. }
  457. return false;
  458. }
  459. }
  460. }
  461. }
  462. }
  463. }
  464. #endregion
  465. #region When Attacking - ESS
  466. if (timing == EffectTiming.OnAllyAttack)
  467. {
  468. ActivateClass activateClass = new ActivateClass();
  469. activateClass.SetUpICardEffect("Return 1 of your opponent's Digimon to hand", CanUseCondition, card);
  470. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  471. activateClass.SetIsInheritedEffect(true);
  472. cardEffects.Add(activateClass);
  473. string EffectDescription()
  474. {
  475. return
  476. "[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.";
  477. }
  478. bool CanUseCondition(Hashtable hashtable)
  479. {
  480. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  481. }
  482. bool CanSelectPermanentCondition(Permanent permanent)
  483. {
  484. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  485. {
  486. if (permanent.Level <= 4)
  487. {
  488. return true;
  489. }
  490. }
  491. return false;
  492. }
  493. bool CanActivateCondition(Hashtable hashtable)
  494. {
  495. if (CardEffectCommons.IsExistOnBattleArea(card))
  496. {
  497. if (card.PermanentOfThisCard().TopCard.ContainsTraits("Hybrid") ||
  498. card.PermanentOfThisCard().TopCard.ContainsTraits("Ten Warriors") ||
  499. card.PermanentOfThisCard().TopCard.ContainsTraits("TenWarriors"))
  500. {
  501. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  502. {
  503. return true;
  504. }
  505. }
  506. }
  507. return false;
  508. }
  509. IEnumerator ActivateCoroutine(Hashtable hashtable)
  510. {
  511. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  512. {
  513. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  514. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  515. selectPermanentEffect.SetUp(
  516. selectPlayer: card.Owner,
  517. canTargetCondition: CanSelectPermanentCondition,
  518. canTargetCondition_ByPreSelecetedList: null,
  519. canEndSelectCondition: null,
  520. maxCount: maxCount,
  521. canNoSelect: false,
  522. canEndNotMax: false,
  523. selectPermanentCoroutine: null,
  524. afterSelectPermanentCoroutine: null,
  525. mode: SelectPermanentEffect.Mode.Bounce,
  526. cardEffect: activateClass);
  527. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  528. }
  529. }
  530. }
  531. #endregion
  532. return cardEffects;
  533. }
  534. }
  535. }