BT22_061.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Vademon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_061 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region DM Trait Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.HasDMTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 4,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Vegiemon Alternative Digivolution Condition
  30. if (timing == EffectTiming.None)
  31. {
  32. bool PermanentCondition(Permanent targetPermanent)
  33. {
  34. return targetPermanent.TopCard.EqualsCardName("Vegiemon");
  35. }
  36. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  37. permanentCondition: PermanentCondition,
  38. digivolutionCost: 3,
  39. ignoreDigivolutionRequirement: false,
  40. card: card,
  41. condition: null)
  42. );
  43. }
  44. #endregion
  45. #region Ver2 Digivolution Cost Reduction
  46. if (timing == EffectTiming.BeforePayCost)
  47. {
  48. ActivateClass activateClass = new ActivateClass();
  49. activateClass.SetUpICardEffect("Reduce the digivolution cost by 1 for each face-down source", CanUseCondition, card);
  50. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  51. cardEffects.Add(activateClass);
  52. string EffectDiscription()
  53. => "When any of your [Ver.2] trait Digimon would digivolve into this card, for each of their face-down digivolution cards, reduce the digivolution cost by 1.";
  54. bool PermanentEvoCondition(Permanent permanent)
  55. {
  56. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  57. {
  58. if (permanent.TopCard.HasVer2Traits)
  59. {
  60. return card.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass);
  61. }
  62. }
  63. return false;
  64. }
  65. bool CardCondition(CardSource source)
  66. {
  67. return (source == card);
  68. }
  69. bool CanUseCondition(Hashtable hashtable)
  70. {
  71. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentEvoCondition))
  72. {
  73. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentEvoCondition, CardCondition))
  74. {
  75. return true;
  76. }
  77. }
  78. return false;
  79. }
  80. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  81. {
  82. Hashtable hashtable = new Hashtable();
  83. hashtable.Add("CardEffect", activateClass);
  84. Permanent targetPermanent = CardEffectCommons.GetPermanentsFromHashtable(_hashtable)[0];
  85. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  86. ChangeCostClass changeCostClass = new ChangeCostClass();
  87. changeCostClass.SetUpICardEffect($"Digivolution Cost -{ReduceCost()}", CanUseCondition, card);
  88. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  89. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  91. bool CanUseCondition(Hashtable hashtable)
  92. {
  93. return true;
  94. }
  95. int ReduceCost()
  96. {
  97. return targetPermanent.DigivolutionCards.Filter(x => x.IsFlipped).Count;
  98. }
  99. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  100. {
  101. if (CardSourceCondition(cardSource))
  102. {
  103. if (RootCondition(root))
  104. {
  105. if (PermanentsCondition(targetPermanents))
  106. {
  107. Cost -= ReduceCost();
  108. }
  109. }
  110. }
  111. return Cost;
  112. }
  113. bool PermanentsCondition(List<Permanent> targetPermanents)
  114. {
  115. if (targetPermanents != null)
  116. {
  117. if (targetPermanents.Exists(PermanentCondition))
  118. {
  119. return true;
  120. }
  121. }
  122. return false;
  123. }
  124. bool PermanentCondition(Permanent targetPermanent)
  125. {
  126. if (targetPermanent.TopCard != null)
  127. {
  128. return PermanentEvoCondition(targetPermanent);
  129. }
  130. return false;
  131. }
  132. bool CardSourceCondition(CardSource cardSource)
  133. {
  134. if (cardSource != null)
  135. {
  136. return CardCondition(cardSource);
  137. }
  138. return false;
  139. }
  140. bool RootCondition(SelectCardEffect.Root root)
  141. {
  142. return true;
  143. }
  144. bool isUpDown()
  145. {
  146. return true;
  147. }
  148. }
  149. }
  150. #endregion
  151. #region Fragment
  152. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  153. {
  154. string EffectDiscription()
  155. {
  156. return "<Fragment <3>> (When this Digimon would be deleted, by trashing any 3 of its digivolution cards, it isn’t deleted.)";
  157. }
  158. cardEffects.Add(CardEffectFactory.FragmentSelfEffect(isInheritedEffect: false, card: card, condition: null, trashValue: 3, effectName: "Fragment <3>", effectDiscription: EffectDiscription()));
  159. }
  160. #endregion
  161. #endregion
  162. #region When Digivolving
  163. if (timing == EffectTiming.OnEnterFieldAnyone)
  164. {
  165. ActivateClass activateClass = new ActivateClass();
  166. activateClass.SetUpICardEffect("De-Digivolve 1, then by trashing bottom FD source, bounce 1 level 4 or lower digimon or tamer to hand", CanUseCondition, card);
  167. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  168. activateClass.SetHashString("BT22_061_DeDigivolve1AndBounce");
  169. cardEffects.Add(activateClass);
  170. string EffectDiscription()
  171. {
  172. return "[When Digivolving] [Once Per Turn] <De-Digivolve 1> 1 of your opponent's Digimon. (Trash the top card. You can't trash past level 3 cards.) Then, by trashing this Digimon's bottom face-down digivolution card, return 1 of your opponent's play cost 4 or lower Digimon or Tamers to the hand.";
  173. }
  174. bool CanUseCondition(Hashtable hashtable)
  175. {
  176. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  177. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  178. }
  179. bool CanActivateCondition(Hashtable hashtable)
  180. {
  181. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  182. }
  183. bool DeDigivolveCondition(Permanent targetPermanent)
  184. {
  185. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(targetPermanent, card)
  186. && !targetPermanent.ImmuneFromDeDigivolve();
  187. }
  188. bool CanSelectPermanentCondition(Permanent permanent)
  189. {
  190. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  191. && permanent.TopCard.HasPlayCost && permanent.TopCard.BasePlayCostFromEntity <= 4
  192. && (permanent.TopCard.IsDigimon || permanent.TopCard.IsTamer);
  193. }
  194. IEnumerator ActivateCoroutine(Hashtable hashtable)
  195. {
  196. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, DeDigivolveCondition))
  197. {
  198. Permanent targetDegenPermanent = null;
  199. #region Select De-Digivolve Permanent
  200. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, DeDigivolveCondition));
  201. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  202. selectPermanentEffect.SetUp(
  203. selectPlayer: card.Owner,
  204. canTargetCondition: DeDigivolveCondition,
  205. canTargetCondition_ByPreSelecetedList: null,
  206. canEndSelectCondition: null,
  207. maxCount: maxCount,
  208. canNoSelect: false,
  209. canEndNotMax: false,
  210. selectPermanentCoroutine: SelectPermanentCoroutine,
  211. afterSelectPermanentCoroutine: null,
  212. mode: SelectPermanentEffect.Mode.Custom,
  213. cardEffect: activateClass);
  214. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to De-digivolve.", "The opponent is selecting 1 Digimon to De-digivolve.");
  215. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  216. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  217. {
  218. targetDegenPermanent = permanent;
  219. yield return null;
  220. }
  221. #endregion
  222. if (targetDegenPermanent != null)
  223. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(targetDegenPermanent, 1, activateClass).Degeneration());
  224. }
  225. if (card.PermanentOfThisCard().HasFaceDownDigivolutionCards)
  226. {
  227. #region Selection to Trash Bottom Face Down Source
  228. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  229. {
  230. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  231. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  232. };
  233. string selectPlayerMessage = "Trash bottom FD source to bounce 4 cost or less tamer or digimon?";
  234. string notSelectPlayerMessage = "The opponent is choosing to trash bottom FD source to bounce 4 cost or less tamer or digimon.";
  235. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  236. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  237. #endregion
  238. bool isTrashing = GManager.instance.userSelectionManager.SelectedBoolValue;
  239. if (isTrashing)
  240. {
  241. #region Trash Bottom Face Down Source
  242. bool CanSelectCardCondition(CardSource cardSource)
  243. {
  244. return cardSource.IsFlipped;
  245. }
  246. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(
  247. targetPermanent: card.PermanentOfThisCard(),
  248. trashCount: 1,
  249. isFromTop: false,
  250. activateClass: activateClass,
  251. cardCondition: CanSelectCardCondition
  252. ));
  253. #endregion
  254. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  255. {
  256. #region Bounce Permanent
  257. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  258. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  259. selectPermanentEffect.SetUp(
  260. selectPlayer: card.Owner,
  261. canTargetCondition: CanSelectPermanentCondition,
  262. canTargetCondition_ByPreSelecetedList: null,
  263. canEndSelectCondition: null,
  264. maxCount: maxCount,
  265. canNoSelect: false,
  266. canEndNotMax: false,
  267. selectPermanentCoroutine: null,
  268. afterSelectPermanentCoroutine: null,
  269. mode: SelectPermanentEffect.Mode.Bounce,
  270. cardEffect: activateClass);
  271. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  272. #endregion
  273. }
  274. }
  275. }
  276. }
  277. }
  278. #endregion
  279. #region When Attacking
  280. if (timing == EffectTiming.OnAllyAttack)
  281. {
  282. ActivateClass activateClass = new ActivateClass();
  283. activateClass.SetUpICardEffect("De-Digivolve 1, then by trashing bottom FD source, bounce 1 level 4 or lower digimon or tamer to hand", CanUseCondition, card);
  284. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  285. activateClass.SetHashString("BT22_061_DeDigivolve1AndBounce");
  286. cardEffects.Add(activateClass);
  287. string EffectDiscription()
  288. {
  289. return "[When Attacking] [Once Per Turn] <De-Digivolve 1> 1 of your opponent's Digimon. (Trash the top card. You can't trash past level 3 cards.) Then, by trashing this Digimon's bottom face-down digivolution card, return 1 of your opponent's play cost 4 or lower Digimon or Tamers to the hand.";
  290. }
  291. bool CanUseCondition(Hashtable hashtable)
  292. {
  293. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  294. }
  295. bool CanActivateCondition(Hashtable hashtable)
  296. {
  297. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  298. }
  299. bool DeDigivolveCondition(Permanent targetPermanent)
  300. {
  301. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(targetPermanent, card)
  302. && !targetPermanent.ImmuneFromDeDigivolve();
  303. }
  304. bool CanSelectPermanentCondition(Permanent permanent)
  305. {
  306. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  307. && permanent.TopCard.HasPlayCost && permanent.TopCard.BasePlayCostFromEntity <= 4
  308. && (permanent.TopCard.IsDigimon || permanent.TopCard.IsTamer);
  309. }
  310. IEnumerator ActivateCoroutine(Hashtable hashtable)
  311. {
  312. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, DeDigivolveCondition))
  313. {
  314. Permanent targetDegenPermanent = null;
  315. #region Select De-Digivolve Permanent
  316. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, DeDigivolveCondition));
  317. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  318. selectPermanentEffect.SetUp(
  319. selectPlayer: card.Owner,
  320. canTargetCondition: DeDigivolveCondition,
  321. canTargetCondition_ByPreSelecetedList: null,
  322. canEndSelectCondition: null,
  323. maxCount: maxCount,
  324. canNoSelect: false,
  325. canEndNotMax: false,
  326. selectPermanentCoroutine: SelectPermanentCoroutine,
  327. afterSelectPermanentCoroutine: null,
  328. mode: SelectPermanentEffect.Mode.Custom,
  329. cardEffect: activateClass);
  330. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to De-digivolve.", "The opponent is selecting 1 Digimon to De-digivolve.");
  331. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  332. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  333. {
  334. targetDegenPermanent = permanent;
  335. yield return null;
  336. }
  337. #endregion
  338. if (targetDegenPermanent != null) yield return ContinuousController.instance.StartCoroutine(
  339. new IDegeneration(targetDegenPermanent, 1, activateClass).Degeneration());
  340. }
  341. if (card.PermanentOfThisCard().HasFaceDownDigivolutionCards)
  342. {
  343. #region Selection to Trash Bottom Face Down Source
  344. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  345. {
  346. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  347. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  348. };
  349. string selectPlayerMessage = "Trash bottom FD source to bounce 4 cost or less tamer or digimon?";
  350. string notSelectPlayerMessage = "The opponent is choosing to trash bottom FD source to bounce 4 cost or less tamer or digimon.";
  351. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  352. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  353. #endregion
  354. bool isTrashing = GManager.instance.userSelectionManager.SelectedBoolValue;
  355. if (isTrashing)
  356. {
  357. #region Trash Bottom Face Down Source
  358. bool CanSelectCardCondition(CardSource cardSource)
  359. {
  360. return cardSource.IsFlipped;
  361. }
  362. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(
  363. targetPermanent: card.PermanentOfThisCard(),
  364. trashCount: 1,
  365. isFromTop: false,
  366. activateClass: activateClass,
  367. cardCondition: CanSelectCardCondition
  368. ));
  369. #endregion
  370. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  371. {
  372. #region Bounce Permanent
  373. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  374. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  375. selectPermanentEffect.SetUp(
  376. selectPlayer: card.Owner,
  377. canTargetCondition: CanSelectPermanentCondition,
  378. canTargetCondition_ByPreSelecetedList: null,
  379. canEndSelectCondition: null,
  380. maxCount: maxCount,
  381. canNoSelect: false,
  382. canEndNotMax: false,
  383. selectPermanentCoroutine: null,
  384. afterSelectPermanentCoroutine: null,
  385. mode: SelectPermanentEffect.Mode.Bounce,
  386. cardEffect: activateClass);
  387. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  388. #endregion
  389. }
  390. }
  391. }
  392. }
  393. }
  394. #endregion
  395. #region ESS
  396. if (timing == EffectTiming.OnAllyAttack)
  397. {
  398. ActivateClass activateClass = new ActivateClass();
  399. activateClass.SetUpICardEffect("Change attack target to this card", CanUseCondition, card);
  400. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  401. activateClass.SetHashString("BT22_061_ChangeAttackTarget");
  402. activateClass.SetIsInheritedEffect(true);
  403. cardEffects.Add(activateClass);
  404. string EffectDiscription()
  405. {
  406. return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may change the attack target to this Digimon.";
  407. }
  408. bool CanUseCondition(Hashtable hashtable)
  409. {
  410. return CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentDigimon);
  411. }
  412. bool CanActivateCondition(Hashtable hashtable)
  413. {
  414. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  415. && CardEffectCommons.IsOpponentTurn(card)
  416. && CanBeSwitched();
  417. }
  418. bool IsOpponentDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  419. bool CanBeSwitched()
  420. {
  421. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(GManager.instance.attackProcess.AttackingPermanent, card)
  422. && GManager.instance.attackProcess.IsAttacking
  423. && GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget;
  424. }
  425. IEnumerator ActivateCoroutine(Hashtable hashtable)
  426. {
  427. if (CanBeSwitched()) yield return ContinuousController.instance.StartCoroutine(
  428. GManager.instance.attackProcess.SwitchDefender(activateClass, false, card.PermanentOfThisCard()));
  429. }
  430. }
  431. #endregion
  432. return cardEffects;
  433. }
  434. }
  435. }