BT22_038.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Monzaemon
  6. namespace DCGO.CardEffects.BT22
  7. {
  8. public class BT22_038 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static Effects
  14. #region Numemon Digivolution Condition
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.EqualsCardName("Numemon");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Alternative Digivolution Condition
  25. if (timing == EffectTiming.None)
  26. {
  27. bool PermanentCondition(Permanent targetPermanent)
  28. {
  29. return targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.HasDMTraits;
  30. }
  31. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  32. }
  33. #endregion
  34. #region Ver1 Digivolution Cost Reduction
  35. if (timing == EffectTiming.BeforePayCost)
  36. {
  37. ActivateClass activateClass = new ActivateClass();
  38. activateClass.SetUpICardEffect("Reduce the digivolution cost by 1 for each face-down source", CanUseCondition, card);
  39. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  40. cardEffects.Add(activateClass);
  41. string EffectDiscription()
  42. => "When any of your Digimon with the [Ver.1] trait would digivolve into this card, for each of its face-down digivolution cards, reduce the digivolution cost by 1.";
  43. bool PermanentEvoCondition(Permanent permanent)
  44. {
  45. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  46. {
  47. if (permanent.TopCard.HasVer1Traits)
  48. {
  49. return card.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass);
  50. }
  51. }
  52. return false;
  53. }
  54. bool CardCondition(CardSource source)
  55. {
  56. return (source == card);
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentEvoCondition))
  61. {
  62. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentEvoCondition, CardCondition))
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. Hashtable hashtable = new Hashtable();
  72. hashtable.Add("CardEffect", activateClass);
  73. Permanent targetPermanent = CardEffectCommons.GetPermanentsFromHashtable(_hashtable)[0];
  74. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  75. ChangeCostClass changeCostClass = new ChangeCostClass();
  76. changeCostClass.SetUpICardEffect($"Digivolution Cost -{ReduceCost()}", CanUseCondition, card);
  77. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  78. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  79. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  80. bool CanUseCondition(Hashtable hashtable)
  81. {
  82. return true;
  83. }
  84. int ReduceCost()
  85. {
  86. return targetPermanent.DigivolutionCards.Filter(x => x.IsFlipped).Count;
  87. }
  88. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  89. {
  90. if (CardSourceCondition(cardSource))
  91. {
  92. if (RootCondition(root))
  93. {
  94. if (PermanentsCondition(targetPermanents))
  95. {
  96. Cost -= ReduceCost();
  97. }
  98. }
  99. }
  100. return Cost;
  101. }
  102. bool PermanentsCondition(List<Permanent> targetPermanents)
  103. {
  104. if (targetPermanents != null)
  105. {
  106. if (targetPermanents.Exists(PermanentCondition))
  107. {
  108. return true;
  109. }
  110. }
  111. return false;
  112. }
  113. bool PermanentCondition(Permanent targetPermanent)
  114. {
  115. if (targetPermanent.TopCard != null)
  116. {
  117. return PermanentEvoCondition(targetPermanent);
  118. }
  119. return false;
  120. }
  121. bool CardSourceCondition(CardSource cardSource)
  122. {
  123. if (cardSource != null)
  124. {
  125. return CardCondition(cardSource);
  126. }
  127. return false;
  128. }
  129. bool RootCondition(SelectCardEffect.Root root)
  130. {
  131. return true;
  132. }
  133. bool isUpDown()
  134. {
  135. return true;
  136. }
  137. }
  138. }
  139. #endregion
  140. #region Armour Purge
  141. if (timing == EffectTiming.WhenPermanentWouldBeDeleted) cardEffects.Add(CardEffectFactory.ArmorPurgeEffect(card: card));
  142. #endregion
  143. #endregion
  144. #region Shared WD/WA
  145. bool SharedIsOpponentDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  146. bool SharedHasFDSource() => card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Any();
  147. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  148. {
  149. bool isTrashingSource = false;
  150. if (SharedHasFDSource())
  151. {
  152. #region Make Selection for Trashing Bottom FD Source
  153. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  154. {
  155. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  156. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  157. };
  158. string selectPlayerMessage = "Trash bottom FD source?";
  159. string notSelectPlayerMessage = "The opponent is choosing to trash bottom FD source";
  160. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  161. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  162. isTrashingSource = GManager.instance.userSelectionManager.SelectedBoolValue;
  163. #endregion
  164. if (isTrashingSource)
  165. {
  166. CardSource bottomFDSource = card.PermanentOfThisCard().DigivolutionCards.FindLast(x => x.IsFlipped);
  167. yield return ContinuousController.instance.StartCoroutine(
  168. CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(card.PermanentOfThisCard(), 1, false, activateClass, cs => cs.IsFlipped));
  169. if (!card.PermanentOfThisCard().DigivolutionCards.Contains(bottomFDSource))
  170. {
  171. Permanent selectedPermanent = null;
  172. #region Select Permanent
  173. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  174. selectPermanentEffect.SetUp(
  175. selectPlayer: card.Owner,
  176. canTargetCondition: SharedIsOpponentDigimon,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. maxCount: 1,
  180. canNoSelect: false,
  181. canEndNotMax: false,
  182. selectPermanentCoroutine: SelectPermanentCoroutine,
  183. afterSelectPermanentCoroutine: null,
  184. mode: SelectPermanentEffect.Mode.Custom,
  185. cardEffect: activateClass);
  186. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  187. {
  188. selectedPermanent = permanent;
  189. yield return null;
  190. }
  191. selectPermanentEffect.SetUpCustomMessage(
  192. "Select 1 Digimon that will be unable to activate [When Digivolving] effects & -4K DP.",
  193. "The opponent is selecting 1 Digimon that will be unable to activate [When Digivolving] effects & -4K DP.");
  194. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  195. #endregion
  196. if (selectedPermanent != null)
  197. {
  198. #region Setup Disable When Digivolving
  199. bool CanUseConditionDebuff(Hashtable hashtableDebuff)
  200. {
  201. return true;
  202. }
  203. bool InvalidateCondition(ICardEffect cardEffect)
  204. {
  205. if (selectedPermanent.TopCard != null)
  206. {
  207. if (cardEffect != null)
  208. {
  209. if (cardEffect.EffectSourceCard != null)
  210. {
  211. if (isExistOnField(cardEffect.EffectSourceCard))
  212. {
  213. if (cardEffect.EffectSourceCard.PermanentOfThisCard() == selectedPermanent)
  214. {
  215. if (cardEffect.IsWhenDigivolving)
  216. {
  217. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  218. {
  219. return true;
  220. }
  221. }
  222. }
  223. }
  224. }
  225. }
  226. }
  227. return false;
  228. }
  229. DisableEffectClass invalidationClass = new DisableEffectClass();
  230. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseConditionDebuff, card);
  231. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  232. #endregion
  233. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => invalidationClass);
  234. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  235. targetPermanent: selectedPermanent,
  236. changeValue: -4000,
  237. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  238. activateClass: activateClass
  239. ));
  240. }
  241. }
  242. }
  243. }
  244. }
  245. #endregion
  246. #region When Digivolving
  247. if (timing == EffectTiming.OnEnterFieldAnyone)
  248. {
  249. ActivateClass activateClass = new ActivateClass();
  250. activateClass.SetUpICardEffect("by trashing bottom face down source, 1 digimon cant use When digivolving effects and get -4K DP", CanUseCondition, card);
  251. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  252. activateClass.SetHashString("BT22_038_WDWA");
  253. cardEffects.Add(activateClass);
  254. string EffectDiscription()
  255. {
  256. return "[When Digivolving] [Once Per Turn] By trashing this Digimon's bottom face-down digivolution card, until your opponent's turn ends, 1 of their Digimon can't activate [When Digivolving] effects and gets -4000 DP.";
  257. }
  258. bool CanUseCondition(Hashtable hashtable)
  259. {
  260. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  261. }
  262. bool CanActivateCondition(Hashtable hashtable)
  263. {
  264. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  265. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, SharedIsOpponentDigimon)
  266. && SharedHasFDSource();
  267. }
  268. IEnumerator ActivateCoroutine(Hashtable hashtable)
  269. {
  270. yield return ContinuousController.instance.StartCoroutine(SharedActivateCoroutine(hashtable, activateClass));
  271. }
  272. }
  273. #endregion
  274. #region When Attacking
  275. if (timing == EffectTiming.OnAllyAttack)
  276. {
  277. ActivateClass activateClass = new ActivateClass();
  278. activateClass.SetUpICardEffect("by trashing bottom face down source, 1 digimon cant use When digivolving effects and get -4K DP", CanUseCondition, card);
  279. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  280. activateClass.SetHashString("BT22_038_WDWA");
  281. cardEffects.Add(activateClass);
  282. string EffectDiscription()
  283. {
  284. return "[When Attacking] [Once Per Turn] By trashing this Digimon's bottom face-down digivolution card, until your opponent's turn ends, 1 of their Digimon can't activate [When Digivolving] effects and gets -4000 DP.";
  285. }
  286. bool CanUseCondition(Hashtable hashtable)
  287. {
  288. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  289. }
  290. bool CanActivateCondition(Hashtable hashtable)
  291. {
  292. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  293. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, SharedIsOpponentDigimon)
  294. && SharedHasFDSource();
  295. }
  296. IEnumerator ActivateCoroutine(Hashtable hashtable)
  297. {
  298. yield return ContinuousController.instance.StartCoroutine(SharedActivateCoroutine(hashtable, activateClass));
  299. }
  300. }
  301. #endregion
  302. #region ESS
  303. if (timing == EffectTiming.OnAllyAttack)
  304. {
  305. ActivateClass activateClass = new ActivateClass();
  306. activateClass.SetUpICardEffect("-4K DP", CanUseCondition, card);
  307. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  308. activateClass.SetHashString("BT22_038_WA");
  309. activateClass.SetIsInheritedEffect(true);
  310. cardEffects.Add(activateClass);
  311. string EffectDiscription()
  312. {
  313. return "[When Attacking] [Once Per Turn] 1 of your opponent's Digimon gets -4000 DP for the turn.";
  314. }
  315. bool CanUseCondition(Hashtable hashtable)
  316. {
  317. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  318. }
  319. bool CanActivateCondition(Hashtable hashtable)
  320. {
  321. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  322. }
  323. bool IsOpponentDigimon(Permanent permanent)
  324. {
  325. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  326. }
  327. IEnumerator ActivateCoroutine(Hashtable hashtable)
  328. {
  329. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentDigimon))
  330. {
  331. Permanent selectedPermament = null;
  332. #region Select Permanent
  333. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsOpponentDigimon));
  334. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  335. selectPermanentEffect.SetUp(
  336. selectPlayer: card.Owner,
  337. canTargetCondition: IsOpponentDigimon,
  338. canTargetCondition_ByPreSelecetedList: null,
  339. canEndSelectCondition: null,
  340. maxCount: maxCount,
  341. canNoSelect: false,
  342. canEndNotMax: false,
  343. selectPermanentCoroutine: SelectPermanentCoroutine,
  344. afterSelectPermanentCoroutine: null,
  345. mode: SelectPermanentEffect.Mode.Custom,
  346. cardEffect: activateClass);
  347. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  348. {
  349. selectedPermament = permanent;
  350. yield return null;
  351. }
  352. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to -4K DP", "The opponent is selecting 1 Digimon to -4K DP");
  353. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  354. #endregion
  355. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  356. targetPermanent: selectedPermament,
  357. changeValue: -4000,
  358. effectDuration: EffectDuration.UntilEachTurnEnd,
  359. activateClass: activateClass
  360. ));
  361. }
  362. }
  363. }
  364. #endregion
  365. return cardEffects;
  366. }
  367. }
  368. }