BT25_096.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Mirage Beast Knight
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_096 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Reduce Play Cost
  14. bool SharedCanSelectTamerCondition(Permanent permanent)
  15. => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  16. && permanent.HasFaceDownDigivolutionCards;
  17. if (timing == EffectTiming.BeforePayCost)
  18. {
  19. ActivateClass activateClass = new ActivateClass();
  20. activateClass.SetUpICardEffect("Reduce Play Cost -2", CanUseCondition, card);
  21. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  22. activateClass.SetIsSkippable(true);
  23. cardEffects.Add(activateClass);
  24. string EffectDescription()
  25. {
  26. return "When this card would be used, by trashing the bottom face-down card from under any of your Tamers, reduce the use cost by 2.";
  27. }
  28. bool CanUseCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, cardSource => cardSource == card)
  31. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, SharedCanSelectTamerCondition);
  32. }
  33. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  34. {
  35. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, SharedCanSelectTamerCondition))
  36. {
  37. Permanent selectedPermanent = null;
  38. #region Select Tamer to trash bottom face down digivolution card
  39. if (CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectTamerCondition))
  40. {
  41. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  42. selectPermanentEffect.SetUp(
  43. selectPlayer: card.Owner,
  44. canTargetCondition: SharedCanSelectTamerCondition,
  45. canTargetCondition_ByPreSelecetedList: null,
  46. canEndSelectCondition: null,
  47. maxCount: 1,
  48. canNoSelect: true,
  49. canEndNotMax: false,
  50. selectPermanentCoroutine: SelectPermanentCoroutine,
  51. afterSelectPermanentCoroutine: null,
  52. mode: SelectPermanentEffect.Mode.Custom,
  53. cardEffect: activateClass);
  54. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  55. {
  56. selectedPermanent = permanent;
  57. yield return null;
  58. }
  59. selectPermanentEffect.SetUpCustomMessage("Select 1 tamer to trash bottom face down digivolution card.", "The opponent is selecting 1 tamer to trash bottom face down digivolution card.");
  60. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  61. }
  62. #endregion
  63. if (selectedPermanent != null)
  64. {
  65. CardSource cardToTrash = selectedPermanent.DigivolutionCards.Last(x => x.IsFaceDown);
  66. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsAndProcessAccordingToResult(
  67. targetPermanent: selectedPermanent,
  68. targetDigivolutionCards: new List<CardSource>() { cardToTrash },
  69. activateClass: activateClass,
  70. successProcess: SuccessProcess,
  71. failureProcess: null));
  72. IEnumerator SuccessProcess(List<CardSource> trashedCards)
  73. {
  74. if (card.Owner.CanReduceCost(null, card)) ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  75. ChangeCostClass changeCostClass = new ChangeCostClass();
  76. changeCostClass.SetUpICardEffect("Play Cost -2", CanUseCondition1, card);
  77. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  78. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  79. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  80. bool CanUseCondition1(Hashtable hashtable) => true;
  81. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  82. {
  83. if (CardSourceCondition(cardSource)
  84. && RootCondition(root)
  85. && PermanentsCondition(targetPermanents))
  86. {
  87. Cost -= 2;
  88. }
  89. return Cost;
  90. }
  91. bool PermanentsCondition(List<Permanent> targetPermanents)
  92. {
  93. return targetPermanents == null
  94. || targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0;
  95. }
  96. bool CardSourceCondition(CardSource cardSource)
  97. => cardSource != null
  98. && cardSource == card;
  99. bool RootCondition(SelectCardEffect.Root root) => true;
  100. bool isUpDown() => true;
  101. }
  102. }
  103. }
  104. }
  105. }
  106. if (timing == EffectTiming.None)
  107. {
  108. ChangeCostClass changeCostClass = new ChangeCostClass();
  109. changeCostClass.SetUpICardEffect("Play Cost -2", CanUseCondition, card);
  110. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  111. changeCostClass.SetNotShowUI(true);
  112. cardEffects.Add(changeCostClass);
  113. bool CanUseCondition(Hashtable hashtable)
  114. {
  115. return CardEffectCommons.IsExistOnHand(card)
  116. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, SharedCanSelectTamerCondition);
  117. }
  118. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  119. {
  120. if (CardSourceCondition(cardSource))
  121. {
  122. if (RootCondition(root))
  123. {
  124. Cost -= 2;
  125. }
  126. }
  127. return Cost;
  128. }
  129. bool CardSourceCondition(CardSource cardSource)
  130. => cardSource != null && cardSource == card;
  131. bool RootCondition(SelectCardEffect.Root root) => true;
  132. bool isUpDown() => true;
  133. }
  134. #endregion
  135. #region Main
  136. if (timing == EffectTiming.OptionSkill)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect("By placing 1 [Gaogamon] and 1 [MachGaogamon] from trash as 1 [Gaomon] bottom sources, may digivolve into [MirageGaogamon] without cost or digivole requirements", CanUseCondition, card);
  140. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  141. cardEffects.Add(activateClass);
  142. string EffectDescription()
  143. {
  144. return "[Main] By placing 1 [Gaogamon] and 1 [MachGaogamon] from your trash as 1 of your [Gaomon]'s bottom digivolution cards, that Digimon may digivolve into [MirageGaogamon] in the hand, ignoring digivolution requirements and without paying the cost.";
  145. }
  146. bool CanUseCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  149. }
  150. IEnumerator ActivateCoroutine(Hashtable hashtable)
  151. {
  152. #region Conditions
  153. bool IsGaomon(Permanent permanent)
  154. => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  155. && permanent.TopCard.EqualsCardName("Gaomon");
  156. bool IsGaogamon(CardSource cardSource)
  157. => cardSource.EqualsCardName("Gaogamon");
  158. bool IsMachGaogamon(CardSource cardSource)
  159. => cardSource.EqualsCardName("MachGaogamon");
  160. bool isMirageGaogamon(CardSource cardSource)
  161. => cardSource.EqualsCardName("MirageGaogamon");
  162. #endregion
  163. if (!(CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsGaogamon) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsMachGaogamon))) yield break;
  164. Permanent selectedPermanent = null;
  165. #region Select Gaomon
  166. if (CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsGaomon) > 1)
  167. {
  168. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  169. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsGaomon));
  170. selectPermanentEffect.SetUp(
  171. selectPlayer: card.Owner,
  172. canTargetCondition: IsGaomon,
  173. canTargetCondition_ByPreSelecetedList: null,
  174. canEndSelectCondition: null,
  175. maxCount: maxCount,
  176. canNoSelect: true,
  177. canEndNotMax: false,
  178. selectPermanentCoroutine: SelectPermanentCoroutine,
  179. afterSelectPermanentCoroutine: null,
  180. mode: SelectPermanentEffect.Mode.Custom,
  181. cardEffect: activateClass);
  182. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  183. {
  184. selectedPermanent = permanent;
  185. yield return null;
  186. }
  187. selectPermanentEffect.SetUpCustomMessage("Select 1 [Gaomon] to gain digivolution sources", "The opponent is selecting 1 [Gaomon] to gain digivolution sources.");
  188. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  189. }
  190. if (CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsGaomon) == 1)
  191. selectedPermanent = card.Owner.GetBattleAreaDigimons().Find(IsGaomon);
  192. #endregion
  193. if (selectedPermanent != null)
  194. {
  195. List<CardSource> selectedTrashCards = new List<CardSource>();
  196. IEnumerator SelectCardCoroutine(CardSource cardSource)
  197. {
  198. selectedTrashCards.Add(cardSource);
  199. yield return null;
  200. }
  201. #region Select Gaogamon
  202. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsGaogamon))
  203. {
  204. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  205. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsGaogamon));
  206. selectCardEffect.SetUp(
  207. canTargetCondition: IsGaogamon,
  208. canTargetCondition_ByPreSelecetedList: null,
  209. canEndSelectCondition: null,
  210. canNoSelect: () => true,
  211. selectCardCoroutine: SelectCardCoroutine,
  212. afterSelectCardCoroutine: null,
  213. message: "Select 1 [Gaogamon] card",
  214. maxCount: maxCount,
  215. canEndNotMax: false,
  216. isShowOpponent: true,
  217. mode: SelectCardEffect.Mode.Custom,
  218. root: SelectCardEffect.Root.Trash,
  219. customRootCardList: null,
  220. canLookReverseCard: true,
  221. selectPlayer: card.Owner,
  222. cardEffect: activateClass);
  223. selectCardEffect.SetUpCustomMessage("Select 1 [Gaogamon] card to place under [Gaomon].", "The opponent is selecting a [Gaogamon] card to place under [Gaomon].");
  224. selectCardEffect.SetUpCustomMessage_ShowCard("Selected [Gaogamon]");
  225. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  226. }
  227. #endregion
  228. #region Select MachGaogamon
  229. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsMachGaogamon) && selectedTrashCards.Find(IsGaogamon))
  230. {
  231. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  232. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsMachGaogamon));
  233. selectCardEffect.SetUp(
  234. canTargetCondition: IsMachGaogamon,
  235. canTargetCondition_ByPreSelecetedList: null,
  236. canEndSelectCondition: null,
  237. canNoSelect: () => true,
  238. selectCardCoroutine: SelectCardCoroutine,
  239. afterSelectCardCoroutine: null,
  240. message: "Select 1 [MachGaogamon] card",
  241. maxCount: maxCount,
  242. canEndNotMax: false,
  243. isShowOpponent: true,
  244. mode: SelectCardEffect.Mode.Custom,
  245. root: SelectCardEffect.Root.Trash,
  246. customRootCardList: null,
  247. canLookReverseCard: true,
  248. selectPlayer: card.Owner,
  249. cardEffect: activateClass);
  250. selectCardEffect.SetUpCustomMessage("Select 1 [MachGaogamon] card to place under [Gaomon].", "The opponent is selecting a [MachGaogamon] card to place under [Gaomon].");
  251. selectCardEffect.SetUpCustomMessage_ShowCard("Selected [MachGaogamon]");
  252. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  253. }
  254. #endregion
  255. if (selectedTrashCards.Find(IsGaogamon) && selectedTrashCards.Find(IsMachGaogamon))
  256. {
  257. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(
  258. addedDigivolutionCards: selectedTrashCards,
  259. cardEffect: activateClass));
  260. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  261. targetPermanent: selectedPermanent,
  262. cardCondition: isMirageGaogamon,
  263. payCost: false,
  264. reduceCostTuple: null,
  265. fixedCostTuple: null,
  266. ignoreDigivolutionRequirementFixedCost: 1,
  267. isHand: true,
  268. activateClass: activateClass,
  269. successProcess: null));
  270. }
  271. }
  272. }
  273. }
  274. #endregion
  275. #region Security
  276. if (timing == EffectTiming.SecuritySkill)
  277. {
  278. ActivateClass activateClass = new ActivateClass();
  279. activateClass.SetUpICardEffect($"Play 1 [Gaomon]/[Thomas H. Norstein] from hand or trash, then add this to hand", CanUseCondition, card);
  280. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  281. activateClass.SetIsSecurityEffect(true);
  282. cardEffects.Add(activateClass);
  283. string EffectDescription()
  284. {
  285. return "[Security] You may play 1 [Gaomon] or [Thomas H. Norstein] from your hand or trash without paying the cost. Then, add this card to the hand.";
  286. }
  287. bool CanSelectCardCondition(CardSource cardSource)
  288. {
  289. return (cardSource.EqualsCardName("Gaomon") || cardSource.EqualsCardName("Thomas H. Norstein"))
  290. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  291. }
  292. bool CanUseCondition(Hashtable hashtable) => CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  293. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  294. {
  295. bool canPlayFromHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  296. bool canPlayFromTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  297. if (canPlayFromHand || canPlayFromTrash)
  298. {
  299. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  300. if (canPlayFromHand) selectionElements.Add(new SelectionElement<int>("Play from hand", 1, 0));
  301. if (canPlayFromTrash) selectionElements.Add(new SelectionElement<int>("Play from trash", 2, 0));
  302. selectionElements.Add(new SelectionElement<int>("Dont play a card", 3, 1));
  303. string selectPlayerMessage = "Will you play a [Gaomon] or [Thomas H. Norstein]?";
  304. string notSelectPlayerMessage = "The opponent is choosing whether to play a [Gaomon] or [Thomas H. Norstein]";
  305. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  306. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  307. bool playFromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  308. bool dontPlay = GManager.instance.userSelectionManager.SelectedIntValue == 3;
  309. if (!dontPlay)
  310. {
  311. CardSource selectedCard = null;
  312. SelectCardEffect.Root selectedRoot = SelectCardEffect.Root.None;
  313. IEnumerator SelectCardCoroutine(CardSource cardSource)
  314. {
  315. selectedCard = cardSource;
  316. yield return null;
  317. }
  318. if (playFromHand)
  319. {
  320. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectCardCondition));
  321. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  322. selectHandEffect.SetUp(
  323. selectPlayer: card.Owner,
  324. canTargetCondition: CanSelectCardCondition,
  325. canTargetCondition_ByPreSelecetedList: null,
  326. canEndSelectCondition: null,
  327. maxCount: maxCount,
  328. canNoSelect: true,
  329. canEndNotMax: false,
  330. isShowOpponent: true,
  331. selectCardCoroutine: SelectCardCoroutine,
  332. afterSelectCardCoroutine: null,
  333. mode: SelectHandEffect.Mode.Custom,
  334. cardEffect: activateClass);
  335. selectHandEffect.SetUpCustomMessage("Select 1 [Gaomon] or [Thomas H. Norstein] to play.", "The opponent is selecting 1 [Gaomon] or [Thomas H. Norstein] to play.");
  336. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  337. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  338. selectedRoot = SelectCardEffect.Root.Hand;
  339. }
  340. else
  341. {
  342. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  343. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  344. selectCardEffect.SetUp(
  345. canTargetCondition: CanSelectCardCondition,
  346. canTargetCondition_ByPreSelecetedList: null,
  347. canEndSelectCondition: null,
  348. canNoSelect: () => true,
  349. selectCardCoroutine: SelectCardCoroutine,
  350. afterSelectCardCoroutine: null,
  351. message: "Select 1 [Gaomon] or [Thomas H. Norstein] to play",
  352. maxCount: maxCount,
  353. canEndNotMax: false,
  354. isShowOpponent: true,
  355. mode: SelectCardEffect.Mode.Custom,
  356. root: SelectCardEffect.Root.Trash,
  357. customRootCardList: null,
  358. canLookReverseCard: true,
  359. selectPlayer: card.Owner,
  360. cardEffect: activateClass);
  361. selectCardEffect.SetUpCustomMessage("Select 1 [Gaomon] or [Thomas H. Norstein] to play.", "The opponent is selecting 1 [Gaomon] or [Thomas H. Norstein] to play.");
  362. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  363. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  364. selectedRoot = SelectCardEffect.Root.Trash;
  365. }
  366. if (selectedCard != null && selectedRoot != SelectCardEffect.Root.None)
  367. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  368. cardSources: new List<CardSource>() { selectedCard },
  369. activateClass: activateClass,
  370. payCost: false,
  371. isTapped: false,
  372. root: selectedRoot,
  373. activateETB: true
  374. ));
  375. }
  376. }
  377. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  378. }
  379. }
  380. #endregion
  381. return cardEffects;
  382. }
  383. }
  384. }