BT24_094.cs 17 KB

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