BT25_083.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using static SelectCardEffect;
  6. // LadyDevimon
  7. namespace DCGO.CardEffects.BT25
  8. {
  9. public class BT25_083 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Alt Digivolution
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent permanent)
  18. {
  19. return permanent.TopCard.HasTSTraits || permanent.TopCard.HasText("Three Musketeers");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card, null, level: 4));
  22. }
  23. #endregion
  24. #region OP/WD Shared
  25. string SharedEffectName = "By place 1 [Three Musketeers] trait card from hand or trash as any digimon bottom digivolution card, draw 1";
  26. string SharedEffectDescription(string tag) => $"[{tag}] By placing 1 [Three Musketeers] trait card from your hand or trash as any of your Digimon's bottom digivolution cards, <Draw 1>";
  27. bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass) => CardEffectCommons.HasMatchConditionOwnersHand(card, SharedCanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SharedCanSelectCardCondition);
  28. bool SharedCanSelectCardCondition(CardSource cardSource) => cardSource.HasThreeMusketeersTraits;
  29. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  30. {
  31. bool CanSelectDigimonCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  32. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, SharedCanSelectCardCondition);
  33. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SharedCanSelectCardCondition);
  34. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectDigimonCondition) && (canSelectHand || canSelectTrash))
  35. {
  36. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  37. if (canSelectHand) selectionElements.Add(new SelectionElement<int>("Hand", 1, 0));
  38. if (canSelectTrash) selectionElements.Add(new SelectionElement<int>("Trash", 2, 0));
  39. selectionElements.Add(new SelectionElement<int>("Don't place", 3, 1));
  40. string selectPlayerMessage = "Which place will you take a [Three Musketeers] trait card from?";
  41. string notSelectPlayerMessage = "The opponent is choosing an area to take a [Three Musketeers] trait card from.";
  42. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  43. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  44. bool dontTake = GManager.instance.userSelectionManager.SelectedIntValue == 3;
  45. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  46. if (!dontTake)
  47. {
  48. #region Select 3M card to add digivolution source
  49. CardSource selectedCard = null;
  50. IEnumerator SelectCardCoroutine(CardSource cardSource)
  51. {
  52. selectedCard = cardSource;
  53. yield return null;
  54. }
  55. if (fromHand)
  56. {
  57. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  58. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, SharedCanSelectCardCondition));
  59. selectHandEffect.SetUp(
  60. selectPlayer: card.Owner,
  61. canTargetCondition: SharedCanSelectCardCondition,
  62. canTargetCondition_ByPreSelecetedList: null,
  63. canEndSelectCondition: null,
  64. maxCount: maxCount,
  65. canNoSelect: true,
  66. canEndNotMax: false,
  67. isShowOpponent: true,
  68. selectCardCoroutine: SelectCardCoroutine,
  69. afterSelectCardCoroutine: null,
  70. mode: SelectHandEffect.Mode.Custom,
  71. cardEffect: activateClass);
  72. selectHandEffect.SetUpCustomMessage("Select 1 card to add to digivolution sources.", "The opponent is selecting 1 card to add to digivolution sources.");
  73. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  74. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  75. }
  76. else
  77. {
  78. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  79. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, SharedCanSelectCardCondition));
  80. selectCardEffect.SetUp(
  81. canTargetCondition: SharedCanSelectCardCondition,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. canNoSelect: () => true,
  85. selectCardCoroutine: SelectCardCoroutine,
  86. afterSelectCardCoroutine: null,
  87. message: "Select 1 card to add to digivolution sources",
  88. maxCount: maxCount,
  89. canEndNotMax: false,
  90. isShowOpponent: true,
  91. mode: SelectCardEffect.Mode.Custom,
  92. root: SelectCardEffect.Root.Trash,
  93. customRootCardList: null,
  94. canLookReverseCard: true,
  95. selectPlayer: card.Owner,
  96. cardEffect: activateClass);
  97. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  98. }
  99. #endregion
  100. if (selectedCard != null && CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectDigimonCondition))
  101. {
  102. #region Select digimon to add digivolution source
  103. Permanent selectedPermanent = null;
  104. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  105. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectDigimonCondition));
  106. selectPermanentEffect.SetUp(
  107. selectPlayer: card.Owner,
  108. canTargetCondition: CanSelectDigimonCondition,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. maxCount: maxCount,
  112. canNoSelect: true,
  113. canEndNotMax: false,
  114. selectPermanentCoroutine: SelectPermanentCoroutine,
  115. afterSelectPermanentCoroutine: null,
  116. mode: SelectPermanentEffect.Mode.Custom,
  117. cardEffect: activateClass);
  118. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  119. {
  120. selectedPermanent = permanent;
  121. yield return null;
  122. }
  123. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain digivolution source.", "The opponent is selecting 1 Digimon to gain digivolution source.");
  124. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  125. #endregion
  126. if (selectedPermanent != null)
  127. {
  128. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  129. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  130. }
  131. }
  132. }
  133. }
  134. }
  135. CardEffectFactory.ActivateClassesForSharedEffects
  136. (ref cardEffects, timing, card,
  137. SharedEffectName,
  138. SharedActivateCoroutine,
  139. SharedEffectDescription,
  140. optional: false,
  141. isSkippable: true,
  142. onPlay: true,
  143. whenDigivolving: true,
  144. additionalActivateCondition: AdditionalActivateCondition);
  145. #endregion
  146. #region WD/WA Shared
  147. string SharedEffectName1 = "By trashing 1 option card from any digimon digivolution cards, use 1 [Three Musketeers] trait option card in trash for 3 reduced cost";
  148. string SharedHashString = "BT25_083_WD_WA";
  149. string SharedEffectDescription1(string tag) => $"[{tag}] [Once Per Turn] By trashing 1 Option card from any of your Digimon's digivolution cards, you may use 1 [Three Musketeers] trait Option card from your trash with the cost reduced by 3.";
  150. bool AdditionalActivateCondition2(Hashtable hashtable, ActivateClass activateClass) => CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectDigimonCondition);
  151. bool CanSelectDigimonCondition(Permanent permanent) =>
  152. CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  153. && permanent.DigivolutionCards.Exists(CanSelectOptionCard);
  154. bool CanSelectOptionCard(CardSource cardSource) => cardSource.IsOption;
  155. IEnumerator SharedActivateCoroutine1(Hashtable hashtable, ActivateClass activateClass)
  156. {
  157. bool hasUsed = false;
  158. bool CanSelect3MOptionCard(CardSource cardSource) => cardSource.IsOption
  159. && cardSource.HasThreeMusketeersTraits
  160. && cardSource.PayingCost(Root.Trash, null, checkAvailability: false) <= cardSource.Owner.MaxMemoryCost;
  161. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectDigimonCondition))
  162. {
  163. #region Select digimon to trash option card from digivolution source
  164. Permanent selectedPermanent = null;
  165. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  166. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectDigimonCondition));
  167. selectPermanentEffect.SetUp(
  168. selectPlayer: card.Owner,
  169. canTargetCondition: CanSelectDigimonCondition,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. maxCount: maxCount,
  173. canNoSelect: true,
  174. canEndNotMax: false,
  175. selectPermanentCoroutine: SelectPermanentCoroutine,
  176. afterSelectPermanentCoroutine: null,
  177. mode: SelectPermanentEffect.Mode.Custom,
  178. cardEffect: activateClass);
  179. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  180. {
  181. selectedPermanent = permanent;
  182. yield return null;
  183. }
  184. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to trash 1 option in sources", "The opponent is selecting 1 Digimon to trash 1 option in sources");
  185. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  186. #endregion
  187. if (selectedPermanent != null)
  188. {
  189. #region Select option card to trash from digivolution source
  190. CardSource selectedCard = null;
  191. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  192. selectCardEffect.SetUp(
  193. canTargetCondition: CanSelectOptionCard,
  194. canTargetCondition_ByPreSelecetedList: null,
  195. canEndSelectCondition: null,
  196. canNoSelect: () => true,
  197. selectCardCoroutine: SelectCardCoroutine,
  198. afterSelectCardCoroutine: null,
  199. message: "1 option digivolution card to trash.",
  200. maxCount: 1,
  201. canEndNotMax: false,
  202. isShowOpponent: true,
  203. mode: SelectCardEffect.Mode.Custom,
  204. root: SelectCardEffect.Root.DigivolutionCards,
  205. customRootCardList: selectedPermanent.DigivolutionCards,
  206. canLookReverseCard: true,
  207. selectPlayer: card.Owner,
  208. cardEffect: activateClass);
  209. IEnumerator SelectCardCoroutine(CardSource cardSource)
  210. {
  211. selectedCard = cardSource;
  212. yield return null;
  213. }
  214. selectCardEffect.SetUpCustomMessage("Select 1 option digivolution card to trash.", "The opponent is selecting 1 option digivolution card to trash.");
  215. selectCardEffect.SetUpCustomMessage_ShowCard("Trashed Card");
  216. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  217. #endregion
  218. if (selectedCard != null)
  219. {
  220. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(selectedPermanent, new List<CardSource>() { selectedCard }, activateClass).TrashDigivolutionCards());
  221. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelect3MOptionCard))
  222. {
  223. #region Select 3M option card in trash to use with reduced cost
  224. CardSource selectedOption = null;
  225. SelectCardEffect selectCardEffect1 = GManager.instance.GetComponent<SelectCardEffect>();
  226. selectCardEffect1.SetUp(
  227. canTargetCondition: CanSelect3MOptionCard,
  228. canTargetCondition_ByPreSelecetedList: null,
  229. canEndSelectCondition: null,
  230. canNoSelect: () => true,
  231. selectCardCoroutine: SelectCardCoroutine1,
  232. afterSelectCardCoroutine: null,
  233. message: "Select 1 [Three Musketeers] option to use.",
  234. maxCount: 1,
  235. canEndNotMax: false,
  236. isShowOpponent: true,
  237. mode: SelectCardEffect.Mode.Custom,
  238. root: SelectCardEffect.Root.Trash,
  239. customRootCardList: null,
  240. canLookReverseCard: true,
  241. selectPlayer: card.Owner,
  242. cardEffect: activateClass);
  243. IEnumerator SelectCardCoroutine1(CardSource cardSource)
  244. {
  245. selectedOption = cardSource;
  246. yield return null;
  247. }
  248. selectCardEffect1.SetUpCustomMessage("Select 1 [Three Musketeers] option to use.", "The opponent is selecting 1 [Three Musketeers] option to use.");
  249. selectCardEffect1.SetUpCustomMessage_ShowCard("Selected Card");
  250. yield return ContinuousController.instance.StartCoroutine(selectCardEffect1.Activate());
  251. if (selectedOption != null)
  252. {
  253. hasUsed = true;
  254. #region reduce play cost
  255. ChangeCostClass changeCostClass = new ChangeCostClass();
  256. changeCostClass.SetUpICardEffect($"Play Cost -3", CanUseCondition1, card);
  257. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CanSelect3MOptionCard, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  258. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  259. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  260. ICardEffect GetCardEffect(EffectTiming _timing)
  261. {
  262. if (_timing == EffectTiming.None)
  263. {
  264. return changeCostClass;
  265. }
  266. return null;
  267. }
  268. bool CanUseCondition1(Hashtable hashtable)
  269. {
  270. return true;
  271. }
  272. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  273. {
  274. if (cardSource.IsOption
  275. && cardSource.HasThreeMusketeersTraits
  276. && RootCondition(root)
  277. && PermanentsCondition(targetPermanents))
  278. {
  279. Cost -= 3;
  280. }
  281. return Cost;
  282. }
  283. bool PermanentsCondition(List<Permanent> targetPermanents)
  284. {
  285. return targetPermanents == null
  286. || targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0;
  287. }
  288. bool RootCondition(SelectCardEffect.Root root)
  289. {
  290. return true;
  291. }
  292. bool isUpDown()
  293. {
  294. return true;
  295. }
  296. #endregion
  297. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  298. cardSources: new List<CardSource>() { selectedOption },
  299. activateClass: activateClass,
  300. payCost: true,
  301. root: SelectCardEffect.Root.Trash));
  302. #region release effect
  303. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  304. #endregion
  305. }
  306. #endregion
  307. }
  308. }
  309. }
  310. }
  311. if (!hasUsed) activateClass.RemoveUse();
  312. }
  313. CardEffectFactory.ActivateClassesForSharedEffects
  314. (ref cardEffects, timing, card,
  315. SharedEffectName1,
  316. SharedActivateCoroutine1,
  317. SharedEffectDescription1,
  318. maxCountPerTurn: 1,
  319. hashValue: SharedHashString,
  320. optional: false,
  321. isSkippable: true,
  322. whenDigivolving: true,
  323. whenAttacking: true,
  324. additionalActivateCondition: AdditionalActivateCondition2);
  325. #endregion
  326. #region Inherited
  327. if (timing == EffectTiming.OnDestroyedAnyone)
  328. {
  329. ActivateClass activateClass = new ActivateClass();
  330. activateClass.SetUpICardEffect("Play 1 level 4 or lower [Three Musketeers] Digimon", CanUseCondition, card);
  331. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  332. activateClass.SetHashString("BT25_083_OD");
  333. activateClass.SetIsInheritedEffect(true);
  334. cardEffects.Add(activateClass);
  335. string EffectDiscription()
  336. {
  337. return "You may play 1 level 4 or lower Digimon card with [Three Musketeers] in its text from your trash without paying the cost.";
  338. }
  339. bool CanUseCondition(Hashtable hashtable)
  340. {
  341. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  342. }
  343. bool CanActivateCondition(Hashtable hashtable)
  344. {
  345. return CardEffectCommons.CanActivateOnDeletionInherited(hashtable, card);
  346. }
  347. bool CanSelectCardCondition(CardSource cardSource)
  348. {
  349. return cardSource.HasLevel &&
  350. cardSource.Level <= 4 &&
  351. cardSource.HasText("Three Musketeers")
  352. && cardSource.IsDigimon;
  353. }
  354. IEnumerator ActivateCoroutine(Hashtable hashtable)
  355. {
  356. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  357. selectCardEffect.SetUp(
  358. canTargetCondition: CanSelectCardCondition,
  359. canTargetCondition_ByPreSelecetedList: null,
  360. canEndSelectCondition: null,
  361. canNoSelect: () => true,
  362. selectCardCoroutine: null,
  363. afterSelectCardCoroutine: null,
  364. message: "Select 1 level 4 or lower [Three Musketeers] digimon to play.",
  365. maxCount: 1,
  366. canEndNotMax: false,
  367. isShowOpponent: true,
  368. mode: SelectCardEffect.Mode.PlayForFree,
  369. root: SelectCardEffect.Root.Trash,
  370. customRootCardList: null,
  371. canLookReverseCard: true,
  372. selectPlayer: card.Owner,
  373. cardEffect: activateClass);
  374. selectCardEffect.SetUpCustomMessage("Select 1 level 4 or lower [Three Musketeers] digimon to play.", "The opponent is selecting 1 level 4 or lower [Three Musketeers] digimon to play.");
  375. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  376. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  377. }
  378. }
  379. #endregion
  380. return cardEffects;
  381. }
  382. }
  383. }