EX3_054.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX3
  6. {
  7. public class EX3_054 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.BeforePayCost)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Reduce Digivolution Cost", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. activateClass.SetHashString("DigivolutionCost-_EX3_054");
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "When you would digivolve into this card, by returning up to 5 cards with [D-Brigade] in their traits from your trash to the top of your deck, reduce the digivolution cost by 1 for each returned card.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. return cardSource.CardTraits.Contains("D-Brigade");
  26. }
  27. bool PermanentCondition(Permanent permanent)
  28. {
  29. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card);
  30. }
  31. bool CardCondition(CardSource cardSource)
  32. {
  33. return cardSource == card;
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition);
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  42. {
  43. return true;
  44. }
  45. return false;
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  48. {
  49. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  50. {
  51. int maxCount = Math.Min(5, card.Owner.TrashCards.Count(CanSelectCardCondition));
  52. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  53. selectCardEffect.SetUp(
  54. canTargetCondition: CanSelectCardCondition,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: CanEndSelectCondition,
  57. canNoSelect: () => true,
  58. selectCardCoroutine: null,
  59. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  60. message: "Select cards to return to the top of deck\n(cards will be placed back to the top of the deck so that cards with lower numbers are on top).",
  61. maxCount: maxCount,
  62. canEndNotMax: true,
  63. isShowOpponent: true,
  64. mode: SelectCardEffect.Mode.Custom,
  65. root: SelectCardEffect.Root.Trash,
  66. customRootCardList: null,
  67. canLookReverseCard: true,
  68. selectPlayer: card.Owner,
  69. cardEffect: activateClass);
  70. selectCardEffect.SetNotAddLog();
  71. selectCardEffect.SetUpCustomMessage_ShowCard("Deck Top Cards");
  72. selectCardEffect.SetUpCustomMessage(
  73. "Select cards to put on top of the deck.",
  74. "The opponent is selecting cards to put on top of the deck.");
  75. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  76. bool CanEndSelectCondition(List<CardSource> cardSources)
  77. {
  78. if (CardEffectCommons.HasNoElement(cardSources))
  79. {
  80. return false;
  81. }
  82. return true;
  83. }
  84. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  85. {
  86. if (cardSources.Count >= 1)
  87. {
  88. cardSources.Reverse();
  89. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryTopCards(cardSources));
  90. int minusCount = cardSources.Count;
  91. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  92. ChangeCostClass changeCostClass = new ChangeCostClass();
  93. changeCostClass.SetUpICardEffect($"Digivolution Cost -{minusCount}", CanUseCondition1, card);
  94. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  95. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  96. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  97. bool CanUseCondition1(Hashtable hashtable)
  98. {
  99. return true;
  100. }
  101. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  102. {
  103. if (CardSourceCondition(cardSource))
  104. {
  105. if (RootCondition(root))
  106. {
  107. if (PermanentsCondition(targetPermanents))
  108. {
  109. Cost -= minusCount;
  110. }
  111. }
  112. }
  113. return Cost;
  114. }
  115. bool PermanentsCondition(List<Permanent> targetPermanents)
  116. {
  117. if (targetPermanents != null)
  118. {
  119. if (targetPermanents.Count(PermanentCondition) >= 1)
  120. {
  121. return true;
  122. }
  123. }
  124. return false;
  125. }
  126. bool PermanentCondition(Permanent targetPermanent)
  127. {
  128. if (targetPermanent.TopCard != null)
  129. {
  130. if (targetPermanent.TopCard.Owner == card.Owner)
  131. {
  132. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  133. {
  134. return true;
  135. }
  136. }
  137. }
  138. return false;
  139. }
  140. bool CardSourceCondition(CardSource cardSource)
  141. {
  142. if (cardSource != null)
  143. {
  144. if (cardSource == card)
  145. {
  146. return true;
  147. }
  148. }
  149. return false;
  150. }
  151. bool RootCondition(SelectCardEffect.Root root)
  152. {
  153. return true;
  154. }
  155. bool isUpDown()
  156. {
  157. return true;
  158. }
  159. }
  160. }
  161. }
  162. }
  163. }
  164. if (timing == EffectTiming.OnEnterFieldAnyone)
  165. {
  166. ActivateClass activateClass = new ActivateClass();
  167. activateClass.SetUpICardEffect("Delete 1 Digimon and unsuspend this Digimon", CanUseCondition, card);
  168. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  169. activateClass.SetHashString("Unsuspend_EX3_054");
  170. cardEffects.Add(activateClass);
  171. string EffectDiscription()
  172. {
  173. return "[Your Turn][Once Per Turn] When you play another Digimon with [D-Brigade] in its traits, delete 1 of your opponent's Digimon with a play cost less than or equal to the Digimon you played, and unsuspend this Digimon.";
  174. }
  175. bool PermanentCondition(Permanent permanent)
  176. {
  177. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  178. {
  179. if (permanent != card.PermanentOfThisCard())
  180. {
  181. if (permanent.TopCard.CardTraits.Contains("D-Brigade"))
  182. {
  183. return true;
  184. }
  185. }
  186. }
  187. return false;
  188. }
  189. bool PermanentCondition1(Permanent permanent)
  190. {
  191. if (permanent != null)
  192. {
  193. if (permanent != card.PermanentOfThisCard())
  194. {
  195. if (permanent.TraitsJustAfterPlayed.Contains("D-Brigade"))
  196. {
  197. if (permanent.PlayCostJustAfterPlayed >= 0)
  198. {
  199. return true;
  200. }
  201. }
  202. }
  203. }
  204. return false;
  205. }
  206. bool CanUseCondition(Hashtable hashtable)
  207. {
  208. if (CardEffectCommons.IsExistOnBattleArea(card))
  209. {
  210. if (CardEffectCommons.IsOwnerTurn(card))
  211. {
  212. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  213. {
  214. return true;
  215. }
  216. }
  217. }
  218. return false;
  219. }
  220. bool CanActivateCondition(Hashtable hashtable)
  221. {
  222. if (CardEffectCommons.IsExistOnBattleArea(card))
  223. {
  224. return true;
  225. }
  226. return false;
  227. }
  228. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  229. {
  230. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  231. hashtable: _hashtable,
  232. rootCondition: null);
  233. if (permanents != null)
  234. {
  235. int maxCost = -1;
  236. List<int> costs = permanents
  237. .Filter(PermanentCondition1)
  238. .Map(permanent => permanent.PlayCostJustAfterPlayed);
  239. if (costs.Count >= 1)
  240. {
  241. maxCost = costs.Max();
  242. }
  243. bool CanSelectPermanentCondition(Permanent permanent)
  244. {
  245. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  246. {
  247. if (permanent.TopCard.HasPlayCost)
  248. {
  249. if (permanent.TopCard.GetCostItself <= maxCost)
  250. {
  251. return true;
  252. }
  253. }
  254. }
  255. return false;
  256. }
  257. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  258. {
  259. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  260. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  261. selectPermanentEffect.SetUp(
  262. selectPlayer: card.Owner,
  263. canTargetCondition: CanSelectPermanentCondition,
  264. canTargetCondition_ByPreSelecetedList: null,
  265. canEndSelectCondition: null,
  266. maxCount: maxCount,
  267. canNoSelect: false,
  268. canEndNotMax: false,
  269. selectPermanentCoroutine: null,
  270. afterSelectPermanentCoroutine: null,
  271. mode: SelectPermanentEffect.Mode.Destroy,
  272. cardEffect: activateClass);
  273. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  274. }
  275. }
  276. if (CardEffectCommons.IsExistOnBattleArea(card))
  277. {
  278. Permanent selectedPermanent = card.PermanentOfThisCard();
  279. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  280. }
  281. }
  282. }
  283. return cardEffects;
  284. }
  285. }
  286. }