BT15_096.cs 15 KB

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