EX9_073.cs 35 KB

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