BT25_076.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Ghoulmon
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_076 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region When Would be Played
  13. if (timing == EffectTiming.BeforePayCost)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Delete 1 of your play cost 11 or lower [Negamon] in text with [Negamon] in sources to reduce by it's play cost", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. activateClass.SetIsDigimonEffect(true);
  20. string EffectDescription()
  21. {
  22. return
  23. "When this card would be played, by deleting 1 of your play cost 11 or lower Digimon with [Negamon] in its digivolution cards and [Negamon] in its text, reduce the cost by the deleted Digimon's play cost.";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  28. }
  29. bool CardCondition(CardSource cardSource)
  30. {
  31. return cardSource == card;
  32. }
  33. bool CanSelectPermanentCondition(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  36. && permanent.TopCard.HasPlayCost
  37. && permanent.TopCard.GetCostItself <= 11
  38. && permanent.TopCard.HasText("Negamon")
  39. && permanent.DigivolutionCards.Count((digiCard) => digiCard.EqualsCardName("Negamon")) > 0
  40. && !permanent.TopCard.CanNotBeAffected(activateClass)
  41. && card.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) - permanent.TopCard.GetCostItself <= card.Owner.MaxMemoryCost;//Check the permanent would sufficiently reduce cost to make a valid play
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable hashtable)
  48. {
  49. bool canNoSelect = true;
  50. if (CardEffectCommons.GetPayCostFromHashtable(hashtable)
  51. && card.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) > card.Owner.MaxMemoryCost)
  52. {
  53. canNoSelect = false;
  54. }
  55. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  56. selectPermanentEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: CanSelectPermanentCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: 1,
  62. canNoSelect: canNoSelect,
  63. canEndNotMax: false,
  64. selectPermanentCoroutine: null,
  65. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  66. mode: SelectPermanentEffect.Mode.Custom,
  67. cardEffect: activateClass);
  68. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  69. "The opponent is selecting 1 Digimon to delete.");
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  72. {
  73. if (permanents.Count == 1)
  74. {
  75. int reducedCost = permanents[0].TopCard.GetCostItself;
  76. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  77. targetPermanents: permanents,
  78. activateClass: activateClass,
  79. successProcess: SuccessProcess,
  80. failureProcess: null));
  81. IEnumerator SuccessProcess(List<Permanent> permanents)
  82. {
  83. if (card.Owner.CanReduceCost(null, card))
  84. {
  85. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  86. }
  87. ChangeCostClass changeCostClass = new ChangeCostClass();
  88. changeCostClass.SetUpICardEffect($"Play Cost -{reducedCost}", CanUseCondition1, card);
  89. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition,
  90. rootCondition: RootCondition, isUpDown: IsUpDown, isCheckAvailability: () => false,
  91. isChangePayingCost: () => true);
  92. card.Owner.UntilCalculateFixedCostEffect.Add(_ => changeCostClass);
  93. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  94. bool CanUseCondition1(Hashtable hashtable1)
  95. {
  96. return true;
  97. }
  98. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  99. List<Permanent> targetPermanents)
  100. {
  101. if (CardSourceCondition(cardSource) &&
  102. RootCondition(root) &&
  103. PermanentsCondition(targetPermanents))
  104. {
  105. cost -= reducedCost;
  106. }
  107. return cost;
  108. }
  109. bool PermanentsCondition(List<Permanent> targetPermanents)
  110. {
  111. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  112. }
  113. bool CardSourceCondition(CardSource cardSource)
  114. {
  115. return cardSource == card;
  116. }
  117. bool RootCondition(SelectCardEffect.Root root)
  118. {
  119. return true;
  120. }
  121. bool IsUpDown()
  122. {
  123. return true;
  124. }
  125. }
  126. }
  127. }
  128. }
  129. }
  130. #endregion
  131. #region Reduce Play Cost - Not Shown
  132. if (timing == EffectTiming.None && !CardEffectCommons.IsExistOnField(card))//do not apply this effect if the card is already in play anywhere to avoid stack overflow on GetCostItself
  133. {
  134. int GetCardCost(CardSource cardSource)// May cause inaccurate number that ignores Pyramidamon effect, but GetCostItself causes stack overflow
  135. {
  136. return CardEffectCommons.IsExistOnField(card) ? cardSource.BasePlayCostFromEntity : cardSource.GetCostItself;
  137. }
  138. List<Permanent> permanents = card.Owner.GetBattleAreaDigimons().Filter(PermanentCondition);
  139. int reducedCost = permanents.Count > 0 ? permanents.Max(p => GetCardCost(p.TopCard)): 0;
  140. ChangeCostClass changeCostClass = new ChangeCostClass();
  141. changeCostClass.SetUpICardEffect($"Play Cost -{reducedCost}", CanUseCondition1, card);
  142. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition,
  143. rootCondition: RootCondition, isUpDown: IsUpDown, isCheckAvailability: () => true,
  144. isChangePayingCost: () => true);
  145. changeCostClass.SetNotShowUI(true);
  146. cardEffects.Add(changeCostClass);
  147. bool CanUseCondition1(Hashtable hashtable1)
  148. {
  149. return CardEffectCommons.HasMatchConditionPermanent(PermanentCondition);
  150. }
  151. bool PermanentCondition(Permanent permanent)
  152. {
  153. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  154. && permanent.TopCard.HasPlayCost
  155. && GetCardCost(permanent.TopCard) <= 11
  156. && permanent.TopCard.HasText("Negamon")
  157. && permanent.DigivolutionCards.Count((cardSource) => cardSource.EqualsCardName("Negamon")) > 0;
  158. }
  159. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  160. List<Permanent> targetPermanents)
  161. {
  162. if (CardSourceCondition(cardSource) &&
  163. RootCondition(root) &&
  164. PermanentsCondition(targetPermanents))
  165. {
  166. cost -= reducedCost;
  167. }
  168. return cost;
  169. }
  170. bool PermanentsCondition(List<Permanent> targetPermanents)
  171. {
  172. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  173. }
  174. bool CardSourceCondition(CardSource cardSource)
  175. {
  176. return cardSource == card;
  177. }
  178. bool RootCondition(SelectCardEffect.Root root)
  179. {
  180. return true;
  181. }
  182. bool IsUpDown()
  183. {
  184. return true;
  185. }
  186. }
  187. #endregion
  188. #region Rush
  189. if (timing == EffectTiming.None)
  190. {
  191. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  192. }
  193. #endregion
  194. #region Reboot
  195. if (timing == EffectTiming.None)
  196. {
  197. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  198. }
  199. #endregion
  200. #region Blocker
  201. if (timing == EffectTiming.None)
  202. {
  203. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  204. }
  205. #endregion
  206. #region Shared OP/WA/OD
  207. string SharedEffectName = "Delete 1 enemy Digimon with lowest play cost, if didn't delete, trash enemy security";
  208. CardEffectFactory.ActivateClassesForSharedEffects
  209. (ref cardEffects, timing, card,
  210. SharedEffectName,
  211. SharedActivateCoroutine,
  212. SharedEffectDescription,
  213. optional: false,
  214. onPlay: true,
  215. whenAttacking: true,
  216. onDeletion: true);
  217. string SharedEffectDescription(string tag)
  218. {
  219. return $"[{tag}] Delete 1 of your opponent's Digimon with the lowest play cost. If this effect didn't delete, trash your opponent's top security card.";
  220. }
  221. bool CanSelectMinCostCondition(Permanent permanent)
  222. {
  223. return CardEffectCommons.IsMinCost(permanent, card.Owner.Enemy, true);
  224. }
  225. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  226. {
  227. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  228. bool failedToDelete = true;
  229. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectMinCostCondition))
  230. {
  231. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  232. selectPermanentEffect.SetUp(
  233. selectPlayer: card.Owner,
  234. canTargetCondition: CanSelectMinCostCondition,
  235. canTargetCondition_ByPreSelecetedList: null,
  236. canEndSelectCondition: null,
  237. maxCount: 1,
  238. canNoSelect: false,
  239. canEndNotMax: false,
  240. selectPermanentCoroutine: null,
  241. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  242. mode: SelectPermanentEffect.Mode.Custom,
  243. cardEffect: activateClass);
  244. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  245. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  246. {
  247. deleteTargetPermanents = permanents.Clone();
  248. yield return null;
  249. }
  250. }
  251. if (deleteTargetPermanents.Count > 0)
  252. {
  253. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: deleteTargetPermanents, activateClass: activateClass, successProcess: SuccessDeleteProcess, failureProcess: null));
  254. IEnumerator SuccessDeleteProcess(List<Permanent> permanents)
  255. {
  256. if (permanents.Count > 0)
  257. failedToDelete = false;
  258. yield return null;
  259. }
  260. }
  261. if (failedToDelete)
  262. {
  263. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  264. player: card.Owner.Enemy,
  265. destroySecurityCount: 1,
  266. cardEffect: activateClass,
  267. fromTop: true).DestroySecurity());
  268. }
  269. }
  270. #endregion
  271. return cardEffects;
  272. }
  273. }
  274. }