EX9_073.cs 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Machinedramon
  5. namespace DCGO.CardEffects.EX9
  6. {
  7. public class EX9_073 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.EqualsTraits("DM");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 3,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region Assembly
  29. if (timing == EffectTiming.None)
  30. {
  31. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  32. addAssemblyConditionClass.SetUpICardEffect($"Assembly", CanUseCondition, card);
  33. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  34. addAssemblyConditionClass.SetNotShowUI(true);
  35. cardEffects.Add(addAssemblyConditionClass);
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return true;
  39. }
  40. AssemblyCondition GetAssembly(CardSource cardSource)
  41. {
  42. if (cardSource == card)
  43. {
  44. AssemblyConditionElement element = new AssemblyConditionElement(CanSelectCardCondition);
  45. bool CanSelectCardCondition(CardSource cardSource)
  46. {
  47. if (cardSource != null)
  48. {
  49. if (cardSource.Owner == card.Owner)
  50. {
  51. if (cardSource.IsDigimon)
  52. {
  53. if (cardSource.IsLevel5)
  54. {
  55. if (cardSource.EqualsTraits("Cyborg"))
  56. {
  57. return true;
  58. }
  59. }
  60. }
  61. }
  62. }
  63. return false;
  64. }
  65. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  66. {
  67. List<string> cardNames = new List<string>();
  68. foreach (CardSource cardSource1 in cardSources)
  69. {
  70. foreach (string cardName in cardSource1.CardNames)
  71. {
  72. if (!cardNames.Contains(cardName))
  73. {
  74. cardNames.Add(cardName);
  75. }
  76. }
  77. }
  78. if (cardSource.CardNames.Count((cardName) => cardNames.Contains(cardName)) >= 1)
  79. {
  80. return false;
  81. }
  82. return true;
  83. }
  84. AssemblyCondition assemblyCondition = new AssemblyCondition(
  85. element: element,
  86. CanTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  87. selectMessage: "4 level 5 [Cyborg] trait Digimon cards w/different name",
  88. elementCount: 4,
  89. reduceCost: 6);
  90. return assemblyCondition;
  91. }
  92. return null;
  93. }
  94. }
  95. #endregion
  96. #region On Play/ When Digivolving/ When Attacking Shared
  97. bool CanSelectCardConditionShared(CardSource cardSource)
  98. {
  99. return cardSource.IsLevel5 &&
  100. (cardSource.EqualsTraits("Cyborg") || cardSource.EqualsTraits("Ver.5"));
  101. }
  102. bool CanActivateConditionShared(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  105. (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardConditionShared) ||
  106. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardConditionShared));
  107. }
  108. #endregion
  109. #region On Play
  110. if (timing == EffectTiming.OnEnterFieldAnyone)
  111. {
  112. ActivateClass activateClass = new ActivateClass();
  113. activateClass.SetUpICardEffect("Place 1 card in hand or trash as source, to activate its [On Play] effect",
  114. CanUseCondition, card);
  115. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, 1, true, EffectDescription());
  116. activateClass.SetHashString("AddSource_EX9_073");
  117. cardEffects.Add(activateClass);
  118. string EffectDescription() =>
  119. "[On Play] [Once Per Turn] By placing 1 level 5 [Cyborg] or [Ver.5] trait card from your hand or trash as this Digimon's top digivolution card, active 1 [On Play] effect on the placed card as an effect of this Digimon.";
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  123. }
  124. IEnumerator ActivateCoroutine(Hashtable hashtable)
  125. {
  126. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardConditionShared);
  127. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardConditionShared);
  128. if (canSelectHand && canSelectTrash)
  129. {
  130. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  131. {
  132. new(message: "From hand", value: true, spriteIndex: 0),
  133. new(message: "From trash", value: false, spriteIndex: 1),
  134. };
  135. string selectPlayerMessage = "From which area do you choose a card?";
  136. string notSelectPlayerMessage = "The opponent is choosing from which area to choose a card.";
  137. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  138. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  139. notSelectPlayerMessage: notSelectPlayerMessage);
  140. }
  141. else
  142. {
  143. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  144. }
  145. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  146. .WaitForEndSelect());
  147. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  148. CardSource selectedCard = null;
  149. IEnumerator SelectCardCoroutine(CardSource cardSource)
  150. {
  151. selectedCard = cardSource;
  152. yield return null;
  153. }
  154. if (fromHand)
  155. {
  156. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  157. selectHandEffect.SetUp(
  158. selectPlayer: card.Owner,
  159. canTargetCondition: CanSelectCardConditionShared,
  160. canTargetCondition_ByPreSelecetedList: null,
  161. canEndSelectCondition: null,
  162. maxCount: 1,
  163. canNoSelect: true,
  164. canEndNotMax: false,
  165. isShowOpponent: true,
  166. selectCardCoroutine: SelectCardCoroutine,
  167. afterSelectCardCoroutine: null,
  168. mode: SelectHandEffect.Mode.Custom,
  169. cardEffect: activateClass);
  170. selectHandEffect.SetUpCustomMessage("Select 1 card to place on top of digivolution cards.",
  171. "The opponent is selecting 1 card to place on top of digivolution cards.");
  172. selectHandEffect.SetUpCustomMessage_ShowCard("Placed Card");
  173. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  174. }
  175. else
  176. {
  177. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  178. selectCardEffect.SetUp(
  179. canTargetCondition: CanSelectCardConditionShared,
  180. canTargetCondition_ByPreSelecetedList: null,
  181. canEndSelectCondition: null,
  182. canNoSelect: () => true,
  183. selectCardCoroutine: SelectCardCoroutine,
  184. afterSelectCardCoroutine: null,
  185. message: "Select 1 card to place on top of digivolution cards.",
  186. maxCount: 1,
  187. canEndNotMax: false,
  188. isShowOpponent: true,
  189. mode: SelectCardEffect.Mode.Custom,
  190. root: SelectCardEffect.Root.Trash,
  191. customRootCardList: null,
  192. canLookReverseCard: true,
  193. selectPlayer: card.Owner,
  194. cardEffect: activateClass);
  195. selectCardEffect.SetUpCustomMessage("Select 1 card to place on top of digivolution cards.",
  196. "The opponent is selecting 1 card to place on top of digivolution cards.");
  197. selectCardEffect.SetUpCustomMessage_ShowCard("Placed Card");
  198. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  199. }
  200. if (selectedCard)
  201. {
  202. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard()
  203. .AddDigivolutionCardsTop(new List<CardSource>() { selectedCard }, activateClass));
  204. List<ICardEffect> candidateEffects = selectedCard.cEntity_EffectController.GetCardEffects_ExceptAddedEffects(EffectTiming.OnEnterFieldAnyone, card)
  205. .Clone()
  206. .Filter(cardEffect =>
  207. cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect &&
  208. cardEffect.IsOnPlay);
  209. if (candidateEffects.Count >= 1)
  210. {
  211. ICardEffect selectedEffect = null;
  212. if (candidateEffects.Count == 1)
  213. {
  214. selectedEffect = candidateEffects[0];
  215. }
  216. else
  217. {
  218. List<SkillInfo> skillInfos = candidateEffects
  219. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  220. List<CardSource> cardSources = candidateEffects
  221. .Map(cardEffect => cardEffect.EffectSourceCard);
  222. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  223. selectCardEffect.SetUp(
  224. canTargetCondition: _ => true,
  225. canTargetCondition_ByPreSelecetedList: null,
  226. canEndSelectCondition: null,
  227. canNoSelect: () => false,
  228. selectCardCoroutine: null,
  229. afterSelectCardCoroutine: null,
  230. message: "Select 1 effect to activate.",
  231. maxCount: 1,
  232. canEndNotMax: false,
  233. isShowOpponent: false,
  234. mode: SelectCardEffect.Mode.Custom,
  235. root: SelectCardEffect.Root.Custom,
  236. customRootCardList: cardSources,
  237. canLookReverseCard: true,
  238. selectPlayer: card.Owner,
  239. cardEffect: activateClass);
  240. selectCardEffect.SetNotShowCard();
  241. selectCardEffect.SetUpSkillInfos(skillInfos);
  242. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  243. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  244. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  245. {
  246. if (selectedIndexes.Count == 1)
  247. {
  248. selectedEffect = candidateEffects[selectedIndexes[0]];
  249. yield return null;
  250. }
  251. }
  252. }
  253. if (selectedEffect != null)
  254. {
  255. Hashtable effectHashtable = CardEffectCommons.OnPlayCheckHashtableOfCard(card);
  256. if (selectedEffect.CanUse(effectHashtable))
  257. {
  258. selectedEffect.SetIsDigimonEffect(true);
  259. yield return ContinuousController.instance.StartCoroutine(
  260. ((ActivateICardEffect)selectedEffect)
  261. .Activate_Optional_Effect_Execute(effectHashtable));
  262. }
  263. }
  264. }
  265. }
  266. }
  267. }
  268. #endregion
  269. #region When Digivolving
  270. if (timing == EffectTiming.OnEnterFieldAnyone)
  271. {
  272. ActivateClass activateClass = new ActivateClass();
  273. activateClass.SetUpICardEffect("Place 1 card in hand or trash as source, to activate its [On Play] effect",
  274. CanUseCondition, card);
  275. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, 1, true,
  276. EffectDescription());
  277. activateClass.SetHashString("AddSource_EX9_073");
  278. cardEffects.Add(activateClass);
  279. string EffectDescription() =>
  280. "[When Digivolving] [Once Per Turn] By placing 1 level 5 [Cyborg] or [Ver.5] trait card from your hand or trash as this Digimon's top digivolution card, active 1 [On Play] effect on the placed card as an effect of this Digimon.";
  281. bool CanUseCondition(Hashtable hashtable)
  282. {
  283. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  284. }
  285. IEnumerator ActivateCoroutine(Hashtable hashtable)
  286. {
  287. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardConditionShared);
  288. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardConditionShared);
  289. if (canSelectHand && canSelectTrash)
  290. {
  291. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  292. {
  293. new(message: "From hand", value: true, spriteIndex: 0),
  294. new(message: "From trash", value: false, spriteIndex: 1),
  295. };
  296. string selectPlayerMessage = "From which area do you choose a card?";
  297. string notSelectPlayerMessage = "The opponent is choosing from which area to choose a card.";
  298. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  299. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  300. notSelectPlayerMessage: notSelectPlayerMessage);
  301. }
  302. else
  303. {
  304. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  305. }
  306. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  307. .WaitForEndSelect());
  308. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  309. CardSource selectedCard = null;
  310. IEnumerator SelectCardCoroutine(CardSource cardSource)
  311. {
  312. selectedCard = cardSource;
  313. yield return null;
  314. }
  315. if (fromHand)
  316. {
  317. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  318. selectHandEffect.SetUp(
  319. selectPlayer: card.Owner,
  320. canTargetCondition: CanSelectCardConditionShared,
  321. canTargetCondition_ByPreSelecetedList: null,
  322. canEndSelectCondition: null,
  323. maxCount: 1,
  324. canNoSelect: true,
  325. canEndNotMax: false,
  326. isShowOpponent: true,
  327. selectCardCoroutine: SelectCardCoroutine,
  328. afterSelectCardCoroutine: null,
  329. mode: SelectHandEffect.Mode.Custom,
  330. cardEffect: activateClass);
  331. selectHandEffect.SetUpCustomMessage("Select 1 card to place on top of digivolution cards.",
  332. "The opponent is selecting 1 card to place on top of digivolution cards.");
  333. selectHandEffect.SetUpCustomMessage_ShowCard("Placed Card");
  334. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  335. }
  336. else
  337. {
  338. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  339. selectCardEffect.SetUp(
  340. canTargetCondition: CanSelectCardConditionShared,
  341. canTargetCondition_ByPreSelecetedList: null,
  342. canEndSelectCondition: null,
  343. canNoSelect: () => true,
  344. selectCardCoroutine: SelectCardCoroutine,
  345. afterSelectCardCoroutine: null,
  346. message: "Select 1 card to place on top of digivolution cards.",
  347. maxCount: 1,
  348. canEndNotMax: false,
  349. isShowOpponent: true,
  350. mode: SelectCardEffect.Mode.Custom,
  351. root: SelectCardEffect.Root.Trash,
  352. customRootCardList: null,
  353. canLookReverseCard: true,
  354. selectPlayer: card.Owner,
  355. cardEffect: activateClass);
  356. selectCardEffect.SetUpCustomMessage("Select 1 card to place on top of digivolution cards.",
  357. "The opponent is selecting 1 card to place on top of digivolution cards.");
  358. selectCardEffect.SetUpCustomMessage_ShowCard("Placed Card");
  359. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  360. }
  361. if (selectedCard)
  362. {
  363. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard()
  364. .AddDigivolutionCardsTop(new List<CardSource>() { selectedCard }, activateClass));
  365. List<ICardEffect> candidateEffects = selectedCard.cEntity_EffectController.GetCardEffects_ExceptAddedEffects(EffectTiming.OnEnterFieldAnyone, card)
  366. .Clone()
  367. .Filter(cardEffect =>
  368. cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect &&
  369. cardEffect.IsOnPlay);
  370. if (candidateEffects.Count >= 1)
  371. {
  372. ICardEffect selectedEffect = null;
  373. if (candidateEffects.Count == 1)
  374. {
  375. selectedEffect = candidateEffects[0];
  376. }
  377. else
  378. {
  379. List<SkillInfo> skillInfos = candidateEffects
  380. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  381. List<CardSource> cardSources = candidateEffects
  382. .Map(cardEffect => cardEffect.EffectSourceCard);
  383. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  384. selectCardEffect.SetUp(
  385. canTargetCondition: _ => true,
  386. canTargetCondition_ByPreSelecetedList: null,
  387. canEndSelectCondition: null,
  388. canNoSelect: () => false,
  389. selectCardCoroutine: null,
  390. afterSelectCardCoroutine: null,
  391. message: "Select 1 effect to activate.",
  392. maxCount: 1,
  393. canEndNotMax: false,
  394. isShowOpponent: false,
  395. mode: SelectCardEffect.Mode.Custom,
  396. root: SelectCardEffect.Root.Custom,
  397. customRootCardList: cardSources,
  398. canLookReverseCard: true,
  399. selectPlayer: card.Owner,
  400. cardEffect: activateClass);
  401. selectCardEffect.SetNotShowCard();
  402. selectCardEffect.SetUpSkillInfos(skillInfos);
  403. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  404. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  405. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  406. {
  407. if (selectedIndexes.Count == 1)
  408. {
  409. selectedEffect = candidateEffects[selectedIndexes[0]];
  410. yield return null;
  411. }
  412. }
  413. }
  414. if (selectedEffect != null)
  415. {
  416. Hashtable effectHashtable = CardEffectCommons.OnPlayCheckHashtableOfCard(card);
  417. if (selectedEffect.CanUse(effectHashtable))
  418. {
  419. selectedEffect.SetIsDigimonEffect(true);
  420. yield return ContinuousController.instance.StartCoroutine(
  421. ((ActivateICardEffect)selectedEffect)
  422. .Activate_Optional_Effect_Execute(effectHashtable));
  423. }
  424. }
  425. }
  426. }
  427. }
  428. }
  429. #endregion
  430. #region When Attacking
  431. if (timing == EffectTiming.OnAllyAttack)
  432. {
  433. ActivateClass activateClass = new ActivateClass();
  434. activateClass.SetUpICardEffect("Place 1 card in hand or trash as source, to activate its [On Play] effect",
  435. CanUseCondition, card);
  436. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, 1, true,
  437. EffectDescription());
  438. activateClass.SetHashString("AddSource_EX9_073");
  439. cardEffects.Add(activateClass);
  440. string EffectDescription() =>
  441. "[When Attacking] [Once Per Turn] By placing 1 level 5 [Cyborg] or [Ver.5] trait card from your hand or trash as this Digimon's top digivolution card, active 1 [On Play] effect on the placed card as an effect of this Digimon.";
  442. bool CanUseCondition(Hashtable hashtable)
  443. {
  444. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  445. }
  446. IEnumerator ActivateCoroutine(Hashtable hashtable)
  447. {
  448. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardConditionShared);
  449. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardConditionShared);
  450. if (canSelectHand && canSelectTrash)
  451. {
  452. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  453. {
  454. new(message: "From hand", value: true, spriteIndex: 0),
  455. new(message: "From trash", value: false, spriteIndex: 1),
  456. };
  457. string selectPlayerMessage = "From which area do you choose a card?";
  458. string notSelectPlayerMessage = "The opponent is choosing from which area to choose a card.";
  459. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  460. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  461. notSelectPlayerMessage: notSelectPlayerMessage);
  462. }
  463. else
  464. {
  465. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  466. }
  467. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  468. .WaitForEndSelect());
  469. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  470. CardSource selectedCard = null;
  471. IEnumerator SelectCardCoroutine(CardSource cardSource)
  472. {
  473. selectedCard = cardSource;
  474. yield return null;
  475. }
  476. if (fromHand)
  477. {
  478. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  479. selectHandEffect.SetUp(
  480. selectPlayer: card.Owner,
  481. canTargetCondition: CanSelectCardConditionShared,
  482. canTargetCondition_ByPreSelecetedList: null,
  483. canEndSelectCondition: null,
  484. maxCount: 1,
  485. canNoSelect: true,
  486. canEndNotMax: false,
  487. isShowOpponent: true,
  488. selectCardCoroutine: SelectCardCoroutine,
  489. afterSelectCardCoroutine: null,
  490. mode: SelectHandEffect.Mode.Custom,
  491. cardEffect: activateClass);
  492. selectHandEffect.SetUpCustomMessage("Select 1 card to place on top of digivolution cards.",
  493. "The opponent is selecting 1 card to place on top of digivolution cards.");
  494. selectHandEffect.SetUpCustomMessage_ShowCard("Placed Card");
  495. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  496. }
  497. else
  498. {
  499. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  500. selectCardEffect.SetUp(
  501. canTargetCondition: CanSelectCardConditionShared,
  502. canTargetCondition_ByPreSelecetedList: null,
  503. canEndSelectCondition: null,
  504. canNoSelect: () => true,
  505. selectCardCoroutine: SelectCardCoroutine,
  506. afterSelectCardCoroutine: null,
  507. message: "Select 1 card to place on top of digivolution cards.",
  508. maxCount: 1,
  509. canEndNotMax: false,
  510. isShowOpponent: true,
  511. mode: SelectCardEffect.Mode.Custom,
  512. root: SelectCardEffect.Root.Trash,
  513. customRootCardList: null,
  514. canLookReverseCard: true,
  515. selectPlayer: card.Owner,
  516. cardEffect: activateClass);
  517. selectCardEffect.SetUpCustomMessage("Select 1 card to place on top of digivolution cards.",
  518. "The opponent is selecting 1 card to place on top of digivolution cards.");
  519. selectCardEffect.SetUpCustomMessage_ShowCard("Placed Card");
  520. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  521. }
  522. if (selectedCard)
  523. {
  524. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard()
  525. .AddDigivolutionCardsTop(new List<CardSource>() { selectedCard }, activateClass));
  526. List<ICardEffect> candidateEffects = selectedCard.cEntity_EffectController.GetCardEffects_ExceptAddedEffects(EffectTiming.OnEnterFieldAnyone, card)
  527. .Clone()
  528. .Filter(cardEffect =>
  529. cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect &&
  530. cardEffect.IsOnPlay);
  531. if (candidateEffects.Count >= 1)
  532. {
  533. ICardEffect selectedEffect = null;
  534. if (candidateEffects.Count == 1)
  535. {
  536. selectedEffect = candidateEffects[0];
  537. }
  538. else
  539. {
  540. List<SkillInfo> skillInfos = candidateEffects
  541. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  542. List<CardSource> cardSources = candidateEffects
  543. .Map(cardEffect => cardEffect.EffectSourceCard);
  544. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  545. selectCardEffect.SetUp(
  546. canTargetCondition: _ => true,
  547. canTargetCondition_ByPreSelecetedList: null,
  548. canEndSelectCondition: null,
  549. canNoSelect: () => false,
  550. selectCardCoroutine: null,
  551. afterSelectCardCoroutine: null,
  552. message: "Select 1 effect to activate.",
  553. maxCount: 1,
  554. canEndNotMax: false,
  555. isShowOpponent: false,
  556. mode: SelectCardEffect.Mode.Custom,
  557. root: SelectCardEffect.Root.Custom,
  558. customRootCardList: cardSources,
  559. canLookReverseCard: true,
  560. selectPlayer: card.Owner,
  561. cardEffect: activateClass);
  562. selectCardEffect.SetNotShowCard();
  563. selectCardEffect.SetUpSkillInfos(skillInfos);
  564. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  565. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  566. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  567. {
  568. if (selectedIndexes.Count == 1)
  569. {
  570. selectedEffect = candidateEffects[selectedIndexes[0]];
  571. yield return null;
  572. }
  573. }
  574. }
  575. if (selectedEffect != null)
  576. {
  577. Hashtable effectHashtable = CardEffectCommons.OnPlayCheckHashtableOfCard(card);
  578. if (selectedEffect.CanUse(effectHashtable))
  579. {
  580. selectedEffect.SetIsDigimonEffect(true);
  581. yield return ContinuousController.instance.StartCoroutine(
  582. ((ActivateICardEffect)selectedEffect)
  583. .Activate_Optional_Effect_Execute(effectHashtable));
  584. }
  585. }
  586. }
  587. }
  588. }
  589. }
  590. #endregion
  591. #region All Turns
  592. if (timing == EffectTiming.WhenRemoveField)
  593. {
  594. ActivateClass activateClass = new ActivateClass();
  595. activateClass.SetUpICardEffect(
  596. "Trash 2 bottom digivolution cards to prevent this Digimon from leaving the battle area", CanUseCondition, card);
  597. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  598. cardEffects.Add(activateClass);
  599. string EffectDescription() =>
  600. "[All Turns] When this Digimon would leave the battle area, by trashing its bottom 2 face-down or [Cyborg] trait digivolution cards, it doesn't leave.";
  601. bool CanUseCondition(Hashtable hashtable)
  602. {
  603. return CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  604. }
  605. bool CanSelectTrashSourceCardCondition(CardSource cardSource)
  606. {
  607. return (cardSource.IsFlipped || cardSource.EqualsTraits("Cyborg")) &&
  608. !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  609. }
  610. bool CanActivateCondition(Hashtable hashtable)
  611. {
  612. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  613. card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectTrashSourceCardCondition) >= 2;
  614. }
  615. IEnumerator ActivateCoroutine(Hashtable hashtable)
  616. {
  617. Permanent thisPermanent = card.PermanentOfThisCard();
  618. int startingSources = thisPermanent.DigivolutionCards.Count;
  619. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: thisPermanent, trashCount: 2, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  620. if (thisPermanent.DigivolutionCards.Count == startingSources - 2)
  621. {
  622. thisPermanent.willBeRemoveField = false;
  623. thisPermanent.HideDeleteEffect();
  624. thisPermanent.HideHandBounceEffect();
  625. thisPermanent.HideDeckBounceEffect();
  626. thisPermanent.HideWillRemoveFieldEffect();
  627. }
  628. }
  629. }
  630. #endregion
  631. return cardEffects;
  632. }
  633. }
  634. }