BT24_029.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Whamon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_029 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel4
  19. && targetPermanent.TopCard.HasTSTraits;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region OP/WD Shared
  25. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  26. {
  27. bool CardCondition(CardSource cardSource)
  28. {
  29. return cardSource.HasPlayCost && cardSource.GetCostItself <= 5
  30. && (cardSource.HasAquaTraits || cardSource.HasSeaBeastTraits || cardSource.HasTSTraits);
  31. }
  32. bool validHandCard = CardEffectCommons.HasMatchConditionOwnersHand(card, CardCondition);
  33. if (validHandCard)
  34. {
  35. CardSource selectedCard = null;
  36. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  37. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CardCondition));
  38. selectHandEffect.SetUp(
  39. selectPlayer: card.Owner,
  40. canTargetCondition: CardCondition,
  41. canTargetCondition_ByPreSelecetedList: null,
  42. canEndSelectCondition: null,
  43. maxCount: maxCount,
  44. canNoSelect: true,
  45. canEndNotMax: false,
  46. isShowOpponent: true,
  47. selectCardCoroutine: SelectCardCoroutine,
  48. afterSelectCardCoroutine: null,
  49. mode: SelectHandEffect.Mode.Custom,
  50. cardEffect: activateClass);
  51. IEnumerator SelectCardCoroutine(CardSource cardSource)
  52. {
  53. selectedCard = cardSource;
  54. yield return null;
  55. }
  56. selectHandEffect.SetUpCustomMessage("Select 1 card to place as digivolution source.", "The opponent is selecting 1 card to place as digivolution source.");
  57. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  58. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  59. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  60. addedDigivolutionCards: new List<CardSource>() { selectedCard },
  61. cardEffect: activateClass));
  62. bool CanSelectPermanentCondition(Permanent permanent)
  63. {
  64. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  65. && (permanent.IsDigimon || permanent.IsTamer);
  66. }
  67. if (card.PermanentOfThisCard().DigivolutionCards.Contains(selectedCard)
  68. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  69. {
  70. Permanent selectedPermanent = null;
  71. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  72. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  73. selectPermanentEffect.SetUp(
  74. selectPlayer: card.Owner,
  75. canTargetCondition: CanSelectPermanentCondition,
  76. canTargetCondition_ByPreSelecetedList: null,
  77. canEndSelectCondition: null,
  78. maxCount: maxCount1,
  79. canNoSelect: false,
  80. canEndNotMax: false,
  81. selectPermanentCoroutine: SelectPermanentCoroutine,
  82. afterSelectPermanentCoroutine: null,
  83. mode: SelectPermanentEffect.Mode.Custom,
  84. cardEffect: activateClass);
  85. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  86. {
  87. selectedPermanent = permanent;
  88. yield return null;
  89. }
  90. selectPermanentEffect.SetUpCustomMessage("Select 1 card to gain cant suspend.", "The opponent is selecting 1 card to gain cant suspend.");
  91. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  92. if (selectedPermanent != null)
  93. {
  94. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  95. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCondition1, card);
  96. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCondition);
  97. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotSuspendClass);
  98. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  99. bool CanUseCondition1(Hashtable hashtable)
  100. {
  101. return selectedPermanent.TopCard != null
  102. && !selectedPermanent.TopCard.CanNotBeAffected(activateClass);
  103. }
  104. bool PermanentCondition(Permanent permanent) => permanent == selectedPermanent;
  105. }
  106. }
  107. }
  108. }
  109. #endregion
  110. #region On Play
  111. if (timing == EffectTiming.OnEnterFieldAnyone)
  112. {
  113. ActivateClass activateClass = new ActivateClass();
  114. activateClass.SetUpICardEffect("By placing 1 5 or lower play cost [TS]/[Sea Beast]/[Aqua]/[Sea Animal] card as bottom source, 1 digimon/tamer cant suspend", CanUseCondition, card);
  115. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  116. cardEffects.Add(activateClass);
  117. string EffectDiscription()
  118. {
  119. return "[On Play] By placing 1 play cost 5 or lower card with the [Sea Beast] or [TS] trait or [Aqua] or [Sea Animal] in any of its traits from your hand as this Digimon's bottom digivolution card, 1 of your opponent's Digimon or Tamers can't suspend until their turn ends.";
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  124. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  125. }
  126. bool CanActivateCondition(Hashtable hashtable)
  127. {
  128. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  129. }
  130. }
  131. #endregion
  132. #region When Digivolving
  133. if (timing == EffectTiming.OnEnterFieldAnyone)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect("By placing 1 5 or lower play cost [TS]/[Sea Beast]/[Aqua]/[Sea Animal] card as bottom source, 1 digimon/tamer cant suspend", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  138. cardEffects.Add(activateClass);
  139. string EffectDiscription()
  140. {
  141. return "[When Digivolving] By placing 1 play cost 5 or lower card with the [Sea Beast] or [TS] trait or [Aqua] or [Sea Animal] in any of its traits from your hand as this Digimon's bottom digivolution card, 1 of your opponent's Digimon or Tamers can't suspend until their turn ends.";
  142. }
  143. bool CanUseCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  146. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  147. }
  148. bool CanActivateCondition(Hashtable hashtable)
  149. {
  150. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  151. }
  152. }
  153. #endregion
  154. #region End of Attack
  155. if (timing == EffectTiming.OnEndAttack)
  156. {
  157. ActivateClass activateClass = new ActivateClass();
  158. activateClass.SetUpICardEffect("Play 1 5 cost or lower [TS] card from digivolution sources", CanUseCondition, card);
  159. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  160. activateClass.SetHashString("BT24_029_EOA");
  161. cardEffects.Add(activateClass);
  162. string EffectDiscription()
  163. {
  164. return "[End of Attack] [Once Per Turn] You may play 1 play cost 5 or lower [TS] trait card from this Digimon's digivolution cards without paying the cost.";
  165. }
  166. bool CanUseCondition(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.IsExistOnBattleArea(card)
  169. && CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  170. }
  171. bool CanActivateCondition(Hashtable hashtable)
  172. {
  173. return CardEffectCommons.IsExistOnBattleArea(card);
  174. }
  175. bool CardCondition(CardSource cardSource)
  176. {
  177. return cardSource.HasPlayCost && cardSource.GetCostItself <= 5
  178. && cardSource.HasTSTraits
  179. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, root: SelectCardEffect.Root.DigivolutionCards);
  180. }
  181. IEnumerator ActivateCoroutine(Hashtable hashtable)
  182. {
  183. var hasValidSourceCards = card.PermanentOfThisCard().DigivolutionCards.Exists(CardCondition);
  184. if (hasValidSourceCards)
  185. {
  186. CardSource selectedCard = null;
  187. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  188. int maxCount = Math.Min(1, card.PermanentOfThisCard().DigivolutionCards.Count(CardCondition));
  189. selectCardEffect.SetUp(
  190. canTargetCondition: CardCondition,
  191. canTargetCondition_ByPreSelecetedList: null,
  192. canEndSelectCondition: null,
  193. canNoSelect: () => true,
  194. selectCardCoroutine: SelectCardCoroutine,
  195. afterSelectCardCoroutine: null,
  196. message: "Select 1 card to play from digivolution source.",
  197. maxCount: maxCount,
  198. canEndNotMax: false,
  199. isShowOpponent: true,
  200. mode: SelectCardEffect.Mode.Custom,
  201. root: SelectCardEffect.Root.DigivolutionCards,
  202. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  203. canLookReverseCard: true,
  204. selectPlayer: card.Owner,
  205. cardEffect: activateClass);
  206. IEnumerator SelectCardCoroutine(CardSource cardSource)
  207. {
  208. selectedCard = cardSource;
  209. yield return null;
  210. }
  211. selectCardEffect.SetUpCustomMessage("Select 1 card to play from digivolution source.", "The opponent is selecting 1 card to play from digivolution source.");
  212. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  213. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  214. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  215. cardSources: new List<CardSource>() { selectedCard },
  216. activateClass: activateClass,
  217. payCost: false,
  218. isTapped: false,
  219. root: SelectCardEffect.Root.DigivolutionCards,
  220. activateETB: true));
  221. }
  222. }
  223. }
  224. #endregion
  225. #region ESS
  226. if (timing == EffectTiming.OnAllyAttack)
  227. {
  228. ActivateClass activateClass = new ActivateClass();
  229. activateClass.SetUpICardEffect("Play 1 level 4 or lower blue [TS] digimon in digivolution sources", CanUseCondition, card);
  230. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  231. activateClass.SetHashString("BT24_029_ESS");
  232. activateClass.SetIsInheritedEffect(true);
  233. cardEffects.Add(activateClass);
  234. string EffectDiscription()
  235. {
  236. return "[When Attacking] [Once Per Turn] You may play 1 level 4 or lower blue Digimon card with the [TS] trait from this Digimon's digivolution cards without paying the cost.";
  237. }
  238. bool CanUseCondition(Hashtable hashtable)
  239. {
  240. return CardEffectCommons.IsExistOnBattleArea(card)
  241. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  242. }
  243. bool CanActivateCondition(Hashtable hashtable)
  244. {
  245. return CardEffectCommons.IsExistOnBattleArea(card);
  246. }
  247. bool CardCondition(CardSource cardSource)
  248. {
  249. return cardSource.IsDigimon
  250. && cardSource.HasCardColor(CardColor.Blue)
  251. && cardSource.HasLevel && cardSource.Level <= 4
  252. && cardSource.HasTSTraits
  253. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, root: SelectCardEffect.Root.DigivolutionCards);
  254. }
  255. IEnumerator ActivateCoroutine(Hashtable hashtable)
  256. {
  257. var hasValidSourceCards = card.PermanentOfThisCard().DigivolutionCards.Exists(CardCondition);
  258. if (hasValidSourceCards)
  259. {
  260. CardSource selectedCard = null;
  261. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  262. int maxCount = Math.Min(1, card.PermanentOfThisCard().DigivolutionCards.Count(CardCondition));
  263. selectCardEffect.SetUp(
  264. canTargetCondition: CardCondition,
  265. canTargetCondition_ByPreSelecetedList: null,
  266. canEndSelectCondition: null,
  267. canNoSelect: () => true,
  268. selectCardCoroutine: SelectCardCoroutine,
  269. afterSelectCardCoroutine: null,
  270. message: "Select 1 card to play from digivolution source.",
  271. maxCount: maxCount,
  272. canEndNotMax: false,
  273. isShowOpponent: true,
  274. mode: SelectCardEffect.Mode.Custom,
  275. root: SelectCardEffect.Root.DigivolutionCards,
  276. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  277. canLookReverseCard: true,
  278. selectPlayer: card.Owner,
  279. cardEffect: activateClass);
  280. IEnumerator SelectCardCoroutine(CardSource cardSource)
  281. {
  282. selectedCard = cardSource;
  283. yield return null;
  284. }
  285. selectCardEffect.SetUpCustomMessage("Select 1 card to play from digivolution source.", "The opponent is selecting 1 card to play from digivolution source.");
  286. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  287. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  288. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  289. cardSources: new List<CardSource>() { selectedCard },
  290. activateClass: activateClass,
  291. payCost: false,
  292. isTapped: false,
  293. root: SelectCardEffect.Root.DigivolutionCards,
  294. activateETB: true));
  295. }
  296. }
  297. }
  298. #endregion
  299. return cardEffects;
  300. }
  301. }
  302. }