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 CardEffectCommons.IsExistOnBattleAreaDigimon(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(Permanent selectedPermanent)
  65. {
  66. bool CanUseImmunityCondition(Hashtable hashtable1)
  67. {
  68. return selectedPermanent.TopCard != null;
  69. }
  70. bool PermanentImmunityCondition(Permanent permanent)
  71. {
  72. return permanent == selectedPermanent;
  73. }
  74. ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass();
  75. immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by <De-Digivolve>", CanUseImmunityCondition,
  76. selectedPermanent.TopCard);
  77. immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentImmunityCondition);
  78. selectedPermanent.UntilOpponentTurnEndEffects.Add(_ => immuneFromDeDigivolveClass);
  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. Permanent selectedPermanent = null;
  99. List<CardSource> selectedCards = new List<CardSource>();
  100. bool canSelectHand = card.Owner.HandCards.Count(CanTuckOrTrash) >= 1;
  101. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanTuckOrTrash);
  102. if (canSelectHand || canSelectTrash)
  103. {
  104. if (canSelectHand && canSelectTrash)
  105. {
  106. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  107. {
  108. new(message: "From hand", value: true, spriteIndex: 0),
  109. new(message: "From trash", value: false, spriteIndex: 1),
  110. };
  111. string selectPlayerMessage = "From which area do you select a card?";
  112. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  113. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  114. }
  115. else
  116. {
  117. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  118. }
  119. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  120. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  121. IEnumerator SelectCardCoroutine(CardSource cardSource)
  122. {
  123. selectedCards.Add(cardSource);
  124. yield return null;
  125. }
  126. if (fromHand)
  127. {
  128. int maxCount = 1;
  129. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  130. selectHandEffect.SetUp(
  131. selectPlayer: card.Owner,
  132. canTargetCondition: CanTuckOrTrash,
  133. canTargetCondition_ByPreSelecetedList: null,
  134. canEndSelectCondition: null,
  135. maxCount: maxCount,
  136. canNoSelect: true,
  137. canEndNotMax: false,
  138. isShowOpponent: true,
  139. selectCardCoroutine: SelectCardCoroutine,
  140. afterSelectCardCoroutine: null,
  141. mode: SelectHandEffect.Mode.Custom,
  142. cardEffect: activateClass);
  143. 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.");
  144. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  145. yield return StartCoroutine(selectHandEffect.Activate());
  146. }
  147. else
  148. {
  149. int maxCount = 1;
  150. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  151. selectCardEffect.SetUp(
  152. canTargetCondition: CanTuckOrTrash,
  153. canTargetCondition_ByPreSelecetedList: null,
  154. canEndSelectCondition: null,
  155. canNoSelect: () => true,
  156. selectCardCoroutine: SelectCardCoroutine,
  157. afterSelectCardCoroutine: null,
  158. message: "Select 1 card to place on bottom of digivolution cards.",
  159. maxCount: maxCount,
  160. canEndNotMax: false,
  161. isShowOpponent: true,
  162. mode: SelectCardEffect.Mode.Custom,
  163. root: SelectCardEffect.Root.Trash,
  164. customRootCardList: null,
  165. canLookReverseCard: true,
  166. selectPlayer: card.Owner,
  167. cardEffect: activateClass);
  168. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  169. 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.");
  170. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  171. }
  172. if (selectedCards.Count >= 1)
  173. {
  174. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanTuckUnderCondition));
  175. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  176. selectPermanentEffect.SetUp(
  177. selectPlayer: card.Owner,
  178. canTargetCondition: CanTuckUnderCondition,
  179. canTargetCondition_ByPreSelecetedList: null,
  180. canEndSelectCondition: null,
  181. maxCount: maxCount,
  182. canNoSelect: true,
  183. canEndNotMax: false,
  184. selectPermanentCoroutine: SelectPermanentCoroutine,
  185. afterSelectPermanentCoroutine: null,
  186. mode: SelectPermanentEffect.Mode.Custom,
  187. cardEffect: activateClass);
  188. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  189. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  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(selectedPermanent);
  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. Permanent selectedPermanent = null;
  241. bool canSelectHand = card.Owner.HandCards.Count(CanTuckOrTrash) >= 1;
  242. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanTuckOrTrash);
  243. if (canSelectHand || canSelectTrash)
  244. {
  245. if (canSelectHand && canSelectTrash)
  246. {
  247. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  248. {
  249. new(message: "From hand", value: true, spriteIndex: 0),
  250. new(message: "From trash", value: false, spriteIndex: 1),
  251. };
  252. string selectPlayerMessage = "From which area do you select a card?";
  253. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  254. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  255. }
  256. else
  257. {
  258. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  259. }
  260. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  261. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  262. List<CardSource> selectedCards = new List<CardSource>();
  263. IEnumerator SelectCardCoroutine(CardSource cardSource)
  264. {
  265. selectedCards.Add(cardSource);
  266. yield return null;
  267. }
  268. if (fromHand)
  269. {
  270. int maxCount = 1;
  271. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  272. selectHandEffect.SetUp(
  273. selectPlayer: card.Owner,
  274. canTargetCondition: CanTuckOrTrash,
  275. canTargetCondition_ByPreSelecetedList: null,
  276. canEndSelectCondition: null,
  277. maxCount: maxCount,
  278. canNoSelect: true,
  279. canEndNotMax: false,
  280. isShowOpponent: true,
  281. selectCardCoroutine: SelectCardCoroutine,
  282. afterSelectCardCoroutine: null,
  283. mode: SelectHandEffect.Mode.Custom,
  284. cardEffect: activateClass);
  285. 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.");
  286. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  287. yield return StartCoroutine(selectHandEffect.Activate());
  288. }
  289. else
  290. {
  291. int maxCount = 1;
  292. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  293. selectCardEffect.SetUp(
  294. canTargetCondition: CanTuckOrTrash,
  295. canTargetCondition_ByPreSelecetedList: null,
  296. canEndSelectCondition: null,
  297. canNoSelect: () => true,
  298. selectCardCoroutine: SelectCardCoroutine,
  299. afterSelectCardCoroutine: null,
  300. message: "Select 1 card to place on bottom of digivolution cards.",
  301. maxCount: maxCount,
  302. canEndNotMax: false,
  303. isShowOpponent: true,
  304. mode: SelectCardEffect.Mode.Custom,
  305. root: SelectCardEffect.Root.Trash,
  306. customRootCardList: null,
  307. canLookReverseCard: true,
  308. selectPlayer: card.Owner,
  309. cardEffect: activateClass);
  310. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  311. 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.");
  312. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  313. }
  314. if (selectedCards.Count >= 1)
  315. {
  316. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanTuckUnderCondition));
  317. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  318. selectPermanentEffect.SetUp(
  319. selectPlayer: card.Owner,
  320. canTargetCondition: CanTuckUnderCondition,
  321. canTargetCondition_ByPreSelecetedList: null,
  322. canEndSelectCondition: null,
  323. maxCount: maxCount,
  324. canNoSelect: true,
  325. canEndNotMax: false,
  326. selectPermanentCoroutine: SelectPermanentCoroutine,
  327. afterSelectPermanentCoroutine: null,
  328. mode: SelectPermanentEffect.Mode.Custom,
  329. cardEffect: activateClass);
  330. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  331. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  332. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  333. {
  334. selectedPermanent = permanent;
  335. UnityEngine.Debug.Log($"PERMENENT SELECTED: {permanent}");
  336. yield return null;
  337. }
  338. if (selectedPermanent != null)
  339. {
  340. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCards[0] }, activateClass));
  341. #region Immunities
  342. bool CardEffectCondition(ICardEffect cardEffect)
  343. {
  344. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  345. }
  346. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToHand(
  347. targetPermanent: selectedPermanent,
  348. cardEffectCondition: CardEffectCondition,
  349. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  350. activateClass: activateClass,
  351. effectName: "Can't return to hand by opponent's effects"));
  352. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToDeck(
  353. targetPermanent: selectedPermanent,
  354. cardEffectCondition: CardEffectCondition,
  355. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  356. activateClass: activateClass,
  357. effectName: "Can't return to deck by opponent's effects"));
  358. ActivateDeDigivolveProtection(selectedPermanent);
  359. #endregion
  360. }
  361. }
  362. }
  363. }
  364. }
  365. #endregion
  366. #region When Digivolving/When Attacking shared
  367. bool CanActivateConditionAtkShared(Hashtable hashtable)
  368. {
  369. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  370. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  371. }
  372. bool CanSelectPermanentCondition(Permanent permanent)
  373. {
  374. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  375. return permanent.DigivolutionCards.Count(CanTuckOrTrash) >= 1;
  376. return false;
  377. }
  378. bool DedigivolveTarget(Permanent permanent)
  379. {
  380. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  381. }
  382. #endregion
  383. #region When Digivolving (trash)
  384. if(timing == EffectTiming.OnEnterFieldAnyone)
  385. {
  386. ActivateClass activateClass = new ActivateClass();
  387. activateClass.SetUpICardEffect("Trash source to de-digivolve", CanUseCondition, card);
  388. activateClass.SetUpActivateClass(CanActivateConditionAtkShared, ActivateCoroutine, 1, true, EffectDescription());
  389. activateClass.SetHashString("BT21_074De-digivolve");
  390. cardEffects.Add(activateClass);
  391. string EffectDescription()
  392. {
  393. 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.";
  394. }
  395. bool CanUseCondition(Hashtable hashtable)
  396. {
  397. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  398. }
  399. IEnumerator ActivateCoroutine(Hashtable hashtable)
  400. {
  401. bool trashed = false;
  402. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  403. permanentCondition: CanSelectPermanentCondition,
  404. cardCondition: CanTuckOrTrash,
  405. maxCount: 1,
  406. canNoTrash: false,
  407. isFromOnly1Permanent: false,
  408. activateClass: activateClass,
  409. afterSelectionCoroutine: AfterTrashedCards
  410. ));
  411. IEnumerator AfterTrashedCards(Permanent permanent, List<CardSource> cards)
  412. {
  413. if(cards.Count > 0)
  414. trashed = true;
  415. yield return null;
  416. }
  417. if (trashed)
  418. {
  419. if (CardEffectCommons.HasMatchConditionPermanent(DedigivolveTarget))
  420. {
  421. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  422. selectPermanentEffect.SetUp(
  423. selectPlayer: card.Owner,
  424. canTargetCondition: DedigivolveTarget,
  425. canTargetCondition_ByPreSelecetedList: null,
  426. canEndSelectCondition: null,
  427. maxCount: 1,
  428. canNoSelect: false,
  429. canEndNotMax: false,
  430. selectPermanentCoroutine: SelectedDedigivolveTarget,
  431. afterSelectPermanentCoroutine: null,
  432. mode: SelectPermanentEffect.Mode.Custom,
  433. cardEffect: activateClass);
  434. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  435. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  436. IEnumerator SelectedDedigivolveTarget(Permanent target)
  437. {
  438. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(target, 1, activateClass).Degeneration());
  439. }
  440. }
  441. }
  442. }
  443. }
  444. #endregion
  445. #region When Attacking
  446. if (timing == EffectTiming.OnAllyAttack)
  447. {
  448. ActivateClass activateClass = new ActivateClass();
  449. activateClass.SetUpICardEffect("Trash source to de-digivolve", CanUseCondition, card);
  450. activateClass.SetUpActivateClass(CanActivateConditionAtkShared, ActivateCoroutine, 1, true, EffectDescription());
  451. activateClass.SetHashString("BT21_074De-digivolve");
  452. cardEffects.Add(activateClass);
  453. string EffectDescription()
  454. {
  455. 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.";
  456. }
  457. bool CanUseCondition(Hashtable hashtable)
  458. {
  459. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  460. }
  461. IEnumerator ActivateCoroutine(Hashtable hashtable)
  462. {
  463. bool trashed = false;
  464. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  465. permanentCondition: CanSelectPermanentCondition,
  466. cardCondition: CanTuckOrTrash,
  467. maxCount: 1,
  468. canNoTrash: false,
  469. isFromOnly1Permanent: false,
  470. activateClass: activateClass,
  471. afterSelectionCoroutine: AfterTrashedCards
  472. ));
  473. IEnumerator AfterTrashedCards(Permanent permanent, List<CardSource> cards)
  474. {
  475. if (cards.Count > 0)
  476. trashed = true;
  477. yield return null;
  478. }
  479. if (trashed)
  480. {
  481. if (CardEffectCommons.HasMatchConditionPermanent(DedigivolveTarget))
  482. {
  483. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  484. selectPermanentEffect.SetUp(
  485. selectPlayer: card.Owner,
  486. canTargetCondition: DedigivolveTarget,
  487. canTargetCondition_ByPreSelecetedList: null,
  488. canEndSelectCondition: null,
  489. maxCount: 1,
  490. canNoSelect: false,
  491. canEndNotMax: false,
  492. selectPermanentCoroutine: SelectedDedigivolveTarget,
  493. afterSelectPermanentCoroutine: null,
  494. mode: SelectPermanentEffect.Mode.Custom,
  495. cardEffect: activateClass);
  496. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  497. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  498. IEnumerator SelectedDedigivolveTarget(Permanent target)
  499. {
  500. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(target, 1, activateClass).Degeneration());
  501. }
  502. }
  503. }
  504. }
  505. }
  506. #endregion
  507. #region When Linking
  508. if (timing == EffectTiming.WhenLinked)
  509. {
  510. ActivateClass activateClass = new ActivateClass();
  511. activateClass.SetUpICardEffect("Delete level 4", CanUseCondition, card);
  512. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  513. activateClass.SetIsLinkedEffect(true);
  514. cardEffects.Add(activateClass);
  515. string EffectDiscription()
  516. {
  517. return "[When Linking] Delete 1 of your opponent's level 4 or lower Digimon.";
  518. }
  519. bool CanUseCondition(Hashtable hashtable)
  520. {
  521. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  522. }
  523. bool DeletionTargetCondition(Permanent permanent)
  524. {
  525. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.TopCard.HasLevel && permanent.Level <= 4;
  526. }
  527. bool CanActivateCondition(Hashtable hashtable)
  528. {
  529. return isExistOnField(card) && CardEffectCommons.HasMatchConditionPermanent(DeletionTargetCondition);
  530. }
  531. IEnumerator ActivateCoroutine(Hashtable hashtable)
  532. {
  533. if(CardEffectCommons.HasMatchConditionOpponentsPermanent(card, DeletionTargetCondition))
  534. {
  535. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  536. int maxCount = 1;
  537. selectPermanentEffect.SetUp(
  538. selectPlayer: card.Owner,
  539. canTargetCondition: DeletionTargetCondition,
  540. canTargetCondition_ByPreSelecetedList: null,
  541. canEndSelectCondition: null,
  542. maxCount: maxCount,
  543. canNoSelect: false,
  544. canEndNotMax: false,
  545. selectPermanentCoroutine: null,
  546. afterSelectPermanentCoroutine: null,
  547. mode: SelectPermanentEffect.Mode.Destroy,
  548. cardEffect: activateClass);
  549. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  550. }
  551. }
  552. }
  553. #endregion
  554. return cardEffects;
  555. }
  556. }
  557. }