EX9_041.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // ExTyrannomon
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_041 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Raremon Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.ContainsCardName("Raremon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region DM Alternate Digivolution Requirement
  24. if (timing == EffectTiming.None)
  25. {
  26. static bool PermanentCondition(Permanent targetPermanent)
  27. {
  28. return targetPermanent.TopCard.IsLevel4 &&
  29. targetPermanent.TopCard.EqualsTraits("DM");
  30. }
  31. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  32. }
  33. #endregion
  34. #region Ver5 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 [Ver.5] trait Digimon would digivolve into this card, for each of their 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.EqualsTraits("Ver.5"))
  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 Fortitude
  141. if (timing == EffectTiming.OnDestroyedAnyone)
  142. {
  143. cardEffects.Add(CardEffectFactory.FortitudeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  144. }
  145. #endregion
  146. #region On Play/When Digivolving Shared
  147. bool OpponentsDigimon(Permanent permanent)
  148. {
  149. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  150. }
  151. bool OpponentsTappedDigimon(Permanent permanent)
  152. {
  153. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.IsSuspended;
  154. }
  155. bool IsMinDPSuspended(Permanent permanent)
  156. {
  157. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy,OpponentsTappedDigimon);
  158. }
  159. bool FlippedSourceCondition(CardSource source)
  160. {
  161. return source.IsFlipped;
  162. }
  163. #endregion
  164. #region On Play
  165. if (timing == EffectTiming.OnEnterFieldAnyone)
  166. {
  167. ActivateClass activateClass = new ActivateClass();
  168. activateClass.SetUpICardEffect("Suspend 1 Digimon, trash bottom source to bounce suspended digimon with lowest DP", CanUseCondition, card);
  169. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  170. cardEffects.Add(activateClass);
  171. string EffectDiscription()
  172. {
  173. return "[On Play] Suspend 1 of your opponent's Digimon. Then, by trashing this Digimon's bottom face-down digivolution card, return 1 of your opponent's suspended Digimon with the lowest DP to the hand.";
  174. }
  175. bool CanUseCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  178. }
  179. bool CanActivateCondition(Hashtable hashtable)
  180. {
  181. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable hashtable)
  184. {
  185. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon))
  186. {
  187. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  188. selectPermanentEffect.SetUp(
  189. selectPlayer: card.Owner,
  190. canTargetCondition: OpponentsDigimon,
  191. canTargetCondition_ByPreSelecetedList: null,
  192. canEndSelectCondition: null,
  193. maxCount: 1,
  194. canNoSelect: false,
  195. canEndNotMax: false,
  196. selectPermanentCoroutine: null,
  197. afterSelectPermanentCoroutine: null,
  198. mode: SelectPermanentEffect.Mode.Tap,
  199. cardEffect: activateClass);
  200. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  201. }
  202. if (card.PermanentOfThisCard().DigivolutionCards.Count(FlippedSourceCondition) > 0)
  203. {
  204. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  205. {
  206. new(message: "Yes", value: true, spriteIndex: 0),
  207. new(message: "No", value: false, spriteIndex: 1),
  208. };
  209. string selectPlayerMessage = "Use effect to bounce suspended digimon?";
  210. string notSelectPlayerMessage = "The opponent is choosing to bounce suspended digimon.";
  211. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  212. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  213. bool isUsingEffect = GManager.instance.userSelectionManager.SelectedBoolValue;
  214. if (isUsingEffect)
  215. {
  216. int cardEvoSources = card.PermanentOfThisCard().DigivolutionCards.Count;
  217. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(
  218. targetPermanent: card.PermanentOfThisCard(),
  219. trashCount: 1,
  220. isFromTop: false,
  221. activateClass: activateClass,
  222. cardCondition: FlippedSourceCondition
  223. ));
  224. if (card.PermanentOfThisCard().DigivolutionCards.Count < cardEvoSources)
  225. {
  226. if (CardEffectCommons.HasMatchConditionPermanent(IsMinDPSuspended))
  227. {
  228. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  229. selectPermanentEffect1.SetUp(
  230. selectPlayer: card.Owner,
  231. canTargetCondition: IsMinDPSuspended,
  232. canTargetCondition_ByPreSelecetedList: null,
  233. canEndSelectCondition: null,
  234. maxCount: 1,
  235. canNoSelect: false,
  236. canEndNotMax: false,
  237. selectPermanentCoroutine: null,
  238. afterSelectPermanentCoroutine: null,
  239. mode: SelectPermanentEffect.Mode.Bounce,
  240. cardEffect: activateClass);
  241. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  242. }
  243. }
  244. }
  245. }
  246. }
  247. }
  248. #endregion
  249. #region When Digivolving
  250. if (timing == EffectTiming.OnEnterFieldAnyone)
  251. {
  252. ActivateClass activateClass = new ActivateClass();
  253. activateClass.SetUpICardEffect("Suspend 1 Digimon, trash bottom source to bounce suspended digimon with lowest DP", CanUseCondition, card);
  254. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  255. cardEffects.Add(activateClass);
  256. string EffectDiscription()
  257. {
  258. return "[When Digivolving] Suspend 1 of your opponent's Digimon. Then, by trashing this Digimon's bottom face-down digivolution card, return 1 of your opponent's suspended Digimon with the lowest DP to the hand.";
  259. }
  260. bool CanUseCondition(Hashtable hashtable)
  261. {
  262. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  263. }
  264. bool CanActivateCondition(Hashtable hashtable)
  265. {
  266. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  267. }
  268. IEnumerator ActivateCoroutine(Hashtable hashtable)
  269. {
  270. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon))
  271. {
  272. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  273. selectPermanentEffect.SetUp(
  274. selectPlayer: card.Owner,
  275. canTargetCondition: OpponentsDigimon,
  276. canTargetCondition_ByPreSelecetedList: null,
  277. canEndSelectCondition: null,
  278. maxCount: 1,
  279. canNoSelect: false,
  280. canEndNotMax: false,
  281. selectPermanentCoroutine: null,
  282. afterSelectPermanentCoroutine: null,
  283. mode: SelectPermanentEffect.Mode.Tap,
  284. cardEffect: activateClass);
  285. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  286. }
  287. if(card.PermanentOfThisCard().DigivolutionCards.Count(FlippedSourceCondition) > 0)
  288. {
  289. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  290. {
  291. new(message: "Yes", value: true, spriteIndex: 0),
  292. new(message: "No", value: false, spriteIndex: 1),
  293. };
  294. string selectPlayerMessage = "Use effect to bounce suspended digimon?";
  295. string notSelectPlayerMessage = "The opponent is choosing to bounce suspended digimon.";
  296. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  297. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  298. bool isUsingEffect = GManager.instance.userSelectionManager.SelectedBoolValue;
  299. if (isUsingEffect)
  300. {
  301. int cardEvoSources = card.PermanentOfThisCard().DigivolutionCards.Count;
  302. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(
  303. targetPermanent: card.PermanentOfThisCard(),
  304. trashCount: 1,
  305. isFromTop: false,
  306. activateClass: activateClass,
  307. cardCondition: FlippedSourceCondition
  308. ));
  309. if(card.PermanentOfThisCard().DigivolutionCards.Count < cardEvoSources)
  310. {
  311. if (CardEffectCommons.HasMatchConditionPermanent(IsMinDPSuspended))
  312. {
  313. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  314. selectPermanentEffect1.SetUp(
  315. selectPlayer: card.Owner,
  316. canTargetCondition: IsMinDPSuspended,
  317. canTargetCondition_ByPreSelecetedList: null,
  318. canEndSelectCondition: null,
  319. maxCount: 1,
  320. canNoSelect: false,
  321. canEndNotMax: false,
  322. selectPermanentCoroutine: null,
  323. afterSelectPermanentCoroutine: null,
  324. mode: SelectPermanentEffect.Mode.Bounce,
  325. cardEffect: activateClass);
  326. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  327. }
  328. }
  329. }
  330. }
  331. }
  332. }
  333. #endregion
  334. #region All Turns - ESS
  335. if (timing == EffectTiming.OnEndBattle)
  336. {
  337. ActivateClass activateClass = new ActivateClass();
  338. activateClass.SetUpICardEffect("Trash the top card of opponent's security", CanUseCondition, card);
  339. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  340. activateClass.SetIsInheritedEffect(true);
  341. activateClass.SetHashString("EX9_041_TrashSec");
  342. cardEffects.Add(activateClass);
  343. string EffectDescription()
  344. {
  345. return
  346. "[All Turns] (Once Per Turn) When this Digimon deletes an opponent's Digimon in battle, trash their top security card.";
  347. }
  348. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  349. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  350. bool CanUseCondition(Hashtable hashtable)
  351. {
  352. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  353. CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable,
  354. winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false);
  355. }
  356. bool CanActivateCondition(Hashtable hashtable)
  357. {
  358. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  359. card.Owner.Enemy.SecurityCards.Count >= 1;
  360. }
  361. IEnumerator ActivateCoroutine(Hashtable hashtable)
  362. {
  363. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  364. player: card.Owner.Enemy,
  365. destroySecurityCount: 1,
  366. cardEffect: activateClass,
  367. fromTop: true).DestroySecurity());
  368. }
  369. }
  370. #endregion
  371. return cardEffects;
  372. }
  373. }
  374. }