BT21_071.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //BT21_071 Scopemon
  6. namespace DCGO.CardEffects.BT21
  7. {
  8. public class BT21_071 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition - Stnd.
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsTraits("Stnd.");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Alternative Digivolution Condition - Three Musketeers
  24. if (timing == EffectTiming.None)
  25. {
  26. bool Condition(Permanent permanent)
  27. {
  28. return permanent.TopCard.HasText("Three Musketeers") && permanent.Level == 3;
  29. }
  30. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(Condition, 2, false, card, null));
  31. }
  32. #endregion
  33. #region On Play/When Digivolving shared
  34. bool CanTuckCondition(CardSource card)
  35. {
  36. return card.EqualsTraits("Appmon") || card.HasThreeMusketeersTraits;
  37. }
  38. bool CanActivateConditionShared(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  41. (card.Owner.HandCards.Count >= 1 || card.Owner.TrashCards.Count >= 1) &&
  42. CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanTuckUnderCondition);
  43. }
  44. bool CanTuckUnderCondition(Permanent permanent)
  45. {
  46. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && !permanent.IsToken;
  47. }
  48. #endregion
  49. #region On Play
  50. if(timing == EffectTiming.OnEnterFieldAnyone)
  51. {
  52. ActivateClass activateClass = new ActivateClass();
  53. activateClass.SetUpICardEffect("Tuck appmon/muskets for memory", CanUseCondition, card);
  54. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, true, EffectDescription());
  55. cardEffects.Add(activateClass);
  56. string EffectDescription()
  57. {
  58. return "[On Play] By placing 1 card with the [Appmon] or [Three Musketeers] trait from your hand or trash as 1 of your Digimon's bottom digivolution card, gain 1 memory.";
  59. }
  60. bool CanUseCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  65. {
  66. bool canSelectHand = card.Owner.HandCards.Count(CanTuckCondition) >= 1;
  67. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanTuckCondition);
  68. if (canSelectHand || canSelectTrash)
  69. {
  70. if (canSelectHand && canSelectTrash)
  71. {
  72. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  73. {
  74. new(message: "From hand", value: true, spriteIndex: 0),
  75. new(message: "From trash", value: false, spriteIndex: 1),
  76. };
  77. string selectPlayerMessage = "From which area do you select a card?";
  78. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  79. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  80. }
  81. else
  82. {
  83. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  84. }
  85. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  86. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  87. List<CardSource> selectedCards = new List<CardSource>();
  88. IEnumerator SelectCardCoroutine(CardSource cardSource)
  89. {
  90. selectedCards.Add(cardSource);
  91. yield return null;
  92. }
  93. if (fromHand)
  94. {
  95. int maxCount = 1;
  96. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  97. selectHandEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: CanTuckCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: true,
  104. canEndNotMax: false,
  105. isShowOpponent: true,
  106. selectCardCoroutine: SelectCardCoroutine,
  107. afterSelectCardCoroutine: null,
  108. mode: SelectHandEffect.Mode.Custom,
  109. cardEffect: activateClass);
  110. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  111. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  112. yield return StartCoroutine(selectHandEffect.Activate());
  113. }
  114. else
  115. {
  116. int maxCount = 1;
  117. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  118. selectCardEffect.SetUp(
  119. canTargetCondition: CanTuckCondition,
  120. canTargetCondition_ByPreSelecetedList: null,
  121. canEndSelectCondition: null,
  122. canNoSelect: () => true,
  123. selectCardCoroutine: SelectCardCoroutine,
  124. afterSelectCardCoroutine: null,
  125. message: "Select 1 card to place on bottom of digivolution cards.",
  126. maxCount: maxCount,
  127. canEndNotMax: false,
  128. isShowOpponent: true,
  129. mode: SelectCardEffect.Mode.Custom,
  130. root: SelectCardEffect.Root.Trash,
  131. customRootCardList: null,
  132. canLookReverseCard: true,
  133. selectPlayer: card.Owner,
  134. cardEffect: activateClass);
  135. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  136. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  137. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  138. }
  139. if (selectedCards.Count >= 1)
  140. {
  141. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanTuckUnderCondition));
  142. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  143. selectPermanentEffect.SetUp(
  144. selectPlayer: card.Owner,
  145. canTargetCondition: CanTuckUnderCondition,
  146. canTargetCondition_ByPreSelecetedList: null,
  147. canEndSelectCondition: null,
  148. maxCount: maxCount,
  149. canNoSelect: true,
  150. canEndNotMax: false,
  151. selectPermanentCoroutine: SelectPermanentCoroutine,
  152. afterSelectPermanentCoroutine: null,
  153. mode: SelectPermanentEffect.Mode.Custom,
  154. cardEffect: activateClass);
  155. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  156. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  157. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  158. {
  159. Permanent selectedPermanent = permanent;
  160. if (selectedPermanent != null)
  161. {
  162. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCards[0] }, activateClass));
  163. yield return ContinuousController.instance.StartCoroutine(
  164. card.Owner.AddMemory(1, activateClass));
  165. }
  166. }
  167. }
  168. }
  169. }
  170. }
  171. #endregion
  172. #region When Digivolving
  173. if (timing == EffectTiming.OnEnterFieldAnyone)
  174. {
  175. ActivateClass activateClass = new ActivateClass();
  176. activateClass.SetUpICardEffect("Tuck appmon/muskets for memory", CanUseCondition, card);
  177. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, true, EffectDescription());
  178. cardEffects.Add(activateClass);
  179. string EffectDescription()
  180. {
  181. return "[When Digivolving] By placing 1 card with the [Appmon] or [Three Musketeers] trait from your hand or trash as 1 of your Digimon's bottom digivolution card, gain 1 memory.";
  182. }
  183. bool CanUseCondition(Hashtable hashtable)
  184. {
  185. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  186. }
  187. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  188. {
  189. bool canSelectHand = card.Owner.HandCards.Count(CanTuckCondition) >= 1;
  190. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanTuckCondition);
  191. if (canSelectHand || canSelectTrash)
  192. {
  193. if (canSelectHand && canSelectTrash)
  194. {
  195. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  196. {
  197. new(message: "From hand", value: true, spriteIndex: 0),
  198. new(message: "From trash", value: false, spriteIndex: 1),
  199. };
  200. string selectPlayerMessage = "From which area do you select a card?";
  201. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  202. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  203. }
  204. else
  205. {
  206. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  207. }
  208. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  209. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  210. List<CardSource> selectedCards = new List<CardSource>();
  211. IEnumerator SelectCardCoroutine(CardSource cardSource)
  212. {
  213. selectedCards.Add(cardSource);
  214. yield return null;
  215. }
  216. if (fromHand)
  217. {
  218. int maxCount = 1;
  219. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  220. selectHandEffect.SetUp(
  221. selectPlayer: card.Owner,
  222. canTargetCondition: CanTuckCondition,
  223. canTargetCondition_ByPreSelecetedList: null,
  224. canEndSelectCondition: null,
  225. maxCount: maxCount,
  226. canNoSelect: true,
  227. canEndNotMax: false,
  228. isShowOpponent: true,
  229. selectCardCoroutine: SelectCardCoroutine,
  230. afterSelectCardCoroutine: null,
  231. mode: SelectHandEffect.Mode.Custom,
  232. cardEffect: activateClass);
  233. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  234. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  235. yield return StartCoroutine(selectHandEffect.Activate());
  236. }
  237. else
  238. {
  239. int maxCount = 1;
  240. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  241. selectCardEffect.SetUp(
  242. canTargetCondition: CanTuckCondition,
  243. canTargetCondition_ByPreSelecetedList: null,
  244. canEndSelectCondition: null,
  245. canNoSelect: () => true,
  246. selectCardCoroutine: SelectCardCoroutine,
  247. afterSelectCardCoroutine: null,
  248. message: "Select 1 card to place on bottom of digivolution cards.",
  249. maxCount: maxCount,
  250. canEndNotMax: false,
  251. isShowOpponent: true,
  252. mode: SelectCardEffect.Mode.Custom,
  253. root: SelectCardEffect.Root.Trash,
  254. customRootCardList: null,
  255. canLookReverseCard: true,
  256. selectPlayer: card.Owner,
  257. cardEffect: activateClass);
  258. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  259. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  260. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  261. }
  262. if (selectedCards.Count >= 1)
  263. {
  264. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanTuckUnderCondition));
  265. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  266. selectPermanentEffect.SetUp(
  267. selectPlayer: card.Owner,
  268. canTargetCondition: CanTuckUnderCondition,
  269. canTargetCondition_ByPreSelecetedList: null,
  270. canEndSelectCondition: null,
  271. maxCount: maxCount,
  272. canNoSelect: true,
  273. canEndNotMax: false,
  274. selectPermanentCoroutine: SelectPermanentCoroutine,
  275. afterSelectPermanentCoroutine: null,
  276. mode: SelectPermanentEffect.Mode.Custom,
  277. cardEffect: activateClass);
  278. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  279. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  280. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  281. {
  282. Permanent selectedPermanent = permanent;
  283. if (selectedPermanent != null)
  284. {
  285. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCards[0] }, activateClass));
  286. yield return ContinuousController.instance.StartCoroutine(
  287. card.Owner.AddMemory(1, activateClass));
  288. }
  289. }
  290. }
  291. }
  292. }
  293. }
  294. #endregion
  295. #region Generic link capacity/condition
  296. if (timing == EffectTiming.OnDeclaration)
  297. {
  298. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  299. }
  300. if (timing == EffectTiming.None)
  301. {
  302. bool PermanentCondition(Permanent permanent)
  303. {
  304. return permanent.TopCard.HasAppmonTraits;
  305. }
  306. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 2, card: card));
  307. }
  308. #endregion
  309. #region When Linking
  310. if (timing == EffectTiming.WhenLinked)
  311. {
  312. ActivateClass activateClass = new ActivateClass();
  313. activateClass.SetUpICardEffect("Trash 2 draw 2", CanUseCondition, card);
  314. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  315. activateClass.SetIsLinkedEffect(true);
  316. cardEffects.Add(activateClass);
  317. string EffectDiscription()
  318. {
  319. return "[When Linking] <Draw 2> and trash 2 cards in your hand.";
  320. }
  321. bool CanUseCondition(Hashtable hashtable)
  322. {
  323. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  324. }
  325. bool CanActivateCondition(Hashtable hashtable)
  326. {
  327. return isExistOnField(card);
  328. }
  329. IEnumerator ActivateCoroutine(Hashtable hashtable)
  330. {
  331. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  332. if (card.Owner.HandCards.Count >= 1)
  333. {
  334. int discardCount = Math.Min(2, card.Owner.HandCards.Count);
  335. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  336. selectHandEffect.SetUp(
  337. selectPlayer: card.Owner,
  338. canTargetCondition: (cardSource) => true,
  339. canTargetCondition_ByPreSelecetedList: null,
  340. canEndSelectCondition: null,
  341. maxCount: discardCount,
  342. canNoSelect: false,
  343. canEndNotMax: false,
  344. isShowOpponent: true,
  345. selectCardCoroutine: null,
  346. afterSelectCardCoroutine: null,
  347. mode: SelectHandEffect.Mode.Discard,
  348. cardEffect: activateClass);
  349. yield return StartCoroutine(selectHandEffect.Activate());
  350. }
  351. }
  352. }
  353. #endregion
  354. return cardEffects;
  355. }
  356. }
  357. }