BT17_048.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_048 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Argomon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Opponents Turn
  23. if (timing == EffectTiming.None)
  24. {
  25. bool PermanentCondition(Permanent permanent)
  26. {
  27. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  28. {
  29. if (permanent.IsTamer)
  30. {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanUseCondition()
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. if (!CardEffectCommons.IsOwnerTurn(card))
  41. return true;
  42. }
  43. return false;
  44. }
  45. string effectName = "[Opponent's Turn] None of your opponent's Tamers can unsuspend.";
  46. cardEffects.Add(CardEffectFactory.CantUnsuspendStaticEffect(
  47. permanentCondition: PermanentCondition,
  48. isInheritedEffect: false,
  49. card: card, condition: CanUseCondition,
  50. effectName: effectName));
  51. }
  52. #endregion
  53. #region On Deletion
  54. if (timing == EffectTiming.OnDestroyedAnyone)
  55. {
  56. ActivateClass activateClass = new ActivateClass();
  57. activateClass.SetUpICardEffect("Play 1 Level 6 [Argomon]", CanUseCondition, card);
  58. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  59. cardEffects.Add(activateClass);
  60. string EffectDiscription()
  61. {
  62. return "[On Deletion] If you have 4 or more [Argomon] in the trash, you may play 1 level 6 [Argomon] from your hand without paying the cost.";
  63. }
  64. bool IsArgomon(CardSource source)
  65. {
  66. return source.EqualsCardName("Argomon");
  67. }
  68. bool IsLevel6Argomon(CardSource source)
  69. {
  70. if (source.IsDigimon)
  71. {
  72. if(source.HasLevel && source.Level == 6)
  73. {
  74. if (source.EqualsCardName("Argomon"))
  75. {
  76. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: source, payCost: false, cardEffect: activateClass))
  77. {
  78. return true;
  79. }
  80. }
  81. }
  82. }
  83. return false;
  84. }
  85. bool CanUseCondition(Hashtable hashtable)
  86. {
  87. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  88. }
  89. bool CanActivateCondition(Hashtable hashtable)
  90. {
  91. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  92. {
  93. if(CardEffectCommons.HasMatchConditionOwnersHand(card, IsLevel6Argomon))
  94. {
  95. if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsArgomon) >= 4)
  96. {
  97. return true;
  98. }
  99. }
  100. }
  101. return false;
  102. }
  103. IEnumerator ActivateCoroutine(Hashtable hashtable)
  104. {
  105. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  106. selectHandEffect.SetUp(
  107. selectPlayer: card.Owner,
  108. canTargetCondition: IsLevel6Argomon,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. maxCount: 1,
  112. canNoSelect: true,
  113. canEndNotMax: false,
  114. isShowOpponent: true,
  115. selectCardCoroutine: null,
  116. afterSelectCardCoroutine: SelectCardCoroutine,
  117. mode: SelectHandEffect.Mode.Custom,
  118. cardEffect: activateClass);
  119. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  120. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  121. yield return StartCoroutine(selectHandEffect.Activate());
  122. IEnumerator SelectCardCoroutine(List<CardSource> cardSources)
  123. {
  124. if(cardSources != null)
  125. {
  126. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  127. cardSources: cardSources,
  128. activateClass: activateClass,
  129. payCost: false,
  130. isTapped: false,
  131. root: SelectCardEffect.Root.Hand,
  132. activateETB: true));
  133. }
  134. }
  135. }
  136. }
  137. #endregion
  138. #region When Attacking - ESS
  139. if (timing == EffectTiming.OnAllyAttack)
  140. {
  141. ActivateClass activateClass = new ActivateClass();
  142. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  143. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  144. activateClass.SetIsInheritedEffect(true);
  145. activateClass.SetHashString("Unsuspend_BT17_048");
  146. cardEffects.Add(activateClass);
  147. string EffectDiscription()
  148. {
  149. return "[When Attacking] [Once Per Turn] By suspending 1 of your [Rhythm], unsuspend this Digimon.";
  150. }
  151. bool HasUnsuspendedRhythm(Permanent permanent)
  152. {
  153. if(CardEffectCommons.IsOwnerPermanent(permanent, card))
  154. {
  155. if (permanent.IsTamer)
  156. {
  157. if (permanent.TopCard.EqualsCardName("Rhythm"))
  158. {
  159. if (CardEffectCommons.CanActivateSuspendCostEffect(permanent.TopCard))
  160. {
  161. return true;
  162. }
  163. }
  164. }
  165. }
  166. return false;
  167. }
  168. bool CanUseCondition(Hashtable hashtable)
  169. {
  170. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  171. }
  172. bool CanActivateCondition(Hashtable hashtable)
  173. {
  174. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  175. CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasUnsuspendedRhythm);
  176. }
  177. IEnumerator ActivateCoroutine(Hashtable hashtable)
  178. {
  179. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(HasUnsuspendedRhythm));
  180. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  181. selectPermanentEffect.SetUp(
  182. selectPlayer: card.Owner,
  183. canTargetCondition: HasUnsuspendedRhythm,
  184. canTargetCondition_ByPreSelecetedList: null,
  185. canEndSelectCondition: null,
  186. maxCount: maxCount,
  187. canNoSelect: false,
  188. canEndNotMax: false,
  189. selectPermanentCoroutine: null,
  190. afterSelectPermanentCoroutine: SelectPermanentCoroutine,
  191. mode: SelectPermanentEffect.Mode.Tap,
  192. cardEffect: activateClass);
  193. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  194. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  195. IEnumerator SelectPermanentCoroutine(List<Permanent> permanents)
  196. {
  197. if (permanents != null)
  198. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent> { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  199. }
  200. }
  201. }
  202. #endregion
  203. #region Cost Reduction
  204. if (timing == EffectTiming.BeforePayCost)
  205. {
  206. ActivateClass activateClass = new ActivateClass();
  207. activateClass.SetUpICardEffect("Reduce Digivolution Cost", CanUseCondition, card);
  208. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  209. activateClass.SetHashString("DigivolutionCost-_BT17_048");
  210. cardEffects.Add(activateClass);
  211. string EffectDiscription()
  212. {
  213. return "When digivolving into this card, by suspending up to 5 Tamers, for each Tamer suspended by this effect, reduce the digivolution cost by 1.";
  214. }
  215. bool CanSelectTamerCondition(Permanent permanent)
  216. {
  217. if (permanent.IsTamer)
  218. {
  219. if (!permanent.IsSuspended)
  220. {
  221. return true;
  222. }
  223. }
  224. return false;
  225. }
  226. bool PermanentCondition(Permanent permanent)
  227. {
  228. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card);
  229. }
  230. bool CardCondition(CardSource cardSource)
  231. {
  232. return cardSource == card;
  233. }
  234. bool CanUseCondition(Hashtable hashtable)
  235. {
  236. return CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition);
  237. }
  238. bool CanActivateCondition(Hashtable hashtable)
  239. {
  240. return CardEffectCommons.HasMatchConditionPermanent(CanSelectTamerCondition);
  241. }
  242. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  243. {
  244. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTamerCondition))
  245. {
  246. int maxCount = Math.Min(5, CardEffectCommons.MatchConditionPermanentCount(CanSelectTamerCondition));
  247. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  248. selectPermanentEffect.SetUp(
  249. selectPlayer: card.Owner,
  250. canTargetCondition: CanSelectTamerCondition,
  251. canTargetCondition_ByPreSelecetedList: null,
  252. canEndSelectCondition: null,
  253. maxCount: maxCount,
  254. canNoSelect: false,
  255. canEndNotMax: true,
  256. selectPermanentCoroutine: null,
  257. afterSelectPermanentCoroutine: AfterSelectCardCoroutine,
  258. mode: SelectPermanentEffect.Mode.Tap,
  259. cardEffect: activateClass);
  260. selectPermanentEffect.SetUpCustomMessage("Select up to 5 Tamers to suspend.", "The opponent is selecting up to 5 Tamers to suspend.");
  261. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  262. IEnumerator AfterSelectCardCoroutine(List<Permanent> permanents)
  263. {
  264. if (permanents.Count >= 1)
  265. {
  266. int minusCount = permanents.Count;
  267. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  268. ChangeCostClass changeCostClass = new ChangeCostClass();
  269. changeCostClass.SetUpICardEffect($"Digivolution Cost -{minusCount}", CanUseCondition1, card);
  270. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  271. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  272. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  273. bool CanUseCondition1(Hashtable hashtable)
  274. {
  275. return true;
  276. }
  277. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  278. {
  279. if (CardSourceCondition(cardSource))
  280. {
  281. if (RootCondition(root))
  282. {
  283. if (PermanentsCondition(targetPermanents))
  284. {
  285. Cost -= minusCount;
  286. }
  287. }
  288. }
  289. return Cost;
  290. }
  291. bool PermanentsCondition(List<Permanent> targetPermanents)
  292. {
  293. if (targetPermanents != null)
  294. {
  295. if (targetPermanents.Count(PermanentCondition) >= 1)
  296. {
  297. return true;
  298. }
  299. }
  300. return false;
  301. }
  302. bool PermanentCondition(Permanent targetPermanent)
  303. {
  304. if (targetPermanent.TopCard != null)
  305. {
  306. if (targetPermanent.TopCard.Owner == card.Owner)
  307. {
  308. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  309. {
  310. return true;
  311. }
  312. }
  313. }
  314. return false;
  315. }
  316. bool CardSourceCondition(CardSource cardSource)
  317. {
  318. if (cardSource != null)
  319. {
  320. if (cardSource == card)
  321. {
  322. return true;
  323. }
  324. }
  325. return false;
  326. }
  327. bool RootCondition(SelectCardEffect.Root root)
  328. {
  329. return true;
  330. }
  331. bool isUpDown()
  332. {
  333. return true;
  334. }
  335. }
  336. }
  337. }
  338. }
  339. }
  340. #endregion
  341. return cardEffects;
  342. }
  343. }
  344. }