BT14_093.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT14
  6. {
  7. public class BT14_093 : 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] Search your security stack. 1 of your Digimon may digivolve into 1 yellow level 6 or lower Digimon card with the [Vaccine] trait among them without paying the cost. Then, shuffle your security stack. If digivolved by this effect, and you have a Tamer with [T.K. Takaishi] in its name, <Recovery +1 (Deck)>.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent, CardSource cardSource)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  25. {
  26. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  27. {
  28. return true;
  29. }
  30. }
  31. return false;
  32. }
  33. bool CanSelectCardCondition(CardSource cardSource)
  34. {
  35. if (cardSource.CardTraits.Contains("Vaccine"))
  36. {
  37. if (cardSource.HasCardColor(CardColor.Yellow))
  38. {
  39. if (cardSource.Level <= 6)
  40. {
  41. if (cardSource.HasLevel)
  42. {
  43. if (cardSource.IsDigimon)
  44. {
  45. if (card.Owner.GetBattleAreaPermanents().Some(permanent => CanSelectPermanentCondition(permanent, cardSource)))
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. }
  52. }
  53. }
  54. return false;
  55. }
  56. bool PermanentCondition(Permanent permanent)
  57. {
  58. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  59. {
  60. if (permanent.IsTamer)
  61. {
  62. if (permanent.TopCard.ContainsCardName("T.K. Takaishi"))
  63. {
  64. return true;
  65. }
  66. }
  67. }
  68. return false;
  69. }
  70. bool CanUseCondition(Hashtable hashtable)
  71. {
  72. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  75. {
  76. if (card.Owner.SecurityCards.Count >= 1)
  77. {
  78. Permanent selectedPermanent = null;
  79. int maxCount = Math.Min(1, card.Owner.SecurityCards.Count);
  80. CardSource selectedCard = null;
  81. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  82. selectCardEffect.SetUp(
  83. canTargetCondition: CanSelectCardCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. canNoSelect: () => true,
  87. selectCardCoroutine: SelectCardCoroutine,
  88. afterSelectCardCoroutine: null,
  89. message: "Select 1 card to digivolve.",
  90. maxCount: maxCount,
  91. canEndNotMax: false,
  92. isShowOpponent: true,
  93. mode: SelectCardEffect.Mode.Custom,
  94. root: SelectCardEffect.Root.Security,
  95. customRootCardList: null,
  96. canLookReverseCard: true,
  97. selectPlayer: card.Owner,
  98. cardEffect: activateClass);
  99. selectCardEffect.SetIsSecurity();
  100. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  101. IEnumerator SelectCardCoroutine(CardSource cardSource)
  102. {
  103. selectedCard = cardSource;
  104. yield return null;
  105. }
  106. if (selectedCard != null)
  107. {
  108. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = true;
  109. maxCount = Math.Min(
  110. 1,
  111. CardEffectCommons.MatchConditionPermanentCount(permanent => CanSelectPermanentCondition(permanent, selectedCard)));
  112. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  113. selectPermanentEffect.SetUp(
  114. selectPlayer: card.Owner,
  115. canTargetCondition: permanent => CanSelectPermanentCondition(permanent, selectedCard),
  116. canTargetCondition_ByPreSelecetedList: null,
  117. canEndSelectCondition: null,
  118. maxCount: maxCount,
  119. canNoSelect: false,
  120. canEndNotMax: false,
  121. selectPermanentCoroutine: SelectPermanentCoroutine,
  122. afterSelectPermanentCoroutine: null,
  123. mode: SelectPermanentEffect.Mode.Custom,
  124. cardEffect: activateClass);
  125. selectPermanentEffect.SetUpCustomMessage(
  126. "Select 1 Digimon that will digivolve.",
  127. "The opponent is selecting 1 Digimon that will digivolve.");
  128. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  129. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  130. {
  131. selectedPermanent = permanent;
  132. yield return null;
  133. }
  134. if (selectedPermanent != null)
  135. {
  136. if (selectedCard.CanPlayCardTargetFrame(
  137. selectedPermanent.PermanentFrame,
  138. PayCost: false,
  139. activateClass,
  140. root: SelectCardEffect.Root.Security))
  141. {
  142. PlayCardClass playCardClass = new PlayCardClass(
  143. cardSources: new List<CardSource>() { selectedCard },
  144. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  145. payCost: false,
  146. targetPermanent: selectedPermanent,
  147. isTapped: false,
  148. root: SelectCardEffect.Root.Security,
  149. activateETB: true);
  150. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  151. }
  152. }
  153. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = false;
  154. }
  155. ContinuousController.instance.PlaySE(GManager.instance.ShuffleSE);
  156. card.Owner.SecurityCards = RandomUtility.ShuffledDeckCards(card.Owner.SecurityCards);
  157. if (CardEffectCommons.IsDigivolvedByTheEffect(selectedPermanent, selectedCard, activateClass))
  158. {
  159. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition))
  160. {
  161. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  162. }
  163. }
  164. }
  165. }
  166. }
  167. if (timing == EffectTiming.SecuritySkill)
  168. {
  169. ActivateClass activateClass = new ActivateClass();
  170. activateClass.SetUpICardEffect($"Play 1 [Patamon] from hand or trash and add this card to hand", CanUseCondition, card);
  171. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  172. activateClass.SetIsSecurityEffect(true);
  173. cardEffects.Add(activateClass);
  174. string EffectDiscription()
  175. {
  176. return "[Security] You may play 1 [Patamon] from your hand or trash without paying the cost. Then, add this card to the hand.";
  177. }
  178. bool CanSelectCardCondition(CardSource cardSource)
  179. {
  180. if (cardSource.CardNames.Contains("Patamon"))
  181. {
  182. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  183. {
  184. return true;
  185. }
  186. }
  187. return false;
  188. }
  189. bool CanUseCondition(Hashtable hashtable)
  190. {
  191. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  192. }
  193. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  194. {
  195. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  196. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  197. if (canSelectHand || canSelectTrash)
  198. {
  199. if (canSelectHand && canSelectTrash)
  200. {
  201. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  202. {
  203. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  204. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  205. };
  206. string selectPlayerMessage = "From which area do you play a card?";
  207. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  208. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  209. }
  210. else
  211. {
  212. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  213. }
  214. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  215. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  216. List<CardSource> selectedCards = new List<CardSource>();
  217. IEnumerator SelectCardCoroutine(CardSource cardSource)
  218. {
  219. selectedCards.Add(cardSource);
  220. yield return null;
  221. }
  222. if (fromHand)
  223. {
  224. int maxCount = 1;
  225. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  226. selectHandEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: CanSelectCardCondition,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: maxCount,
  232. canNoSelect: true,
  233. canEndNotMax: false,
  234. isShowOpponent: true,
  235. selectCardCoroutine: SelectCardCoroutine,
  236. afterSelectCardCoroutine: null,
  237. mode: SelectHandEffect.Mode.Custom,
  238. cardEffect: activateClass);
  239. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  240. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  241. yield return StartCoroutine(selectHandEffect.Activate());
  242. }
  243. else
  244. {
  245. int maxCount = 1;
  246. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  247. selectCardEffect.SetUp(
  248. canTargetCondition: CanSelectCardCondition,
  249. canTargetCondition_ByPreSelecetedList: null,
  250. canEndSelectCondition: null,
  251. canNoSelect: () => true,
  252. selectCardCoroutine: SelectCardCoroutine,
  253. afterSelectCardCoroutine: null,
  254. message: "Select 1 card to play.",
  255. maxCount: maxCount,
  256. canEndNotMax: false,
  257. isShowOpponent: true,
  258. mode: SelectCardEffect.Mode.Custom,
  259. root: SelectCardEffect.Root.Trash,
  260. customRootCardList: null,
  261. canLookReverseCard: true,
  262. selectPlayer: card.Owner,
  263. cardEffect: activateClass);
  264. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  265. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  266. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  267. }
  268. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  269. if (!fromHand)
  270. {
  271. root = SelectCardEffect.Root.Trash;
  272. }
  273. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  274. cardSources: selectedCards,
  275. activateClass: activateClass,
  276. payCost: false,
  277. isTapped: false,
  278. root: root,
  279. activateETB: true));
  280. }
  281. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  282. }
  283. }
  284. return cardEffects;
  285. }
  286. }
  287. }