BT11_105.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT11
  5. {
  6. public class BT11_105 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. ChangeCostClass changeCostClass = new ChangeCostClass();
  14. changeCostClass.SetUpICardEffect($"Play Cost -1", CanUseCondition, card);
  15. changeCostClass.SetUpChangeCostClass(
  16. changeCostFunc: ChangeCost,
  17. cardSourceCondition: CardSourceCondition,
  18. rootCondition: RootCondition,
  19. isUpDown: isUpDown,
  20. isCheckAvailability: () => false,
  21. isChangePayingCost: () => true);
  22. cardEffects.Add(changeCostClass);
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardNames.Contains("Snatchmon"));
  26. }
  27. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  28. {
  29. if (CardSourceCondition(cardSource))
  30. {
  31. if (RootCondition(root))
  32. {
  33. if (PermanentsCondition(targetPermanents))
  34. {
  35. Cost -= 1;
  36. }
  37. }
  38. }
  39. return Cost;
  40. }
  41. bool PermanentsCondition(List<Permanent> targetPermanents)
  42. {
  43. return true;
  44. }
  45. bool CardSourceCondition(CardSource cardSource)
  46. {
  47. return cardSource == card;
  48. }
  49. bool RootCondition(SelectCardEffect.Root root)
  50. {
  51. return true;
  52. }
  53. bool isUpDown()
  54. {
  55. return true;
  56. }
  57. }
  58. if (timing == EffectTiming.OptionSkill)
  59. {
  60. ActivateClass activateClass = new ActivateClass();
  61. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  62. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  63. cardEffects.Add(activateClass);
  64. string EffectDiscription()
  65. {
  66. return "[Main] By placing 1 [Vemmon] or [Destromon] from your trash under 1 of your Digimon as its bottom digivolution card, you may digivolve 1 of your Digimon into 1 [Destromon] or [Galacticmon] from your trash for its digivolution cost.";
  67. }
  68. bool CanSelectCardCondition(CardSource cardSource)
  69. {
  70. return cardSource.CardNames.Contains("Vemmon") || cardSource.CardNames.Contains("Destromon");
  71. }
  72. bool CanSelectPermanentCondition(Permanent permanent)
  73. {
  74. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  75. {
  76. if (!permanent.IsToken)
  77. {
  78. return true;
  79. }
  80. }
  81. return false;
  82. }
  83. bool CanSelectCardCondition1(CardSource cardSource)
  84. {
  85. return cardSource.CardNames.Contains("Destromon") || cardSource.CardNames.Contains("Galacticmon");
  86. }
  87. bool CanSelectPermanentCondition1(Permanent permanent)
  88. {
  89. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  90. {
  91. foreach (CardSource cardSource in permanent.TopCard.Owner.TrashCards)
  92. {
  93. if (CanSelectCardCondition1(cardSource))
  94. {
  95. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, root: SelectCardEffect.Root.Trash))
  96. {
  97. return true;
  98. }
  99. }
  100. }
  101. }
  102. return false;
  103. }
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  107. }
  108. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  109. {
  110. bool digivolutionCardAdded = false;
  111. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  112. {
  113. List<CardSource> selectedCards = new List<CardSource>();
  114. int maxCount = 1;
  115. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  116. selectCardEffect.SetUp(
  117. canTargetCondition: CanSelectCardCondition,
  118. canTargetCondition_ByPreSelecetedList: null,
  119. canEndSelectCondition: null,
  120. canNoSelect: () => true,
  121. selectCardCoroutine: SelectCardCoroutine,
  122. afterSelectCardCoroutine: null,
  123. message: "Select 1 card to place at the bottom of digivolution cards.",
  124. maxCount: maxCount,
  125. canEndNotMax: false,
  126. isShowOpponent: true,
  127. mode: SelectCardEffect.Mode.Custom,
  128. root: SelectCardEffect.Root.Trash,
  129. customRootCardList: null,
  130. canLookReverseCard: true,
  131. selectPlayer: card.Owner,
  132. cardEffect: activateClass);
  133. selectCardEffect.SetUpCustomMessage(
  134. "Select 1 card to place at the bottom of digivolution cards.",
  135. "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  136. yield return StartCoroutine(selectCardEffect.Activate());
  137. IEnumerator SelectCardCoroutine(CardSource cardSource)
  138. {
  139. selectedCards.Add(cardSource);
  140. yield return null;
  141. }
  142. if (selectedCards.Count >= 1)
  143. {
  144. maxCount = 1;
  145. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  146. selectPermanentEffect.SetUp(
  147. selectPlayer: card.Owner,
  148. canTargetCondition: CanSelectPermanentCondition,
  149. canTargetCondition_ByPreSelecetedList: null,
  150. canEndSelectCondition: null,
  151. maxCount: maxCount,
  152. canNoSelect: true,
  153. canEndNotMax: false,
  154. selectPermanentCoroutine: SelectPermanentCoroutine,
  155. afterSelectPermanentCoroutine: null,
  156. mode: SelectPermanentEffect.Mode.Custom,
  157. cardEffect: activateClass);
  158. selectPermanentEffect.SetUpCustomMessage(
  159. "Select 1 Digimon that will get a digivolution card.",
  160. "The opponent is selecting 1 Digimon that will get a digivolution card.");
  161. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  162. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  163. {
  164. Permanent selectedPermanent = permanent;
  165. if (selectedPermanent != null)
  166. {
  167. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(
  168. selectedCards,
  169. activateClass));
  170. digivolutionCardAdded = true;
  171. }
  172. }
  173. }
  174. }
  175. if (digivolutionCardAdded)
  176. {
  177. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  178. {
  179. Permanent selectedPermanent = null;
  180. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  181. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  182. selectPermanentEffect.SetUp(
  183. selectPlayer: card.Owner,
  184. canTargetCondition: CanSelectPermanentCondition1,
  185. canTargetCondition_ByPreSelecetedList: null,
  186. canEndSelectCondition: null,
  187. maxCount: maxCount,
  188. canNoSelect: true,
  189. canEndNotMax: false,
  190. selectPermanentCoroutine: SelectPermanentCoroutine,
  191. afterSelectPermanentCoroutine: null,
  192. mode: SelectPermanentEffect.Mode.Custom,
  193. cardEffect: activateClass);
  194. selectPermanentEffect.SetUpCustomMessage(
  195. "Select 1 Digimon that will digivolve.",
  196. "The opponent is selecting 1 Digimon that will digivolve.");
  197. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  198. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  199. {
  200. selectedPermanent = permanent;
  201. yield return null;
  202. }
  203. if (selectedPermanent != null)
  204. {
  205. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  206. targetPermanent: selectedPermanent,
  207. cardCondition: CanSelectCardCondition1,
  208. payCost: true,
  209. reduceCostTuple: null,
  210. fixedCostTuple: null,
  211. ignoreDigivolutionRequirementFixedCost: -1,
  212. isHand: false,
  213. activateClass: activateClass,
  214. successProcess: null));
  215. }
  216. }
  217. }
  218. }
  219. }
  220. if (timing == EffectTiming.SecuritySkill)
  221. {
  222. ActivateClass activateClass = new ActivateClass();
  223. activateClass.SetUpICardEffect($"Reveal the top 3 cards of deck", CanUseCondition, card);
  224. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  225. activateClass.SetIsSecurityEffect(true);
  226. cardEffects.Add(activateClass);
  227. string EffectDiscription()
  228. {
  229. return "[Security] You may reveal the top 3 cards of your deck. Play 1 [Vemmon] among them without paying the cost. Trash the rest.";
  230. }
  231. bool CanSelectCardCondition(CardSource cardSource)
  232. {
  233. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  234. {
  235. if (cardSource.CardNames.Contains("Vemmon"))
  236. {
  237. return true;
  238. }
  239. }
  240. return false;
  241. }
  242. bool CanUseCondition(Hashtable hashtable)
  243. {
  244. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  245. }
  246. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  247. {
  248. if (card.Owner.LibraryCards.Count == 0) yield break;
  249. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  250. {
  251. new SelectionElement<bool>(message: $"Reveal", value : true, spriteIndex: 0),
  252. new SelectionElement<bool>(message: $"Not reveal", value : false, spriteIndex: 1),
  253. };
  254. string selectPlayerMessage = "Will you reveal your deck?";
  255. string notSelectPlayerMessage = "The opponent is choosing whether to reveal deck.";
  256. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  257. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  258. bool doReveal = GManager.instance.userSelectionManager.SelectedBoolValue;
  259. if (!doReveal)
  260. {
  261. yield break;
  262. }
  263. List<CardSource> selectedCards = new List<CardSource>();
  264. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  265. revealCount: 3,
  266. simplifiedSelectCardConditions:
  267. new SimplifiedSelectCardConditionClass[]
  268. {
  269. new SimplifiedSelectCardConditionClass(
  270. canTargetCondition:CanSelectCardCondition,
  271. message: "Select 1 [Vemmon].",
  272. mode: SelectCardEffect.Mode.Custom,
  273. maxCount: 1,
  274. selectCardCoroutine: SelectCardCoroutine),
  275. },
  276. remainingCardsPlace: RemainingCardsPlace.Trash,
  277. activateClass: activateClass,
  278. canNoSelect: true
  279. ));
  280. IEnumerator SelectCardCoroutine(CardSource cardSource)
  281. {
  282. selectedCards.Add(cardSource);
  283. yield return null;
  284. }
  285. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  286. cardSources: selectedCards,
  287. activateClass: activateClass,
  288. payCost: false,
  289. isTapped: false,
  290. root: SelectCardEffect.Root.Library,
  291. activateETB: true));
  292. }
  293. }
  294. return cardEffects;
  295. }
  296. }
  297. }