BT12_111.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_111 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Delete 1 Digimon and place cards from trash under this Digimon's digivolution cards", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] Delete 1 of your opponent's Digimon. Then, you may place up to 5 Digimon cards with a [Bagra Army] trait from your trash into this Digimon's digivolution cards.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  25. }
  26. bool CanSelectCardCondition(CardSource cardSource)
  27. {
  28. if (cardSource.IsDigimon)
  29. {
  30. if (cardSource.CardTraits.Contains("Bagra Army"))
  31. {
  32. return true;
  33. }
  34. if (cardSource.CardTraits.Contains("BagraArmy"))
  35. {
  36. return true;
  37. }
  38. }
  39. return false;
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsExistOnBattleArea(card))
  48. {
  49. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  50. {
  51. return true;
  52. }
  53. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  54. {
  55. return true;
  56. }
  57. }
  58. return false;
  59. }
  60. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  61. {
  62. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  63. {
  64. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  65. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  66. selectPermanentEffect.SetUp(
  67. selectPlayer: card.Owner,
  68. canTargetCondition: CanSelectPermanentCondition,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. maxCount: maxCount,
  72. canNoSelect: false,
  73. canEndNotMax: false,
  74. selectPermanentCoroutine: null,
  75. afterSelectPermanentCoroutine: null,
  76. mode: SelectPermanentEffect.Mode.Destroy,
  77. cardEffect: activateClass);
  78. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  79. }
  80. if (CardEffectCommons.IsExistOnBattleArea(card))
  81. {
  82. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  83. {
  84. List<CardSource> selectedCards = new List<CardSource>();
  85. int maxCount = Math.Min(5, card.Owner.TrashCards.Count(CanSelectCardCondition));
  86. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  87. selectCardEffect.SetUp(
  88. canTargetCondition: CanSelectCardCondition,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: CanEndSelectCondition,
  91. canNoSelect: () => true,
  92. selectCardCoroutine: SelectCardCoroutine,
  93. afterSelectCardCoroutine: null,
  94. message: "Select cards to place in Digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  95. maxCount: maxCount,
  96. canEndNotMax: true,
  97. isShowOpponent: true,
  98. mode: SelectCardEffect.Mode.Custom,
  99. root: SelectCardEffect.Root.Trash,
  100. customRootCardList: null,
  101. canLookReverseCard: true,
  102. selectPlayer: card.Owner,
  103. cardEffect: activateClass);
  104. selectCardEffect.SetUpCustomMessage("Select cards to place in Digivolution cards.", "The opponent is selecting cards to place in Digivolution cards.");
  105. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  106. yield return StartCoroutine(selectCardEffect.Activate());
  107. bool CanEndSelectCondition(List<CardSource> cardSources)
  108. {
  109. if (CardEffectCommons.HasNoElement(cardSources))
  110. {
  111. return false;
  112. }
  113. return true;
  114. }
  115. IEnumerator SelectCardCoroutine(CardSource cardSource)
  116. {
  117. selectedCards.Add(cardSource);
  118. yield return null;
  119. }
  120. List<CardSource> digivolutionCards = new List<CardSource>();
  121. foreach (CardSource cardSource in selectedCards)
  122. {
  123. digivolutionCards.Add(cardSource);
  124. }
  125. if (digivolutionCards.Count >= 1)
  126. {
  127. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(digivolutionCards, activateClass));
  128. }
  129. }
  130. }
  131. }
  132. }
  133. if (timing == EffectTiming.OnEnterFieldAnyone)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect("Delete 1 Digimon and place cards from trash under this Digimon's digivolution cards", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  138. cardEffects.Add(activateClass);
  139. string EffectDiscription()
  140. {
  141. return "[When Digivolving] Delete 1 of your opponent's Digimon. Then, you may place up to 5 Digimon cards with a [Bagra Army] trait from your trash into this Digimon's digivolution cards.";
  142. }
  143. bool CanSelectPermanentCondition(Permanent permanent)
  144. {
  145. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  146. }
  147. bool CanSelectCardCondition(CardSource cardSource)
  148. {
  149. if (cardSource.IsDigimon)
  150. {
  151. if (cardSource.CardTraits.Contains("Bagra Army"))
  152. {
  153. return true;
  154. }
  155. if (cardSource.CardTraits.Contains("BagraArmy"))
  156. {
  157. return true;
  158. }
  159. }
  160. return false;
  161. }
  162. bool CanUseCondition(Hashtable hashtable)
  163. {
  164. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  165. }
  166. bool CanActivateCondition(Hashtable hashtable)
  167. {
  168. if (CardEffectCommons.IsExistOnBattleArea(card))
  169. {
  170. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  171. {
  172. return true;
  173. }
  174. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  175. {
  176. return true;
  177. }
  178. }
  179. return false;
  180. }
  181. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  182. {
  183. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  184. {
  185. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  186. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  187. selectPermanentEffect.SetUp(
  188. selectPlayer: card.Owner,
  189. canTargetCondition: CanSelectPermanentCondition,
  190. canTargetCondition_ByPreSelecetedList: null,
  191. canEndSelectCondition: null,
  192. maxCount: maxCount,
  193. canNoSelect: false,
  194. canEndNotMax: false,
  195. selectPermanentCoroutine: null,
  196. afterSelectPermanentCoroutine: null,
  197. mode: SelectPermanentEffect.Mode.Destroy,
  198. cardEffect: activateClass);
  199. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  200. }
  201. if (CardEffectCommons.IsExistOnBattleArea(card))
  202. {
  203. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  204. {
  205. List<CardSource> selectedCards = new List<CardSource>();
  206. int maxCount = Math.Min(5, card.Owner.TrashCards.Count(CanSelectCardCondition));
  207. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  208. selectCardEffect.SetUp(
  209. canTargetCondition: CanSelectCardCondition,
  210. canTargetCondition_ByPreSelecetedList: null,
  211. canEndSelectCondition: CanEndSelectCondition,
  212. canNoSelect: () => true,
  213. selectCardCoroutine: SelectCardCoroutine,
  214. afterSelectCardCoroutine: null,
  215. message: "Select cards to place in Digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  216. maxCount: maxCount,
  217. canEndNotMax: true,
  218. isShowOpponent: true,
  219. mode: SelectCardEffect.Mode.Custom,
  220. root: SelectCardEffect.Root.Trash,
  221. customRootCardList: null,
  222. canLookReverseCard: true,
  223. selectPlayer: card.Owner,
  224. cardEffect: activateClass);
  225. selectCardEffect.SetUpCustomMessage("Select cards to place in Digivolution cards.", "The opponent is selecting cards to place in Digivolution cards.");
  226. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  227. yield return StartCoroutine(selectCardEffect.Activate());
  228. bool CanEndSelectCondition(List<CardSource> cardSources)
  229. {
  230. if (CardEffectCommons.HasNoElement(cardSources))
  231. {
  232. return false;
  233. }
  234. return true;
  235. }
  236. IEnumerator SelectCardCoroutine(CardSource cardSource)
  237. {
  238. selectedCards.Add(cardSource);
  239. yield return null;
  240. }
  241. List<CardSource> digivolutionCards = new List<CardSource>();
  242. foreach (CardSource cardSource in selectedCards)
  243. {
  244. digivolutionCards.Add(cardSource);
  245. }
  246. if (digivolutionCards.Count >= 1)
  247. {
  248. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(digivolutionCards, activateClass));
  249. }
  250. }
  251. }
  252. }
  253. }
  254. if (timing == EffectTiming.OnEnterFieldAnyone)
  255. {
  256. ActivateClass activateClass = new ActivateClass();
  257. activateClass.SetUpICardEffect("Return all Tamers to hand", CanUseCondition, card);
  258. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  259. cardEffects.Add(activateClass);
  260. string EffectDiscription()
  261. {
  262. return "[Opponent's Turn] If an opponent's Digimon digivolves or attacks, by trashing 5 cards in this Digimon's digivolution cards, return all Tamers to their owners' hands.";
  263. }
  264. bool PermanentCondition(Permanent permanent)
  265. {
  266. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  267. }
  268. bool CanSelectCardCondition(CardSource cardSource)
  269. {
  270. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  271. }
  272. bool CanSelectPermanentCondition(Permanent permanent)
  273. {
  274. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  275. {
  276. if (permanent.IsTamer)
  277. {
  278. return true;
  279. }
  280. }
  281. return false;
  282. }
  283. bool CanUseCondition(Hashtable hashtable)
  284. {
  285. if (CardEffectCommons.IsExistOnBattleArea(card))
  286. {
  287. if (CardEffectCommons.IsOpponentTurn(card))
  288. {
  289. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition))
  290. {
  291. return true;
  292. }
  293. }
  294. }
  295. return false;
  296. }
  297. bool CanActivateCondition(Hashtable hashtable)
  298. {
  299. if (CardEffectCommons.IsExistOnBattleArea(card))
  300. {
  301. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 5)
  302. {
  303. return true;
  304. }
  305. }
  306. return false;
  307. }
  308. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  309. {
  310. bool trashed = false;
  311. List<CardSource> selectedCards = new List<CardSource>();
  312. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  313. selectCardEffect.SetUp(
  314. canTargetCondition: CanSelectCardCondition,
  315. canTargetCondition_ByPreSelecetedList: null,
  316. canEndSelectCondition: null,
  317. canNoSelect: () => true,
  318. selectCardCoroutine: SelectCardCoroutine,
  319. afterSelectCardCoroutine: null,
  320. message: "Select digivolution cards to discard.",
  321. maxCount: 5,
  322. canEndNotMax: false,
  323. isShowOpponent: true,
  324. mode: SelectCardEffect.Mode.Custom,
  325. root: SelectCardEffect.Root.Custom,
  326. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  327. canLookReverseCard: true,
  328. selectPlayer: card.Owner,
  329. cardEffect: null);
  330. selectCardEffect.SetUpCustomMessage("Select digivolution cards to discard.", "The opponent is selecting digivolution cards to discard.");
  331. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  332. IEnumerator SelectCardCoroutine(CardSource cardSource)
  333. {
  334. selectedCards.Add(cardSource);
  335. yield return null;
  336. }
  337. if (selectedCards.Count >= 1)
  338. {
  339. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(card.PermanentOfThisCard(), selectedCards, activateClass).TrashDigivolutionCards());
  340. trashed = true;
  341. }
  342. if (trashed)
  343. {
  344. List<Permanent> bouncedPermanetns = new List<Permanent>();
  345. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  346. {
  347. foreach (Permanent permanent in player.GetBattleAreaPermanents())
  348. {
  349. if (CanSelectPermanentCondition(permanent))
  350. {
  351. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  352. {
  353. if (!permanent.CannotReturnToHand(activateClass))
  354. {
  355. bouncedPermanetns.Add(permanent);
  356. }
  357. }
  358. }
  359. }
  360. }
  361. if (bouncedPermanetns.Count >= 1)
  362. {
  363. yield return ContinuousController.instance.StartCoroutine(new HandBounceClaass(bouncedPermanetns, CardEffectCommons.CardEffectHashtable(activateClass)).Bounce());
  364. }
  365. }
  366. }
  367. }
  368. if (timing == EffectTiming.OnAllyAttack)
  369. {
  370. ActivateClass activateClass = new ActivateClass();
  371. activateClass.SetUpICardEffect("Return all Tamers to hand", CanUseCondition, card);
  372. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  373. cardEffects.Add(activateClass);
  374. string EffectDiscription()
  375. {
  376. return "[Opponent's Turn] If an opponent's Digimon digivolves or attacks, by trashing 5 cards in this Digimon's digivolution cards, return all Tamers to their owners' hands.";
  377. }
  378. bool PermanentCondition(Permanent permanent)
  379. {
  380. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  381. }
  382. bool CanSelectCardCondition(CardSource cardSource)
  383. {
  384. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  385. }
  386. bool CanSelectPermanentCondition(Permanent permanent)
  387. {
  388. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  389. {
  390. if (permanent.IsTamer)
  391. {
  392. return true;
  393. }
  394. }
  395. return false;
  396. }
  397. bool CanUseCondition(Hashtable hashtable)
  398. {
  399. if (CardEffectCommons.IsExistOnBattleArea(card))
  400. {
  401. if (CardEffectCommons.IsOpponentTurn(card))
  402. {
  403. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  404. {
  405. return true;
  406. }
  407. }
  408. }
  409. return false;
  410. }
  411. bool CanActivateCondition(Hashtable hashtable)
  412. {
  413. if (CardEffectCommons.IsExistOnBattleArea(card))
  414. {
  415. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 5)
  416. {
  417. return true;
  418. }
  419. }
  420. return false;
  421. }
  422. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  423. {
  424. bool trashed = false;
  425. List<CardSource> selectedCards = new List<CardSource>();
  426. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  427. selectCardEffect.SetUp(
  428. canTargetCondition: CanSelectCardCondition,
  429. canTargetCondition_ByPreSelecetedList: null,
  430. canEndSelectCondition: null,
  431. canNoSelect: () => true,
  432. selectCardCoroutine: SelectCardCoroutine,
  433. afterSelectCardCoroutine: null,
  434. message: "Select digivolution cards to discard.",
  435. maxCount: 5,
  436. canEndNotMax: false,
  437. isShowOpponent: true,
  438. mode: SelectCardEffect.Mode.Custom,
  439. root: SelectCardEffect.Root.Custom,
  440. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  441. canLookReverseCard: true,
  442. selectPlayer: card.Owner,
  443. cardEffect: null);
  444. selectCardEffect.SetUpCustomMessage("Select digivolution cards to discard.", "The opponent is selecting digivolution cards to discard.");
  445. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  446. IEnumerator SelectCardCoroutine(CardSource cardSource)
  447. {
  448. selectedCards.Add(cardSource);
  449. yield return null;
  450. }
  451. if (selectedCards.Count >= 1)
  452. {
  453. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(card.PermanentOfThisCard(), selectedCards, activateClass).TrashDigivolutionCards());
  454. trashed = true;
  455. }
  456. if (trashed)
  457. {
  458. List<Permanent> bouncedPermanetns = new List<Permanent>();
  459. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  460. {
  461. foreach (Permanent permanent in player.GetBattleAreaPermanents())
  462. {
  463. if (CanSelectPermanentCondition(permanent))
  464. {
  465. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  466. {
  467. if (!permanent.CannotReturnToHand(activateClass))
  468. {
  469. bouncedPermanetns.Add(permanent);
  470. }
  471. }
  472. }
  473. }
  474. }
  475. if (bouncedPermanetns.Count >= 1)
  476. {
  477. yield return ContinuousController.instance.StartCoroutine(new HandBounceClaass(bouncedPermanetns, CardEffectCommons.CardEffectHashtable(activateClass)).Bounce());
  478. }
  479. }
  480. }
  481. }
  482. if (timing == EffectTiming.None)
  483. {
  484. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  485. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  486. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  487. addDigiXrosConditionClass.SetNotShowUI(true);
  488. cardEffects.Add(addDigiXrosConditionClass);
  489. bool CanUseCondition(Hashtable hashtable)
  490. {
  491. return true;
  492. }
  493. DigiXrosCondition GetDigiXros(CardSource cardSource)
  494. {
  495. if (cardSource == card)
  496. {
  497. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "DarkKnightmon");
  498. bool CanSelectCardCondition(CardSource cardSource)
  499. {
  500. if (cardSource != null)
  501. {
  502. if (cardSource.Owner == card.Owner)
  503. {
  504. if (cardSource.IsDigimon)
  505. {
  506. if (cardSource.CardNames_DigiXros.Contains("DarkKnightmon"))
  507. {
  508. return true;
  509. }
  510. }
  511. }
  512. }
  513. return false;
  514. }
  515. DigiXrosConditionElement element1 = new DigiXrosConditionElement(CanSelectCardCondition1, "Bagramon");
  516. bool CanSelectCardCondition1(CardSource cardSource)
  517. {
  518. if (cardSource != null)
  519. {
  520. if (cardSource.Owner == card.Owner)
  521. {
  522. if (cardSource.IsDigimon)
  523. {
  524. if (cardSource.CardNames_DigiXros.Contains("Bagramon"))
  525. {
  526. return true;
  527. }
  528. }
  529. }
  530. }
  531. return false;
  532. }
  533. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element, element1 };
  534. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 3);
  535. return digiXrosCondition;
  536. }
  537. return null;
  538. }
  539. }
  540. return cardEffects;
  541. }
  542. }
  543. }