BT25_083.cs 24 KB

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