EX3_013.cs 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX3
  6. {
  7. public class EX3_013 : 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.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.CardNames.Contains("Machinedramon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. if (timing == EffectTiming.OnEnterFieldAnyone)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("Place cards in digivolution cards to De-Digivolve", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  25. cardEffects.Add(activateClass);
  26. string EffectDiscription()
  27. {
  28. return "[On Play] By placing up to 3 red and black level 5 cards with [Cyborg] in their traits and different card numbers from your hand and trash under this Digimon as its bottom digivolution cards, <De-Digivolve 1> 1 of your opponent's Digimon for each card placed by this effect.";
  29. }
  30. bool CanSelectCardCondition(CardSource cardSource)
  31. {
  32. if (cardSource.IsDigimon)
  33. {
  34. if (cardSource.Level == 5 && cardSource.HasLevel)
  35. {
  36. if (cardSource.CardTraits.Contains("Cyborg"))
  37. {
  38. if (cardSource.HasCardColor(CardColor.Red))
  39. {
  40. return true;
  41. }
  42. if (cardSource.HasCardColor(CardColor.Black))
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanSelectPermanentCondition(Permanent permanent)
  52. {
  53. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  54. }
  55. bool CanUseCondition(Hashtable hashtable)
  56. {
  57. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  58. }
  59. bool CanActivateCondition(Hashtable hashtable)
  60. {
  61. if (CardEffectCommons.IsExistOnBattleArea(card))
  62. {
  63. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  64. {
  65. return true;
  66. }
  67. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  68. {
  69. return true;
  70. }
  71. }
  72. return false;
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  75. {
  76. if (CardEffectCommons.IsExistOnBattleArea(card))
  77. {
  78. int digivolutionCardsCount = 0;
  79. List<CardSource> digivolutionCards = new List<CardSource>();
  80. bool CanSelectCardCondition1(CardSource cardSource)
  81. {
  82. if (CanSelectCardCondition(cardSource))
  83. {
  84. if (digivolutionCards.Count((cardSource1) => cardSource1.CardID == cardSource.CardID) == 0)
  85. {
  86. return true;
  87. }
  88. }
  89. return false;
  90. }
  91. if (card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition1(cardSource)) >= 1)
  92. {
  93. List<CardSource> selectedCards = new List<CardSource>();
  94. int maxCount = Math.Min(3, card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition1(cardSource)));
  95. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  96. selectHandEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: CanSelectCardCondition1,
  99. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  100. canEndSelectCondition: CanEndSelectCondition,
  101. maxCount: maxCount,
  102. canNoSelect: true,
  103. canEndNotMax: true,
  104. isShowOpponent: true,
  105. selectCardCoroutine: SelectCardCoroutine,
  106. afterSelectCardCoroutine: null,
  107. mode: SelectHandEffect.Mode.Custom,
  108. cardEffect: activateClass);
  109. selectHandEffect.SetUpCustomMessage("Select cards to place in Digivolution cards.", "The opponent is selecting cards.");
  110. yield return StartCoroutine(selectHandEffect.Activate());
  111. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  112. {
  113. List<string> cardIDs = new List<string>();
  114. foreach (CardSource cardSource1 in cardSources)
  115. {
  116. if (!cardIDs.Contains(cardSource1.CardID))
  117. {
  118. cardIDs.Add(cardSource1.CardID);
  119. }
  120. }
  121. if (cardIDs.Contains(cardSource.CardID))
  122. {
  123. return false;
  124. }
  125. return true;
  126. }
  127. bool CanEndSelectCondition(List<CardSource> cardSources)
  128. {
  129. List<string> cardIDs = new List<string>();
  130. foreach (CardSource cardSource1 in cardSources)
  131. {
  132. if (!cardIDs.Contains(cardSource1.CardID))
  133. {
  134. cardIDs.Add(cardSource1.CardID);
  135. }
  136. }
  137. if (cardIDs.Count != cardSources.Count)
  138. {
  139. return false;
  140. }
  141. return true;
  142. }
  143. IEnumerator SelectCardCoroutine(CardSource cardSource)
  144. {
  145. selectedCards.Add(cardSource);
  146. digivolutionCards.Add(cardSource);
  147. yield return null;
  148. }
  149. if (selectedCards.Count >= 1)
  150. {
  151. foreach (CardSource selectedCard in selectedCards)
  152. {
  153. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(selectedCard));
  154. }
  155. }
  156. }
  157. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition1(cardSource)))
  158. {
  159. List<CardSource> selectedCards = new List<CardSource>();
  160. int maxCount = Math.Min(3 - digivolutionCards.Count, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition1(cardSource)));
  161. if (maxCount >= 1)
  162. {
  163. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  164. selectCardEffect.SetUp(
  165. canTargetCondition: CanSelectCardCondition1,
  166. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  167. canEndSelectCondition: CanEndSelectCondition,
  168. canNoSelect: () => true,
  169. selectCardCoroutine: SelectCardCoroutine,
  170. afterSelectCardCoroutine: null,
  171. message: "Select cards to place in Digivolution cards.",
  172. maxCount: maxCount,
  173. canEndNotMax: true,
  174. isShowOpponent: true,
  175. mode: SelectCardEffect.Mode.Custom,
  176. root: SelectCardEffect.Root.Trash,
  177. customRootCardList: null,
  178. canLookReverseCard: true,
  179. selectPlayer: card.Owner,
  180. cardEffect: activateClass);
  181. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  182. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  183. {
  184. List<string> cardIDs = new List<string>();
  185. foreach (CardSource cardSource1 in cardSources)
  186. {
  187. if (!cardIDs.Contains(cardSource1.CardID))
  188. {
  189. cardIDs.Add(cardSource1.CardID);
  190. }
  191. }
  192. foreach (CardSource cardSource1 in digivolutionCards)
  193. {
  194. if (!cardIDs.Contains(cardSource1.CardID))
  195. {
  196. cardIDs.Add(cardSource1.CardID);
  197. }
  198. }
  199. if (cardIDs.Contains(cardSource.CardID))
  200. {
  201. return false;
  202. }
  203. return true;
  204. }
  205. bool CanEndSelectCondition(List<CardSource> cardSources)
  206. {
  207. List<string> cardIDs = new List<string>();
  208. foreach (CardSource cardSource1 in cardSources)
  209. {
  210. if (!cardIDs.Contains(cardSource1.CardID))
  211. {
  212. cardIDs.Add(cardSource1.CardID);
  213. }
  214. }
  215. foreach (CardSource cardSource1 in digivolutionCards)
  216. {
  217. if (!cardIDs.Contains(cardSource1.CardID))
  218. {
  219. cardIDs.Add(cardSource1.CardID);
  220. }
  221. }
  222. if (cardIDs.Count != cardSources.Count + digivolutionCards.Count)
  223. {
  224. return false;
  225. }
  226. return true;
  227. }
  228. IEnumerator SelectCardCoroutine(CardSource cardSource)
  229. {
  230. selectedCards.Add(cardSource);
  231. digivolutionCards.Add(cardSource);
  232. yield return null;
  233. }
  234. if (selectedCards.Count >= 1)
  235. {
  236. foreach (CardSource selectedCard in selectedCards)
  237. {
  238. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(selectedCard));
  239. }
  240. }
  241. }
  242. }
  243. if (digivolutionCards.Count >= 1)
  244. {
  245. List<CardSource> digivolutionCards_fixed = new List<CardSource>();
  246. if (digivolutionCards.Count == 1)
  247. {
  248. foreach (CardSource cardSource in digivolutionCards)
  249. {
  250. digivolutionCards_fixed.Add(cardSource);
  251. }
  252. }
  253. else
  254. {
  255. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  256. selectCardEffect.SetUp(
  257. canTargetCondition: (cardSource) => true,
  258. canTargetCondition_ByPreSelecetedList: null,
  259. canEndSelectCondition: null,
  260. canNoSelect: () => false,
  261. selectCardCoroutine: null,
  262. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  263. message: "Specify the order to place the cards in the digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  264. maxCount: digivolutionCards.Count,
  265. canEndNotMax: false,
  266. isShowOpponent: false,
  267. mode: SelectCardEffect.Mode.Custom,
  268. root: SelectCardEffect.Root.Custom,
  269. customRootCardList: digivolutionCards,
  270. canLookReverseCard: true,
  271. selectPlayer: card.Owner,
  272. cardEffect: activateClass);
  273. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  274. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  275. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  276. {
  277. foreach (CardSource cardSource in cardSources)
  278. {
  279. digivolutionCards_fixed.Add(cardSource);
  280. }
  281. yield return null;
  282. }
  283. }
  284. if (CardEffectCommons.IsExistOnBattleArea(card))
  285. {
  286. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(digivolutionCards_fixed, activateClass));
  287. if (digivolutionCards_fixed.Count >= 1)
  288. {
  289. digivolutionCardsCount = digivolutionCards_fixed.Count;
  290. }
  291. }
  292. }
  293. if (digivolutionCardsCount >= 1)
  294. {
  295. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  296. {
  297. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  298. List<Permanent> selectedPermanents = new List<Permanent>();
  299. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  300. selectPermanentEffect.SetUp(
  301. selectPlayer: card.Owner,
  302. canTargetCondition: CanSelectPermanentCondition,
  303. canTargetCondition_ByPreSelecetedList: null,
  304. canEndSelectCondition: null,
  305. maxCount: maxCount,
  306. canNoSelect: false,
  307. canEndNotMax: false,
  308. selectPermanentCoroutine: SelectPermanentCoroutine,
  309. afterSelectPermanentCoroutine: null,
  310. mode: SelectPermanentEffect.Mode.Custom,
  311. cardEffect: activateClass);
  312. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  313. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  314. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  315. {
  316. selectedPermanents.Add(permanent);
  317. yield return null;
  318. }
  319. foreach (Permanent selectedPermanent in selectedPermanents)
  320. {
  321. for (int i = 0; i < digivolutionCardsCount; i++)
  322. {
  323. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(
  324. selectedPermanent,
  325. 1,
  326. activateClass).Degeneration());
  327. }
  328. }
  329. }
  330. }
  331. }
  332. }
  333. }
  334. if (timing == EffectTiming.OnEnterFieldAnyone)
  335. {
  336. ActivateClass activateClass = new ActivateClass();
  337. activateClass.SetUpICardEffect("Place cards in digivolution cards to De-Digivolve", CanUseCondition, card);
  338. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  339. cardEffects.Add(activateClass);
  340. string EffectDiscription()
  341. {
  342. return "[When Digivolving] By placing up to 3 red and black level 5 cards with [Cyborg] in their traits and different card numbers from your hand and trash under this Digimon as its bottom digivolution cards, <De-Digivolve 1> 1 of your opponent's Digimon for each card placed by this effect.";
  343. }
  344. bool CanSelectCardCondition(CardSource cardSource)
  345. {
  346. if (cardSource.IsDigimon)
  347. {
  348. if (cardSource.Level == 5 && cardSource.HasLevel)
  349. {
  350. if (cardSource.CardTraits.Contains("Cyborg"))
  351. {
  352. if (cardSource.HasCardColor(CardColor.Red))
  353. {
  354. return true;
  355. }
  356. if (cardSource.HasCardColor(CardColor.Black))
  357. {
  358. return true;
  359. }
  360. }
  361. }
  362. }
  363. return false;
  364. }
  365. bool CanSelectPermanentCondition(Permanent permanent)
  366. {
  367. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  368. }
  369. bool CanUseCondition(Hashtable hashtable)
  370. {
  371. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  372. }
  373. bool CanActivateCondition(Hashtable hashtable)
  374. {
  375. if (CardEffectCommons.IsExistOnBattleArea(card))
  376. {
  377. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  378. {
  379. return true;
  380. }
  381. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  382. {
  383. return true;
  384. }
  385. }
  386. return false;
  387. }
  388. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  389. {
  390. if (CardEffectCommons.IsExistOnBattleArea(card))
  391. {
  392. int digivolutionCardsCount = 0;
  393. List<CardSource> digivolutionCards = new List<CardSource>();
  394. bool CanSelectCardCondition1(CardSource cardSource)
  395. {
  396. if (CanSelectCardCondition(cardSource))
  397. {
  398. if (digivolutionCards.Count((cardSource1) => cardSource1.CardID == cardSource.CardID) == 0)
  399. {
  400. return true;
  401. }
  402. }
  403. return false;
  404. }
  405. if (card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition1(cardSource)) >= 1)
  406. {
  407. List<CardSource> selectedCards = new List<CardSource>();
  408. int maxCount = Math.Min(3, card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition1(cardSource)));
  409. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  410. selectHandEffect.SetUp(
  411. selectPlayer: card.Owner,
  412. canTargetCondition: CanSelectCardCondition1,
  413. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  414. canEndSelectCondition: CanEndSelectCondition,
  415. maxCount: maxCount,
  416. canNoSelect: true,
  417. canEndNotMax: true,
  418. isShowOpponent: true,
  419. selectCardCoroutine: SelectCardCoroutine,
  420. afterSelectCardCoroutine: null,
  421. mode: SelectHandEffect.Mode.Custom,
  422. cardEffect: activateClass);
  423. selectHandEffect.SetUpCustomMessage("Select cards to place in Digivolution cards.", "The opponent is selecting cards.");
  424. yield return StartCoroutine(selectHandEffect.Activate());
  425. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  426. {
  427. List<string> cardIDs = new List<string>();
  428. foreach (CardSource cardSource1 in cardSources)
  429. {
  430. if (!cardIDs.Contains(cardSource1.CardID))
  431. {
  432. cardIDs.Add(cardSource1.CardID);
  433. }
  434. }
  435. if (cardIDs.Contains(cardSource.CardID))
  436. {
  437. return false;
  438. }
  439. return true;
  440. }
  441. bool CanEndSelectCondition(List<CardSource> cardSources)
  442. {
  443. List<string> cardIDs = new List<string>();
  444. foreach (CardSource cardSource1 in cardSources)
  445. {
  446. if (!cardIDs.Contains(cardSource1.CardID))
  447. {
  448. cardIDs.Add(cardSource1.CardID);
  449. }
  450. }
  451. if (cardIDs.Count != cardSources.Count)
  452. {
  453. return false;
  454. }
  455. return true;
  456. }
  457. IEnumerator SelectCardCoroutine(CardSource cardSource)
  458. {
  459. selectedCards.Add(cardSource);
  460. digivolutionCards.Add(cardSource);
  461. yield return null;
  462. }
  463. if (selectedCards.Count >= 1)
  464. {
  465. foreach (CardSource selectedCard in selectedCards)
  466. {
  467. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(selectedCard));
  468. }
  469. }
  470. }
  471. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition1(cardSource)))
  472. {
  473. List<CardSource> selectedCards = new List<CardSource>();
  474. int maxCount = Math.Min(3 - digivolutionCards.Count, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition1(cardSource)));
  475. if (maxCount >= 1)
  476. {
  477. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  478. selectCardEffect.SetUp(
  479. canTargetCondition: CanSelectCardCondition1,
  480. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  481. canEndSelectCondition: CanEndSelectCondition,
  482. canNoSelect: () => true,
  483. selectCardCoroutine: SelectCardCoroutine,
  484. afterSelectCardCoroutine: null,
  485. message: "Select cards to place in Digivolution cards.",
  486. maxCount: maxCount,
  487. canEndNotMax: true,
  488. isShowOpponent: true,
  489. mode: SelectCardEffect.Mode.Custom,
  490. root: SelectCardEffect.Root.Trash,
  491. customRootCardList: null,
  492. canLookReverseCard: true,
  493. selectPlayer: card.Owner,
  494. cardEffect: activateClass);
  495. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  496. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  497. {
  498. List<string> cardIDs = new List<string>();
  499. foreach (CardSource cardSource1 in cardSources)
  500. {
  501. if (!cardIDs.Contains(cardSource1.CardID))
  502. {
  503. cardIDs.Add(cardSource1.CardID);
  504. }
  505. }
  506. foreach (CardSource cardSource1 in digivolutionCards)
  507. {
  508. if (!cardIDs.Contains(cardSource1.CardID))
  509. {
  510. cardIDs.Add(cardSource1.CardID);
  511. }
  512. }
  513. if (cardIDs.Contains(cardSource.CardID))
  514. {
  515. return false;
  516. }
  517. return true;
  518. }
  519. bool CanEndSelectCondition(List<CardSource> cardSources)
  520. {
  521. List<string> cardIDs = new List<string>();
  522. foreach (CardSource cardSource1 in cardSources)
  523. {
  524. if (!cardIDs.Contains(cardSource1.CardID))
  525. {
  526. cardIDs.Add(cardSource1.CardID);
  527. }
  528. }
  529. foreach (CardSource cardSource1 in digivolutionCards)
  530. {
  531. if (!cardIDs.Contains(cardSource1.CardID))
  532. {
  533. cardIDs.Add(cardSource1.CardID);
  534. }
  535. }
  536. if (cardIDs.Count != cardSources.Count + digivolutionCards.Count)
  537. {
  538. return false;
  539. }
  540. return true;
  541. }
  542. IEnumerator SelectCardCoroutine(CardSource cardSource)
  543. {
  544. selectedCards.Add(cardSource);
  545. digivolutionCards.Add(cardSource);
  546. yield return null;
  547. }
  548. if (selectedCards.Count >= 1)
  549. {
  550. foreach (CardSource selectedCard in selectedCards)
  551. {
  552. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(selectedCard));
  553. }
  554. }
  555. }
  556. }
  557. if (digivolutionCards.Count >= 1)
  558. {
  559. List<CardSource> digivolutionCards_fixed = new List<CardSource>();
  560. if (digivolutionCards.Count == 1)
  561. {
  562. foreach (CardSource cardSource in digivolutionCards)
  563. {
  564. digivolutionCards_fixed.Add(cardSource);
  565. }
  566. }
  567. else
  568. {
  569. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  570. selectCardEffect.SetUp(
  571. canTargetCondition: (cardSource) => true,
  572. canTargetCondition_ByPreSelecetedList: null,
  573. canEndSelectCondition: null,
  574. canNoSelect: () => false,
  575. selectCardCoroutine: null,
  576. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  577. message: "Specify the order to place the cards in the digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  578. maxCount: digivolutionCards.Count,
  579. canEndNotMax: false,
  580. isShowOpponent: false,
  581. mode: SelectCardEffect.Mode.Custom,
  582. root: SelectCardEffect.Root.Custom,
  583. customRootCardList: digivolutionCards,
  584. canLookReverseCard: true,
  585. selectPlayer: card.Owner,
  586. cardEffect: activateClass);
  587. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  588. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  589. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  590. {
  591. foreach (CardSource cardSource in cardSources)
  592. {
  593. digivolutionCards_fixed.Add(cardSource);
  594. }
  595. yield return null;
  596. }
  597. }
  598. if (CardEffectCommons.IsExistOnBattleArea(card))
  599. {
  600. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(digivolutionCards_fixed, activateClass));
  601. if (digivolutionCards_fixed.Count >= 1)
  602. {
  603. digivolutionCardsCount = digivolutionCards_fixed.Count;
  604. }
  605. }
  606. }
  607. if (digivolutionCardsCount >= 1)
  608. {
  609. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  610. {
  611. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  612. List<Permanent> selectedPermanents = new List<Permanent>();
  613. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  614. selectPermanentEffect.SetUp(
  615. selectPlayer: card.Owner,
  616. canTargetCondition: CanSelectPermanentCondition,
  617. canTargetCondition_ByPreSelecetedList: null,
  618. canEndSelectCondition: null,
  619. maxCount: maxCount,
  620. canNoSelect: false,
  621. canEndNotMax: false,
  622. selectPermanentCoroutine: SelectPermanentCoroutine,
  623. afterSelectPermanentCoroutine: null,
  624. mode: SelectPermanentEffect.Mode.Custom,
  625. cardEffect: activateClass);
  626. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  627. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  628. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  629. {
  630. selectedPermanents.Add(permanent);
  631. yield return null;
  632. }
  633. foreach (Permanent selectedPermanent in selectedPermanents)
  634. {
  635. for (int i = 0; i < digivolutionCardsCount; i++)
  636. {
  637. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(
  638. selectedPermanent,
  639. 1,
  640. activateClass).Degeneration());
  641. }
  642. }
  643. }
  644. }
  645. }
  646. }
  647. }
  648. if (timing == EffectTiming.WhenPermanentWouldBeDeleted || timing == EffectTiming.WhenReturntoHandAnyone || timing == EffectTiming.WhenReturntoLibraryAnyone)
  649. {
  650. ActivateClass activateClass = new ActivateClass();
  651. activateClass.SetUpICardEffect("Prevent this Digimon from being deleted or returned to hand or deck", CanUseCondition, card);
  652. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  653. activateClass.SetHashString("Substitute_EX3_013");
  654. cardEffects.Add(activateClass);
  655. string EffectDiscription()
  656. {
  657. return "[All Turns] When this Digimon would be deleted or returned to your hand or deck, you may trash 2 level 5 cards in this Digimon's digivolution cards to prevent it from leaving play.";
  658. }
  659. bool CanSelectCardCondition(CardSource cardSource)
  660. {
  661. if (cardSource.Level == 5)
  662. {
  663. if (!cardSource.CanNotTrashFromDigivolutionCards(activateClass))
  664. {
  665. if (cardSource.HasLevel)
  666. {
  667. return true;
  668. }
  669. }
  670. }
  671. return false;
  672. }
  673. bool CanUseCondition(Hashtable hashtable)
  674. {
  675. if (CardEffectCommons.IsExistOnBattleArea(card))
  676. {
  677. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  678. {
  679. return true;
  680. }
  681. }
  682. return false;
  683. }
  684. bool CanActivateCondition(Hashtable hashtable)
  685. {
  686. if (CardEffectCommons.IsExistOnBattleArea(card))
  687. {
  688. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 2)
  689. {
  690. return true;
  691. }
  692. }
  693. return false;
  694. }
  695. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  696. {
  697. if (CardEffectCommons.IsExistOnBattleArea(card))
  698. {
  699. Permanent selectedPermanent = card.PermanentOfThisCard();
  700. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 2)
  701. {
  702. List<CardSource> selectedCards = new List<CardSource>();
  703. int maxCount = Math.Min(2, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  704. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  705. selectCardEffect.SetUp(
  706. canTargetCondition: CanSelectCardCondition,
  707. canTargetCondition_ByPreSelecetedList: null,
  708. canEndSelectCondition: null,
  709. canNoSelect: () => true,
  710. selectCardCoroutine: SelectCardCoroutine,
  711. afterSelectCardCoroutine: null,
  712. message: "Select cards to discard.",
  713. maxCount: maxCount,
  714. canEndNotMax: false,
  715. isShowOpponent: true,
  716. mode: SelectCardEffect.Mode.Custom,
  717. root: SelectCardEffect.Root.Custom,
  718. customRootCardList: selectedPermanent.DigivolutionCards,
  719. canLookReverseCard: true,
  720. selectPlayer: card.Owner,
  721. cardEffect: activateClass);
  722. selectCardEffect.SetNotShowCard();
  723. yield return StartCoroutine(selectCardEffect.Activate());
  724. IEnumerator SelectCardCoroutine(CardSource cardSource)
  725. {
  726. selectedCards.Add(cardSource);
  727. yield return null;
  728. }
  729. if (selectedCards.Count >= 1)
  730. {
  731. if (selectedCards.Count == 2)
  732. {
  733. selectedPermanent.willBeRemoveField = false;
  734. selectedPermanent.HideDeleteEffect();
  735. selectedPermanent.HideHandBounceEffect();
  736. selectedPermanent.HideDeckBounceEffect();
  737. }
  738. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(selectedPermanent, selectedCards, activateClass).TrashDigivolutionCards());
  739. }
  740. }
  741. }
  742. }
  743. }
  744. return cardEffects;
  745. }
  746. }
  747. }