BT24_090.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Abyss Sanctuary: Throne Room
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_090 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Ignore Color Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  17. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  18. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  19. cardEffects.Add(ignoreColorConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return card.Owner.SecurityCards.Count(cardSource => !cardSource.IsFlipped) == 0;
  23. }
  24. bool CardCondition(CardSource cardSource)
  25. {
  26. return cardSource == card;
  27. }
  28. }
  29. #endregion
  30. #region All Turns - Security
  31. #region Blocker
  32. if (timing == EffectTiming.None)
  33. {
  34. bool PermanentCondition(Permanent permanent)
  35. {
  36. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  37. && (permanent.TopCard.CardColors.Contains(CardColor.Blue) || permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  38. && permanent.TopCard.HasTSTraits;
  39. }
  40. bool CanUseCondition()
  41. {
  42. return CardEffectCommons.IsExistInSecurity(card, false);
  43. }
  44. cardEffects.Add(CardEffectFactory.BlockerStaticEffect(permanentCondition: PermanentCondition, isInheritedEffect: false, card: card, condition: CanUseCondition));
  45. }
  46. #endregion
  47. #region Alliance
  48. if (timing == EffectTiming.OnAllyAttack)
  49. {
  50. bool PermanentCondition(Permanent permanent)
  51. {
  52. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  53. && (permanent.TopCard.CardColors.Contains(CardColor.Blue) || permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  54. && permanent.TopCard.HasTSTraits;
  55. }
  56. bool HasOXII(Permanent permanent)
  57. {
  58. return permanent.TopCard.EqualsCardName("Neptunemon")
  59. || permanent.TopCard.EqualsCardName("Venusmon");
  60. }
  61. bool CanUseCondition()
  62. {
  63. return CardEffectCommons.IsExistInSecurity(card, false)
  64. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasOXII);
  65. }
  66. cardEffects.Add(CardEffectFactory.AllianceStaticEffect(PermanentCondition, false, card, CanUseCondition));
  67. }
  68. #endregion
  69. #endregion
  70. #region Main Effect
  71. if (timing == EffectTiming.OptionSkill)
  72. {
  73. ActivateClass activateClass = new ActivateClass();
  74. activateClass.SetUpICardEffect("Replace your bottom sec with this face-up card, play a [TS] Digimon for -3", CanUseCondition, card);
  75. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  76. cardEffects.Add(activateClass);
  77. string EffectDescription()
  78. {
  79. return "[Main] Add your bottom security card to the hand and place this card face up as the bottom security card. Then, you may play 1 blue or yellow [TS] trait Digimon card from your hand with the play cost reduced by 3.";
  80. }
  81. bool CanUseCondition(Hashtable hashtable)
  82. {
  83. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  84. }
  85. bool CanSelectCardCondition(CardSource cardSource)
  86. {
  87. return cardSource.IsDigimon
  88. && (cardSource.CardColors.Contains(CardColor.Blue) || cardSource.CardColors.Contains(CardColor.Yellow))
  89. && cardSource.HasTSTraits
  90. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, true, activateClass, fixedCost: cardSource.GetCostItself - 3);
  91. }
  92. IEnumerator ActivateCoroutine(Hashtable hashtable)
  93. {
  94. yield return ContinuousController.instance.StartCoroutine(CardEffectFactory.ReplaceBottomSecurityWithFaceUpOptionEffect(card, activateClass));
  95. #region Hand Card Selection
  96. CardSource selectedCard = null;
  97. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  98. int maxCount = Math.Min(1, card.Owner.HandCards.Count(CanSelectCardCondition));
  99. selectHandEffect.SetUp(
  100. selectPlayer: card.Owner,
  101. canTargetCondition: CanSelectCardCondition,
  102. canTargetCondition_ByPreSelecetedList: null,
  103. canEndSelectCondition: null,
  104. maxCount: maxCount,
  105. canNoSelect: true,
  106. canEndNotMax: false,
  107. isShowOpponent: true,
  108. selectCardCoroutine: SelectCardCoroutine,
  109. afterSelectCardCoroutine: null,
  110. mode: SelectHandEffect.Mode.Custom,
  111. cardEffect: activateClass);
  112. IEnumerator SelectCardCoroutine(CardSource cardSource)
  113. {
  114. selectedCard = cardSource;
  115. yield return null;
  116. }
  117. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  118. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  119. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  120. if (selectedCard != null)
  121. {
  122. #region reduce play cost
  123. ChangeCostClass changeCostClass = new ChangeCostClass();
  124. changeCostClass.SetUpICardEffect($"Play Cost -3", CanUseCondition1, card);
  125. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  126. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  127. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  128. ICardEffect GetCardEffect(EffectTiming _timing)
  129. {
  130. if (_timing == EffectTiming.None)
  131. {
  132. return changeCostClass;
  133. }
  134. return null;
  135. }
  136. bool CanUseCondition1(Hashtable hashtable) => true;
  137. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  138. {
  139. if (CardSourceCondition(cardSource)
  140. && RootCondition(root)
  141. && PermanentsCondition(targetPermanents))
  142. {
  143. Cost -= 3;
  144. }
  145. return Cost;
  146. }
  147. bool PermanentsCondition(List<Permanent> targetPermanents)
  148. {
  149. return targetPermanents == null || targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0;
  150. }
  151. bool CardSourceCondition(CardSource cardSource)
  152. {
  153. return cardSource.IsDigimon
  154. && (cardSource.CardColors.Contains(CardColor.Blue)
  155. || cardSource.CardColors.Contains(CardColor.Yellow))
  156. && cardSource.HasTSTraits;
  157. }
  158. bool RootCondition(SelectCardEffect.Root root) => true;
  159. bool isUpDown() => true;
  160. #endregion
  161. #region Play card
  162. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  163. cardSources: new List<CardSource>() { selectedCard },
  164. activateClass: activateClass,
  165. payCost: true,
  166. isTapped: false,
  167. root: SelectCardEffect.Root.Hand,
  168. activateETB: true));
  169. #endregion
  170. #region release effect reducing play cost
  171. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  172. #endregion
  173. }
  174. #endregion
  175. }
  176. }
  177. #endregion
  178. #region Security Effect
  179. if (timing == EffectTiming.SecuritySkill)
  180. {
  181. ActivateClass activateClass = new ActivateClass();
  182. activateClass.SetUpICardEffect($"Play 1 lvl 4- Blue or Yellow [TS] Digimon card from hand", CanUseCondition, card);
  183. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  184. activateClass.SetIsSecurityEffect(true);
  185. cardEffects.Add(activateClass);
  186. string EffectDescription()
  187. => "[Security] You may play 1 level 4 or lower blue or yellow [TS] trait Digimon card from your hand or trash without paying the cost.";
  188. bool CanUseCondition(Hashtable hashtable)
  189. {
  190. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  191. }
  192. bool CanPlayCondition(CardSource cardSource)
  193. {
  194. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 4
  195. && (cardSource.CardColors.Contains(CardColor.Blue) || cardSource.CardColors.Contains(CardColor.Yellow))
  196. && cardSource.HasTSTraits
  197. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  198. }
  199. IEnumerator ActivateCoroutine(Hashtable hashtable)
  200. {
  201. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlayCondition);
  202. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlayCondition);
  203. if (canSelectHand || canSelectTrash)
  204. {
  205. if (canSelectHand && canSelectTrash)
  206. {
  207. List<SelectionElement<int>> selectionElements1 = new List<SelectionElement<int>>()
  208. {
  209. new (message: $"From hand", value : 1, spriteIndex: 0),
  210. new (message: $"From trash", value : 2, spriteIndex: 1),
  211. new (message: $"Don't play", value: 3, spriteIndex: 2)
  212. };
  213. string selectPlayerMessage1 = "From which area will you play a card?";
  214. string notSelectPlayerMessage1 = "The opponent is choosing from which area to select a card.";
  215. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  216. }
  217. else
  218. {
  219. GManager.instance.userSelectionManager.SetInt(canSelectHand ? 1 : 2);
  220. }
  221. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  222. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  223. bool fromTrash = GManager.instance.userSelectionManager.SelectedIntValue == 2;
  224. List<CardSource> selectedCards = new List<CardSource>();
  225. IEnumerator SelectCardCoroutine(CardSource cardSource)
  226. {
  227. selectedCards.Add(cardSource);
  228. yield return null;
  229. }
  230. if (fromHand)
  231. {
  232. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  233. selectHandEffect.SetUp(
  234. selectPlayer: card.Owner,
  235. canTargetCondition: CanPlayCondition,
  236. canTargetCondition_ByPreSelecetedList: null,
  237. canEndSelectCondition: null,
  238. maxCount: 1,
  239. canNoSelect: true,
  240. canEndNotMax: false,
  241. isShowOpponent: true,
  242. selectCardCoroutine: SelectCardCoroutine,
  243. afterSelectCardCoroutine: null,
  244. mode: SelectHandEffect.Mode.Custom,
  245. cardEffect: activateClass);
  246. selectHandEffect.SetUpCustomMessage("Select 1 digimon to play", "The opponent is selecting 1 digimon to play");
  247. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  248. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  249. selectedCards,
  250. activateClass: activateClass,
  251. payCost: false,
  252. isTapped: false,
  253. root: SelectCardEffect.Root.Hand,
  254. activateETB: true));
  255. }
  256. if (fromTrash)
  257. {
  258. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  259. selectCardEffect.SetUp(
  260. canTargetCondition: CanPlayCondition,
  261. canTargetCondition_ByPreSelecetedList: null,
  262. canEndSelectCondition: null,
  263. canNoSelect: () => true,
  264. selectCardCoroutine: SelectCardCoroutine,
  265. afterSelectCardCoroutine: null,
  266. message: "Select 1 digimon to play",
  267. maxCount: 1,
  268. canEndNotMax: false,
  269. isShowOpponent: true,
  270. mode: SelectCardEffect.Mode.Custom,
  271. root: SelectCardEffect.Root.Trash,
  272. customRootCardList: null,
  273. canLookReverseCard: true,
  274. selectPlayer: card.Owner,
  275. cardEffect: activateClass);
  276. selectCardEffect.SetUpCustomMessage("Select 1 digimon to play", "The opponent is selecting 1 digimon to play");
  277. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Digimon");
  278. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  279. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  280. selectedCards,
  281. activateClass: activateClass,
  282. payCost: false,
  283. isTapped: false,
  284. root: SelectCardEffect.Root.Trash,
  285. activateETB: true));
  286. }
  287. }
  288. }
  289. }
  290. #endregion
  291. return cardEffects;
  292. }
  293. }
  294. }