BT21_074.cs 34 KB

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