BT16_099.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT16
  6. {
  7. public class BT16_099 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Option Skill
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] Reveal the top 3 cards of your deck. Add 1 card with the [SoC] trait among them to your hand. Place the remaining cards at the bottom of your deck in any order. Then, place this card in your battle area.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.ContainsTraits("SoC"))
  26. {
  27. return true;
  28. }
  29. return false;
  30. }
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  34. }
  35. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  36. {
  37. bool added = false;
  38. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  39. revealCount: 3,
  40. simplifiedSelectCardConditions:
  41. new SimplifiedSelectCardConditionClass[]
  42. {
  43. new SimplifiedSelectCardConditionClass(
  44. canTargetCondition:CanSelectCardCondition,
  45. message: "Select 1 card with the [SoC] trait.",
  46. mode: SelectCardEffect.Mode.AddHand,
  47. maxCount: 1,
  48. selectCardCoroutine: null),
  49. },
  50. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  51. activateClass: activateClass,
  52. revealedCardsCoroutine: RevealedCardsCoroutine
  53. ));
  54. IEnumerator RevealedCardsCoroutine(List<CardSource> revealedCards)
  55. {
  56. added = revealedCards.Count(CanSelectCardCondition) >= 1;
  57. yield return null;
  58. }
  59. if (added)
  60. {
  61. if (card.Owner.HandCards.Count >= 1)
  62. {
  63. int discardCount = 1;
  64. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  65. selectHandEffect.SetUp(
  66. selectPlayer: card.Owner,
  67. canTargetCondition: (cardSource) => true,
  68. canTargetCondition_ByPreSelecetedList: null,
  69. canEndSelectCondition: null,
  70. maxCount: discardCount,
  71. canNoSelect: false,
  72. canEndNotMax: false,
  73. isShowOpponent: true,
  74. selectCardCoroutine: null,
  75. afterSelectCardCoroutine: null,
  76. mode: SelectHandEffect.Mode.Discard,
  77. cardEffect: activateClass);
  78. yield return StartCoroutine(selectHandEffect.Activate());
  79. }
  80. }
  81. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  82. }
  83. }
  84. #endregion
  85. #region Main - Delay
  86. if (timing == EffectTiming.OnDeclaration)
  87. {
  88. ActivateClass activateClass = new ActivateClass();
  89. activateClass.SetUpICardEffect("Play 1 card from trash", CanUseCondition, card);
  90. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription());
  91. cardEffects.Add(activateClass);
  92. string EffectDiscription()
  93. {
  94. return "[Main] You may play 1 card with the [SoC] trait from your trash with the play cost reduced by 2.";
  95. }
  96. bool CanSelectCardCondition(CardSource cardSource)
  97. {
  98. if (cardSource.HasPlayCost && cardSource.ContainsTraits("SoC"))
  99. {
  100. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass))
  101. {
  102. return true;
  103. }
  104. }
  105. return false;
  106. }
  107. bool CanUseCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.CanDeclareOptionDelayEffect(card);
  110. }
  111. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  112. {
  113. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  114. IEnumerator SuccessProcess()
  115. {
  116. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  117. {
  118. new SelectionElement<bool>(message: $"Play Card", value : true, spriteIndex: 0),
  119. new SelectionElement<bool>(message: $"Not Play Card", value : false, spriteIndex: 1),
  120. };
  121. string selectPlayerMessage = "Will you play a card from trash?";
  122. string notSelectPlayerMessage = "The opponent is deciding to play a card from trash.";
  123. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  124. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  125. bool isPlaying = GManager.instance.userSelectionManager.SelectedBoolValue;
  126. if (isPlaying)
  127. {
  128. #region reduce play cost
  129. ChangeCostClass changeCostClass = new ChangeCostClass();
  130. changeCostClass.SetUpICardEffect($"Play Cost -2", CanUseCondition1, card);
  131. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  132. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  133. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  134. ICardEffect GetCardEffect(EffectTiming _timing)
  135. {
  136. if (_timing == EffectTiming.None)
  137. {
  138. return changeCostClass;
  139. }
  140. return null;
  141. }
  142. bool CanUseCondition1(Hashtable hashtable)
  143. {
  144. return true;
  145. }
  146. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  147. {
  148. if (CardSourceCondition(cardSource))
  149. {
  150. if (RootCondition(root))
  151. {
  152. if (PermanentsCondition(targetPermanents))
  153. {
  154. Cost -= 2;
  155. }
  156. }
  157. }
  158. return Cost;
  159. }
  160. bool PermanentsCondition(List<Permanent> targetPermanents)
  161. {
  162. if (targetPermanents == null)
  163. {
  164. return true;
  165. }
  166. else
  167. {
  168. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  169. {
  170. return true;
  171. }
  172. }
  173. return false;
  174. }
  175. bool CardSourceCondition(CardSource cardSource)
  176. {
  177. if (cardSource.HasPlayCost)
  178. {
  179. if (cardSource.ContainsTraits("SoC"))
  180. {
  181. return true;
  182. }
  183. }
  184. return false;
  185. }
  186. bool RootCondition(SelectCardEffect.Root root)
  187. {
  188. return true;
  189. }
  190. bool isUpDown()
  191. {
  192. return true;
  193. }
  194. #endregion
  195. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1)
  196. {
  197. List<CardSource> selectedCards = new List<CardSource>();
  198. int maxCount = 1;
  199. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  200. selectCardEffect.SetUp(
  201. selectPlayer: card.Owner,
  202. canTargetCondition: CanSelectCardCondition,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. maxCount: maxCount,
  206. message: "Select 1 card to play.",
  207. canNoSelect: () => true,
  208. canEndNotMax: false,
  209. isShowOpponent: true,
  210. selectCardCoroutine: SelectCardCoroutine,
  211. afterSelectCardCoroutine: null,
  212. mode: SelectCardEffect.Mode.Custom,
  213. root: SelectCardEffect.Root.Trash,
  214. customRootCardList: null,
  215. canLookReverseCard: false,
  216. cardEffect: activateClass);
  217. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  218. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  219. yield return StartCoroutine(selectCardEffect.Activate());
  220. IEnumerator SelectCardCoroutine(CardSource cardSource)
  221. {
  222. selectedCards.Add(cardSource);
  223. yield return null;
  224. }
  225. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  226. cardSources: selectedCards,
  227. activateClass: activateClass,
  228. payCost: true,
  229. isTapped: false,
  230. root: SelectCardEffect.Root.Trash,
  231. activateETB: true));
  232. }
  233. #region Remove Cost effect after use
  234. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  235. #endregion
  236. }
  237. }
  238. }
  239. }
  240. #endregion
  241. #region Security Skill
  242. if (timing == EffectTiming.SecuritySkill)
  243. {
  244. ActivateClass activateClass = new ActivateClass();
  245. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  246. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  247. activateClass.SetIsSecurityEffect(true);
  248. cardEffects.Add(activateClass);
  249. string EffectDiscription()
  250. {
  251. return "[Main] Reveal the top 3 cards of your deck. Add 1 card with the [SoC] trait among them to your hand. Place the remaining cards at the bottom of your deck in any order. Then, place this card in your battle area.";
  252. }
  253. bool CanSelectCardCondition(CardSource cardSource)
  254. {
  255. if (cardSource.ContainsTraits("SoC"))
  256. {
  257. return true;
  258. }
  259. return false;
  260. }
  261. bool CanUseCondition(Hashtable hashtable)
  262. {
  263. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  264. }
  265. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  266. {
  267. bool added = false;
  268. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  269. revealCount: 3,
  270. simplifiedSelectCardConditions:
  271. new SimplifiedSelectCardConditionClass[]
  272. {
  273. new SimplifiedSelectCardConditionClass(
  274. canTargetCondition:CanSelectCardCondition,
  275. message: "Select 1 card with the [SoC] trait.",
  276. mode: SelectCardEffect.Mode.AddHand,
  277. maxCount: 1,
  278. selectCardCoroutine: null),
  279. },
  280. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  281. activateClass: activateClass,
  282. revealedCardsCoroutine: RevealedCardsCoroutine
  283. ));
  284. IEnumerator RevealedCardsCoroutine(List<CardSource> revealedCards)
  285. {
  286. added = revealedCards.Count(CanSelectCardCondition) >= 1;
  287. yield return null;
  288. }
  289. if (added)
  290. {
  291. if (card.Owner.HandCards.Count >= 1)
  292. {
  293. int discardCount = 1;
  294. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  295. selectHandEffect.SetUp(
  296. selectPlayer: card.Owner,
  297. canTargetCondition: (cardSource) => true,
  298. canTargetCondition_ByPreSelecetedList: null,
  299. canEndSelectCondition: null,
  300. maxCount: discardCount,
  301. canNoSelect: false,
  302. canEndNotMax: false,
  303. isShowOpponent: true,
  304. selectCardCoroutine: null,
  305. afterSelectCardCoroutine: null,
  306. mode: SelectHandEffect.Mode.Discard,
  307. cardEffect: activateClass);
  308. yield return StartCoroutine(selectHandEffect.Activate());
  309. }
  310. }
  311. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  312. }
  313. }
  314. #endregion
  315. return cardEffects;
  316. }
  317. }
  318. }