ST22_14.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Barbamon
  6. namespace DCGO.CardEffects.ST22
  7. {
  8. public class ST22_14 : 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 Alternate Digivolution Cost
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.HasLevel &&
  20. (targetPermanent.TopCard.HasFallenAngelTraits || targetPermanent.TopCard.HasCSTraits);
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  23. permanentCondition: PermanentCondition,
  24. digivolutionCost: 3,
  25. ignoreDigivolutionRequirement: false,
  26. card: card,
  27. condition: null)
  28. );
  29. }
  30. #endregion
  31. #region Play Cost Reduction
  32. if (timing == EffectTiming.BeforePayCost)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("Reduce play cost (5)", CanUseCondition, card);
  36. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  37. cardEffects.Add(activateClass);
  38. string EffectDiscription()
  39. {
  40. return "When this card would be played, if your opponent has 10 or more cards in either their hand or trash, reduce the play cost by 5.";
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, cardSource => cardSource == card);
  45. }
  46. bool CanActivateCondition(Hashtable hashtable)
  47. {
  48. return card.Owner.Enemy.HandCards.Count >= 10 ||
  49. card.Owner.Enemy.TrashCards.Count >= 10;
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  52. {
  53. if (card.Owner.CanReduceCost(null, card))
  54. {
  55. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  56. }
  57. ChangeCostClass changeCostClass = new ChangeCostClass();
  58. changeCostClass.SetUpICardEffect("Play Cost -5", hashtable => true, card);
  59. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  60. card.Owner.UntilCalculateFixedCostEffect.Add(_ => changeCostClass);
  61. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  62. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  63. List<Permanent> targetPermanents)
  64. {
  65. if (CardSourceCondition(cardSource) &&
  66. RootCondition(root) &&
  67. PermanentsCondition(targetPermanents))
  68. {
  69. cost -= 5;
  70. }
  71. return cost;
  72. }
  73. bool PermanentsCondition(List<Permanent> targetPermanents)
  74. {
  75. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  76. }
  77. bool CardSourceCondition(CardSource cardSource)
  78. {
  79. return cardSource == card;
  80. }
  81. bool RootCondition(SelectCardEffect.Root root)
  82. {
  83. return true;
  84. }
  85. bool isUpDown()
  86. {
  87. return true;
  88. }
  89. }
  90. }
  91. #endregion
  92. #region Reduce Play Cost - Not Shown
  93. if (timing == EffectTiming.None)
  94. {
  95. ChangeCostClass changeCostClass = new ChangeCostClass();
  96. changeCostClass.SetUpICardEffect("Play Cost -5", CanUseCondition, card);
  97. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  98. changeCostClass.SetNotShowUI(true);
  99. cardEffects.Add(changeCostClass);
  100. bool CanUseCondition(Hashtable hashtable)
  101. {
  102. return card.Owner.Enemy.HandCards.Count >= 10 || card.Owner.Enemy.TrashCards.Count >= 10;
  103. }
  104. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  105. List<Permanent> targetPermanents)
  106. {
  107. if (CardSourceCondition(cardSource) &&
  108. RootCondition(root) &&
  109. PermanentsCondition(targetPermanents))
  110. {
  111. cost -= 5;
  112. }
  113. return cost;
  114. }
  115. bool PermanentsCondition(List<Permanent> targetPermanents)
  116. {
  117. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  118. }
  119. bool CardSourceCondition(CardSource cardSource)
  120. {
  121. return cardSource == card;
  122. }
  123. bool RootCondition(SelectCardEffect.Root root)
  124. {
  125. return true;
  126. }
  127. bool isUpDown()
  128. {
  129. return true;
  130. }
  131. }
  132. #endregion
  133. #endregion
  134. #region Shared (On Play/When Digivolving)
  135. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  136. {
  137. bool SharedCanSelectCard(CardSource cardSource)
  138. {
  139. return cardSource.IsDigimon
  140. && cardSource.HasLevel && cardSource.Level <= 5
  141. && cardSource.HasFallenAngelTraits
  142. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  143. }
  144. bool hasDeleted = false;
  145. int amountToTrash = card.Owner.Enemy.HandCards.Count - 6;
  146. #region Trash hand cards if more then 6
  147. if (amountToTrash > 0)
  148. {
  149. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  150. int discardCount = Math.Min(amountToTrash, card.Owner.Enemy.HandCards.Count);
  151. selectHandEffect.SetUp(
  152. selectPlayer: card.Owner.Enemy,
  153. canTargetCondition: (cardSource) => true,
  154. canTargetCondition_ByPreSelecetedList: null,
  155. canEndSelectCondition: null,
  156. maxCount: discardCount,
  157. canNoSelect: false,
  158. canEndNotMax: false,
  159. isShowOpponent: true,
  160. selectCardCoroutine: null,
  161. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  162. mode: SelectHandEffect.Mode.Discard,
  163. cardEffect: activateClass);
  164. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  165. {
  166. if (cardSources.Any()) hasDeleted = true;
  167. yield return null;
  168. }
  169. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  170. }
  171. #endregion
  172. #region If no cards trashed, summon digimon from trash
  173. if (!hasDeleted && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SharedCanSelectCard))
  174. {
  175. CardSource selectedCard = null;
  176. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  177. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, SharedCanSelectCard));
  178. selectCardEffect.SetUp(
  179. canTargetCondition: SharedCanSelectCard,
  180. canTargetCondition_ByPreSelecetedList: null,
  181. canEndSelectCondition: null,
  182. canNoSelect: () => true,
  183. selectCardCoroutine: SelectCardCoroutine,
  184. afterSelectCardCoroutine: null,
  185. message: "Select 1 card to play.",
  186. maxCount: maxCount,
  187. canEndNotMax: false,
  188. isShowOpponent: true,
  189. mode: SelectCardEffect.Mode.Custom,
  190. root: SelectCardEffect.Root.Trash,
  191. customRootCardList: null,
  192. canLookReverseCard: true,
  193. selectPlayer: card.Owner,
  194. cardEffect: activateClass);
  195. IEnumerator SelectCardCoroutine(CardSource cardSource)
  196. {
  197. selectedCard = cardSource;
  198. yield return null;
  199. }
  200. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  201. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  202. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  203. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  204. cardSources: new List<CardSource>() { selectedCard },
  205. activateClass: activateClass,
  206. payCost: false,
  207. isTapped: false,
  208. root: SelectCardEffect.Root.Trash,
  209. activateETB: true));
  210. }
  211. #endregion
  212. }
  213. #endregion
  214. #region On Play
  215. if (timing == EffectTiming.OnEnterFieldAnyone)
  216. {
  217. ActivateClass activateClass = new ActivateClass();
  218. activateClass.SetUpICardEffect("Opponent trashes hand cards until 6 left, If none was trashed, Play 1 [Fallen Angel] from trash", CanUseCondition, card);
  219. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  220. cardEffects.Add(activateClass);
  221. string EffectDiscription()
  222. => "[On Play] Your opponent trashes cards in their hand so that they have 6 cards left. If this effect didn't trash, you may play 1 level 5 or lower [Fallen Angel] trait Digimon card from your trash without paying the cost.";
  223. bool CanUseCondition(Hashtable hashtable)
  224. {
  225. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  226. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  227. }
  228. bool CanActivateCondition(Hashtable hashtable)
  229. {
  230. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  231. }
  232. }
  233. #endregion
  234. #region When Digivolving
  235. if (timing == EffectTiming.OnEnterFieldAnyone)
  236. {
  237. ActivateClass activateClass = new ActivateClass();
  238. activateClass.SetUpICardEffect("Opponent trashes hand cards until 6 left, If none was trashed, Play 1 [Fallen Angel] from trash", CanUseCondition, card);
  239. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  240. cardEffects.Add(activateClass);
  241. string EffectDiscription()
  242. => "[When Digivolving] Your opponent trashes cards in their hand so that they have 6 cards left. If this effect didn't trash, you may play 1 level 5 or lower [Fallen Angel] trait Digimon card from your trash without paying the cost.";
  243. bool CanUseCondition(Hashtable hashtable)
  244. {
  245. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  246. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  247. }
  248. bool CanActivateCondition(Hashtable hashtable)
  249. {
  250. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  251. }
  252. }
  253. #endregion
  254. #region End of Your Turn
  255. if (timing == EffectTiming.OnEndTurn)
  256. {
  257. ActivateClass activateClass = new ActivateClass();
  258. activateClass.SetUpICardEffect("If opponent has 6 or more hand cards, they trash one. Then, if they have 5 or less, delete 1 of their lowest level digimon", CanUseCondition, card);
  259. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  260. activateClass.SetHashString("ST22_08_EOYT");
  261. cardEffects.Add(activateClass);
  262. string EffectDiscription()
  263. => "[End of Your Turn] [Once Per Turn] If your opponent has 6 or more cards in their hand, they trash 1 of them. Then, if they have 5 or fewer, delete 1 of their lowest level Digimon.";
  264. bool CanUseCondition(Hashtable hashtable)
  265. {
  266. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  267. }
  268. bool CanActivateCondition(Hashtable hashtable)
  269. {
  270. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  271. && CardEffectCommons.IsOwnerTurn(card);
  272. }
  273. bool CanSelectPermanentCondition(Permanent permanent)
  274. {
  275. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  276. && CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  277. }
  278. IEnumerator ActivateCoroutine(Hashtable hashtable)
  279. {
  280. #region If 6 or more hand cards, trash 1
  281. if (card.Owner.Enemy.HandCards.Count >= 6)
  282. {
  283. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  284. int discardCount = Math.Min(1, card.Owner.Enemy.HandCards.Count);
  285. selectHandEffect.SetUp(
  286. selectPlayer: card.Owner.Enemy,
  287. canTargetCondition: (cardSource) => true,
  288. canTargetCondition_ByPreSelecetedList: null,
  289. canEndSelectCondition: null,
  290. maxCount: discardCount,
  291. canNoSelect: false,
  292. canEndNotMax: false,
  293. isShowOpponent: true,
  294. selectCardCoroutine: null,
  295. afterSelectCardCoroutine: null,
  296. mode: SelectHandEffect.Mode.Discard,
  297. cardEffect: activateClass);
  298. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  299. }
  300. #endregion
  301. #region If 5 or less hand cards, delete 1 lowest level digimon
  302. if (card.Owner.Enemy.HandCards.Count <= 5 && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  303. {
  304. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  305. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  306. selectPermanentEffect.SetUp(
  307. selectPlayer: card.Owner,
  308. canTargetCondition: CanSelectPermanentCondition,
  309. canTargetCondition_ByPreSelecetedList: null,
  310. canEndSelectCondition: null,
  311. maxCount: maxCount,
  312. canNoSelect: false,
  313. canEndNotMax: false,
  314. selectPermanentCoroutine: null,
  315. afterSelectPermanentCoroutine: null,
  316. mode: SelectPermanentEffect.Mode.Destroy,
  317. cardEffect: activateClass);
  318. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  319. }
  320. #endregion
  321. }
  322. }
  323. #endregion
  324. return cardEffects;
  325. }
  326. }
  327. }