BT21_074.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //BT21_074 Satellamon
  6. namespace DCGO.CardEffects.BT21
  7. {
  8. public class BT21_074 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement - Three Musketeers
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.Level == 4 && targetPermanent.TopCard.HasText("Three Musketeers");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Alternative Digivolution Condition - Sup.
  24. if (timing == EffectTiming.None)
  25. {
  26. bool PermanentCondition(Permanent targetPermanent)
  27. {
  28. return targetPermanent.TopCard.EqualsTraits("Sup.");
  29. }
  30. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  31. }
  32. #endregion
  33. #region Ability to link
  34. if (timing == EffectTiming.None)
  35. {
  36. bool PermanentCondition(Permanent permanent)
  37. {
  38. return permanent.TopCard.HasAppmonTraits;
  39. }
  40. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  41. }
  42. if (timing == EffectTiming.OnDeclaration)
  43. {
  44. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  45. }
  46. #endregion
  47. #region Shared Conditions
  48. bool CanTuckOrTrash(CardSource cardSource)
  49. {
  50. return cardSource.EqualsTraits("Appmon") || cardSource.HasThreeMusketeersTraits;
  51. }
  52. #endregion
  53. #region On Play/When Digivolving shared
  54. bool CanActivateConditionSharedOP(Hashtable hashtable)
  55. {
  56. return isExistOnField(card) &&
  57. (card.Owner.HandCards.Count >= 1 || card.Owner.TrashCards.Count >= 1) &&
  58. CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanTuckUnderCondition);
  59. }
  60. bool CanTuckUnderCondition(Permanent permanent)
  61. {
  62. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && !permanent.IsToken;
  63. }
  64. void ActivateDeDigivolveProtection()
  65. {
  66. ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass();
  67. immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by <De-Digivolve>", CanUseImmunityCondition,
  68. card.PermanentOfThisCard().TopCard);
  69. immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentImmunityCondition);
  70. card.PermanentOfThisCard().UntilOpponentTurnEndEffects.Add(_ => immuneFromDeDigivolveClass);
  71. }
  72. bool CanUseImmunityCondition(Hashtable hashtable1)
  73. {
  74. return card.PermanentOfThisCard().TopCard != null;
  75. }
  76. bool PermanentImmunityCondition(Permanent permanent)
  77. {
  78. return permanent == card.PermanentOfThisCard();
  79. }
  80. #endregion
  81. #region On Play
  82. if (timing == EffectTiming.OnEnterFieldAnyone)
  83. {
  84. ActivateClass activateClass = new ActivateClass();
  85. activateClass.SetUpICardEffect("Tuck to get protections", CanUseCondition, card);
  86. activateClass.SetUpActivateClass(CanActivateConditionSharedOP, ActivateCoroutine, -1, false, EffectDescription());
  87. cardEffects.Add(activateClass);
  88. string EffectDescription()
  89. {
  90. return "[On Play] By placing 1 [Appmon] or [Three Musketeers] trait card from your hand or trash as any of your Digimon's bottom digivolution cards, until your opponent's turn ends, their effects can't return that Digimon to hand or decks or affect it with <De-Digivolve> effects.";
  91. }
  92. bool CanUseCondition(Hashtable hashtable)
  93. {
  94. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  95. }
  96. IEnumerator ActivateCoroutine(Hashtable hashtable)
  97. {
  98. bool canSelectHand = card.Owner.HandCards.Count(CanTuckOrTrash) >= 1;
  99. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanTuckOrTrash);
  100. if (canSelectHand || canSelectTrash)
  101. {
  102. if (canSelectHand && canSelectTrash)
  103. {
  104. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  105. {
  106. new(message: "From hand", value: true, spriteIndex: 0),
  107. new(message: "From trash", value: false, spriteIndex: 1),
  108. };
  109. string selectPlayerMessage = "From which area do you select a card?";
  110. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  111. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  112. }
  113. else
  114. {
  115. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  116. }
  117. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  118. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  119. List<CardSource> selectedCards = new List<CardSource>();
  120. IEnumerator SelectCardCoroutine(CardSource cardSource)
  121. {
  122. selectedCards.Add(cardSource);
  123. yield return null;
  124. }
  125. if (fromHand)
  126. {
  127. int maxCount = 1;
  128. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  129. selectHandEffect.SetUp(
  130. selectPlayer: card.Owner,
  131. canTargetCondition: CanTuckOrTrash,
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. maxCount: maxCount,
  135. canNoSelect: true,
  136. canEndNotMax: false,
  137. isShowOpponent: true,
  138. selectCardCoroutine: SelectCardCoroutine,
  139. afterSelectCardCoroutine: null,
  140. mode: SelectHandEffect.Mode.Custom,
  141. cardEffect: activateClass);
  142. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  143. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  144. yield return StartCoroutine(selectHandEffect.Activate());
  145. }
  146. else
  147. {
  148. int maxCount = 1;
  149. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  150. selectCardEffect.SetUp(
  151. canTargetCondition: CanTuckOrTrash,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. canNoSelect: () => true,
  155. selectCardCoroutine: SelectCardCoroutine,
  156. afterSelectCardCoroutine: null,
  157. message: "Select 1 card to place on bottom of digivolution cards.",
  158. maxCount: maxCount,
  159. canEndNotMax: false,
  160. isShowOpponent: true,
  161. mode: SelectCardEffect.Mode.Custom,
  162. root: SelectCardEffect.Root.Trash,
  163. customRootCardList: null,
  164. canLookReverseCard: true,
  165. selectPlayer: card.Owner,
  166. cardEffect: activateClass);
  167. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  168. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  169. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  170. }
  171. if (selectedCards.Count >= 1)
  172. {
  173. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanTuckUnderCondition));
  174. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  175. selectPermanentEffect.SetUp(
  176. selectPlayer: card.Owner,
  177. canTargetCondition: CanTuckUnderCondition,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. maxCount: maxCount,
  181. canNoSelect: true,
  182. canEndNotMax: false,
  183. selectPermanentCoroutine: SelectPermanentCoroutine,
  184. afterSelectPermanentCoroutine: null,
  185. mode: SelectPermanentEffect.Mode.Custom,
  186. cardEffect: activateClass);
  187. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  188. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  189. Permanent selectedPermanent = null;
  190. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  191. {
  192. selectedPermanent = permanent;
  193. yield return null;
  194. }
  195. if (selectedPermanent != null)
  196. {
  197. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCards[0] }, activateClass));
  198. #region Immunities
  199. bool CardEffectCondition(ICardEffect cardEffect)
  200. {
  201. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  202. }
  203. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToHand(
  204. targetPermanent: selectedPermanent,
  205. cardEffectCondition: CardEffectCondition,
  206. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  207. activateClass: activateClass,
  208. effectName: "Can't return to hand by opponent's effects"));
  209. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToDeck(
  210. targetPermanent: selectedPermanent,
  211. cardEffectCondition: CardEffectCondition,
  212. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  213. activateClass: activateClass,
  214. effectName: "Can't return to deck by opponent's effects"));
  215. ActivateDeDigivolveProtection();
  216. #endregion
  217. }
  218. }
  219. }
  220. }
  221. }
  222. #endregion
  223. #region When Digivolving (tuck)
  224. if (timing == EffectTiming.OnEnterFieldAnyone)
  225. {
  226. ActivateClass activateClass = new ActivateClass();
  227. activateClass.SetUpICardEffect("Tuck to get protections", CanUseCondition, card);
  228. activateClass.SetUpActivateClass(CanActivateConditionSharedOP, ActivateCoroutine, -1, false, EffectDescription());
  229. cardEffects.Add(activateClass);
  230. string EffectDescription()
  231. {
  232. return "[When Digivolving] By placing 1 [Appmon] or [Three Musketeers] trait card from your hand or trash as any of your Digimon's bottom digivolution cards, until your opponent's turn ends, their effects can't return that Digimon to hand or decks or affect it with <De-Digivolve> effects.";
  233. }
  234. bool CanUseCondition(Hashtable hashtable)
  235. {
  236. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  237. }
  238. IEnumerator ActivateCoroutine(Hashtable hashtable)
  239. {
  240. bool canSelectHand = card.Owner.HandCards.Count(CanTuckOrTrash) >= 1;
  241. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanTuckOrTrash);
  242. if (canSelectHand || canSelectTrash)
  243. {
  244. if (canSelectHand && canSelectTrash)
  245. {
  246. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  247. {
  248. new(message: "From hand", value: true, spriteIndex: 0),
  249. new(message: "From trash", value: false, spriteIndex: 1),
  250. };
  251. string selectPlayerMessage = "From which area do you select a card?";
  252. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  253. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  254. }
  255. else
  256. {
  257. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  258. }
  259. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  260. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  261. List<CardSource> selectedCards = new List<CardSource>();
  262. IEnumerator SelectCardCoroutine(CardSource cardSource)
  263. {
  264. selectedCards.Add(cardSource);
  265. yield return null;
  266. }
  267. if (fromHand)
  268. {
  269. int maxCount = 1;
  270. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  271. selectHandEffect.SetUp(
  272. selectPlayer: card.Owner,
  273. canTargetCondition: CanTuckOrTrash,
  274. canTargetCondition_ByPreSelecetedList: null,
  275. canEndSelectCondition: null,
  276. maxCount: maxCount,
  277. canNoSelect: true,
  278. canEndNotMax: false,
  279. isShowOpponent: true,
  280. selectCardCoroutine: SelectCardCoroutine,
  281. afterSelectCardCoroutine: null,
  282. mode: SelectHandEffect.Mode.Custom,
  283. cardEffect: activateClass);
  284. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  285. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  286. yield return StartCoroutine(selectHandEffect.Activate());
  287. }
  288. else
  289. {
  290. int maxCount = 1;
  291. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  292. selectCardEffect.SetUp(
  293. canTargetCondition: CanTuckOrTrash,
  294. canTargetCondition_ByPreSelecetedList: null,
  295. canEndSelectCondition: null,
  296. canNoSelect: () => true,
  297. selectCardCoroutine: SelectCardCoroutine,
  298. afterSelectCardCoroutine: null,
  299. message: "Select 1 card to place on bottom of digivolution cards.",
  300. maxCount: maxCount,
  301. canEndNotMax: false,
  302. isShowOpponent: true,
  303. mode: SelectCardEffect.Mode.Custom,
  304. root: SelectCardEffect.Root.Trash,
  305. customRootCardList: null,
  306. canLookReverseCard: true,
  307. selectPlayer: card.Owner,
  308. cardEffect: activateClass);
  309. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  310. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  311. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  312. }
  313. if (selectedCards.Count >= 1)
  314. {
  315. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanTuckUnderCondition));
  316. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  317. selectPermanentEffect.SetUp(
  318. selectPlayer: card.Owner,
  319. canTargetCondition: CanTuckUnderCondition,
  320. canTargetCondition_ByPreSelecetedList: null,
  321. canEndSelectCondition: null,
  322. maxCount: maxCount,
  323. canNoSelect: true,
  324. canEndNotMax: false,
  325. selectPermanentCoroutine: SelectPermanentCoroutine,
  326. afterSelectPermanentCoroutine: null,
  327. mode: SelectPermanentEffect.Mode.Custom,
  328. cardEffect: activateClass);
  329. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  330. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  331. Permanent selectedPermanent = null;
  332. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  333. {
  334. selectedPermanent = permanent;
  335. yield return null;
  336. }
  337. if (selectedPermanent != null)
  338. {
  339. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCards[0] }, activateClass));
  340. #region Immunities
  341. bool CardEffectCondition(ICardEffect cardEffect)
  342. {
  343. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  344. }
  345. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToHand(
  346. targetPermanent: selectedPermanent,
  347. cardEffectCondition: CardEffectCondition,
  348. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  349. activateClass: activateClass,
  350. effectName: "Can't return to hand by opponent's effects"));
  351. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToDeck(
  352. targetPermanent: selectedPermanent,
  353. cardEffectCondition: CardEffectCondition,
  354. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  355. activateClass: activateClass,
  356. effectName: "Can't return to deck by opponent's effects"));
  357. ActivateDeDigivolveProtection();
  358. #endregion
  359. }
  360. }
  361. }
  362. }
  363. }
  364. #endregion
  365. #region When Digivolving/When Attacking shared
  366. bool CanActivateConditionAtkShared(Hashtable hashtable)
  367. {
  368. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  369. card.PermanentOfThisCard().DigivolutionCards.Some(CanTuckOrTrash);
  370. }
  371. bool CanSelectPermanentCondition(Permanent permanent)
  372. {
  373. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  374. return permanent.DigivolutionCards.Count(CanTuckOrTrash) >= 1;
  375. return false;
  376. }
  377. bool DedigivolveTarget(Permanent permanent)
  378. {
  379. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  380. }
  381. #endregion
  382. #region When Digivolving (trash)
  383. if(timing == EffectTiming.OnEnterFieldAnyone)
  384. {
  385. ActivateClass activateClass = new ActivateClass();
  386. activateClass.SetUpICardEffect("Trash source to de-digivolve", CanUseCondition, card);
  387. activateClass.SetUpActivateClass(CanActivateConditionAtkShared, ActivateCoroutine, 1, true, EffectDescription());
  388. activateClass.SetHashString("BT21_074De-digivolve");
  389. cardEffects.Add(activateClass);
  390. string EffectDescription()
  391. {
  392. return "[When Digivolving][Once Per Turn] By trashing 1 card with the [Appmon] or [Three Musketeers] trait from your Digimon's digivolution cards, <De-Digivolve 1> 1 of your opponent's Digimon.";
  393. }
  394. bool CanUseCondition(Hashtable hashtable)
  395. {
  396. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  397. }
  398. IEnumerator ActivateCoroutine(Hashtable hashtable)
  399. {
  400. bool trashed = false;
  401. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  402. permanentCondition: CanSelectPermanentCondition,
  403. cardCondition: CanTuckOrTrash,
  404. maxCount: 1,
  405. canNoTrash: false,
  406. isFromOnly1Permanent: false,
  407. activateClass: activateClass,
  408. afterSelectionCoroutine: AfterTrashedCards
  409. ));
  410. IEnumerator AfterTrashedCards(Permanent permanent, List<CardSource> cards)
  411. {
  412. if(cards.Count > 0)
  413. trashed = true;
  414. yield return null;
  415. }
  416. if (trashed)
  417. {
  418. if (CardEffectCommons.HasMatchConditionPermanent(DedigivolveTarget))
  419. {
  420. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  421. selectPermanentEffect.SetUp(
  422. selectPlayer: card.Owner,
  423. canTargetCondition: DedigivolveTarget,
  424. canTargetCondition_ByPreSelecetedList: null,
  425. canEndSelectCondition: null,
  426. maxCount: 1,
  427. canNoSelect: false,
  428. canEndNotMax: false,
  429. selectPermanentCoroutine: SelectedDedigivolveTarget,
  430. afterSelectPermanentCoroutine: null,
  431. mode: SelectPermanentEffect.Mode.Custom,
  432. cardEffect: activateClass);
  433. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  434. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  435. IEnumerator SelectedDedigivolveTarget(Permanent target)
  436. {
  437. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(target, 1, activateClass).Degeneration());
  438. }
  439. }
  440. }
  441. }
  442. }
  443. #endregion
  444. #region When Attacking
  445. if (timing == EffectTiming.OnAllyAttack)
  446. {
  447. ActivateClass activateClass = new ActivateClass();
  448. activateClass.SetUpICardEffect("Trash source to de-digivolve", CanUseCondition, card);
  449. activateClass.SetUpActivateClass(CanActivateConditionAtkShared, ActivateCoroutine, 1, true, EffectDescription());
  450. activateClass.SetHashString("BT21_074De-digivolve");
  451. cardEffects.Add(activateClass);
  452. string EffectDescription()
  453. {
  454. return "[When Digivolving][Once Per Turn] By trashing 1 card with the [Appmon] or [Three Musketeers] trait from your Digimon's digivolution cards, <De-Digivolve 1> 1 of your opponent's Digimon.";
  455. }
  456. bool CanUseCondition(Hashtable hashtable)
  457. {
  458. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  459. }
  460. IEnumerator ActivateCoroutine(Hashtable hashtable)
  461. {
  462. bool trashed = false;
  463. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  464. permanentCondition: CanSelectPermanentCondition,
  465. cardCondition: CanTuckOrTrash,
  466. maxCount: 1,
  467. canNoTrash: false,
  468. isFromOnly1Permanent: false,
  469. activateClass: activateClass,
  470. afterSelectionCoroutine: AfterTrashedCards
  471. ));
  472. IEnumerator AfterTrashedCards(Permanent permanent, List<CardSource> cards)
  473. {
  474. if (cards.Count > 0)
  475. trashed = true;
  476. yield return null;
  477. }
  478. if (trashed)
  479. {
  480. if (CardEffectCommons.HasMatchConditionPermanent(DedigivolveTarget))
  481. {
  482. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  483. selectPermanentEffect.SetUp(
  484. selectPlayer: card.Owner,
  485. canTargetCondition: DedigivolveTarget,
  486. canTargetCondition_ByPreSelecetedList: null,
  487. canEndSelectCondition: null,
  488. maxCount: 1,
  489. canNoSelect: false,
  490. canEndNotMax: false,
  491. selectPermanentCoroutine: SelectedDedigivolveTarget,
  492. afterSelectPermanentCoroutine: null,
  493. mode: SelectPermanentEffect.Mode.Custom,
  494. cardEffect: activateClass);
  495. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  496. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  497. IEnumerator SelectedDedigivolveTarget(Permanent target)
  498. {
  499. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(target, 1, activateClass).Degeneration());
  500. }
  501. }
  502. }
  503. }
  504. }
  505. #endregion
  506. #region When Linking
  507. if (timing == EffectTiming.WhenLinked)
  508. {
  509. ActivateClass activateClass = new ActivateClass();
  510. activateClass.SetUpICardEffect("Delete level 4", CanUseCondition, card);
  511. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  512. activateClass.SetIsLinkedEffect(true);
  513. cardEffects.Add(activateClass);
  514. string EffectDiscription()
  515. {
  516. return "[When Linking] Delete 1 of your opponent's level 4 or lower Digimon.";
  517. }
  518. bool CanUseCondition(Hashtable hashtable)
  519. {
  520. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  521. }
  522. bool DeletionTargetCondition(Permanent permanent)
  523. {
  524. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.TopCard.HasLevel && permanent.Level <= 4;
  525. }
  526. bool CanActivateCondition(Hashtable hashtable)
  527. {
  528. return isExistOnField(card) && CardEffectCommons.HasMatchConditionPermanent(DeletionTargetCondition);
  529. }
  530. IEnumerator ActivateCoroutine(Hashtable hashtable)
  531. {
  532. if(CardEffectCommons.HasMatchConditionOpponentsPermanent(card, DeletionTargetCondition))
  533. {
  534. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  535. int maxCount = 1;
  536. selectPermanentEffect.SetUp(
  537. selectPlayer: card.Owner,
  538. canTargetCondition: DeletionTargetCondition,
  539. canTargetCondition_ByPreSelecetedList: null,
  540. canEndSelectCondition: null,
  541. maxCount: maxCount,
  542. canNoSelect: false,
  543. canEndNotMax: false,
  544. selectPermanentCoroutine: null,
  545. afterSelectPermanentCoroutine: null,
  546. mode: SelectPermanentEffect.Mode.Destroy,
  547. cardEffect: activateClass);
  548. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  549. }
  550. }
  551. }
  552. #endregion
  553. return cardEffects;
  554. }
  555. }
  556. }