BT17_068.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT17
  5. {
  6. public class BT17_068 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region When Revealed from Deck
  12. if (timing == EffectTiming.None)
  13. {
  14. ChangeCardLevelClass changeCardLevelClass = new ChangeCardLevelClass();
  15. changeCardLevelClass.SetUpICardEffect($"Also treated as level 6 when revealed from the top of the deck.",CanUseCondition, card);
  16. changeCardLevelClass.SetUpChangeCardLevelClass(GetLevel: GetLevel);
  17. changeCardLevelClass.SetNotShowUI(true);
  18. cardEffects.Add(changeCardLevelClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. return card.IsBeingRevealed;
  22. }
  23. int GetLevel(CardSource cardSource, int level)
  24. {
  25. if (cardSource == card)
  26. level = 6;
  27. return level;
  28. }
  29. }
  30. #endregion
  31. #region When Would be Played
  32. if (timing == EffectTiming.BeforePayCost)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("Return [Apocalymon] from your trash to deck, to get Play Cost -3", CanUseCondition, card);
  36. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  37. activateClass.SetHashString("PlayCost-3_BT17_068");
  38. cardEffects.Add(activateClass);
  39. string EffectDescription()
  40. {
  41. return
  42. "When this card would be played from the hand, by returning 1 [Apocalymon] from your trash to the bottom of the deck, reduce the play cost by 3.";
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  47. }
  48. bool IsApocalymonCardCondition(CardSource cardSource)
  49. {
  50. return cardSource.IsDigimon &&
  51. cardSource.EqualsCardName("Apocalymon");
  52. }
  53. bool CardCondition(CardSource cardSource)
  54. {
  55. return cardSource == card &&
  56. CardEffectCommons.IsExistOnHand(cardSource);
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsApocalymonCardCondition);
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable hashtable)
  63. {
  64. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsApocalymonCardCondition))
  65. {
  66. CardSource cardFromHashtable = CardEffectCommons.GetCardFromHashtable(hashtable);
  67. bool returned = false;
  68. bool canNoSelect = !(cardFromHashtable &&
  69. (CardEffectCommons.GetPayCostFromHashtable(hashtable)
  70. && card.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) > card.Owner.MaxMemoryCost));
  71. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  72. selectCardEffect.SetUp(
  73. canTargetCondition: IsApocalymonCardCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. canNoSelect: () => canNoSelect,
  77. selectCardCoroutine: null,
  78. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  79. message: "Select 1 card to place at the bottom of the deck.",
  80. maxCount: 1,
  81. canEndNotMax: false,
  82. isShowOpponent: false,
  83. mode: SelectCardEffect.Mode.Custom,
  84. root: SelectCardEffect.Root.Trash,
  85. customRootCardList: null,
  86. canLookReverseCard: true,
  87. selectPlayer: card.Owner,
  88. cardEffect: activateClass);
  89. selectCardEffect.SetNotShowCard();
  90. selectCardEffect.SetNotAddLog();
  91. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  92. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  93. {
  94. if (cardSources.Count == 1)
  95. {
  96. yield return ContinuousController.instance.StartCoroutine(
  97. CardObjectController.AddLibraryBottomCards(cardSources));
  98. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  99. .ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  100. returned = true;
  101. }
  102. }
  103. if (returned)
  104. {
  105. if (card.Owner.CanReduceCost(null, card))
  106. {
  107. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  108. }
  109. ChangeCostClass changeCostClass = new ChangeCostClass();
  110. changeCostClass.SetUpICardEffect("Play Cost -3", CanUseConditionChangeCost, card);
  111. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition,
  112. rootCondition: RootCondition, isUpDown: IsUpDown, isCheckAvailability: () => false,
  113. isChangePayingCost: () => true);
  114. card.Owner.UntilCalculateFixedCostEffect.Add(_ => changeCostClass);
  115. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  116. bool CanUseConditionChangeCost(Hashtable hashtableChangeCost)
  117. {
  118. return true;
  119. }
  120. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  121. List<Permanent> targetPermanents)
  122. {
  123. if (CardSourceCondition(cardSource) && RootCondition(root) && PermanentsCondition(targetPermanents))
  124. {
  125. cost -= 3;
  126. }
  127. return cost;
  128. }
  129. bool CardSourceCondition(CardSource cardSource)
  130. {
  131. return cardSource == card;
  132. }
  133. bool RootCondition(SelectCardEffect.Root root)
  134. {
  135. return true;
  136. }
  137. bool PermanentsCondition(List<Permanent> targetPermanents)
  138. {
  139. return targetPermanents == null ||
  140. targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0;
  141. }
  142. bool IsUpDown()
  143. {
  144. return true;
  145. }
  146. }
  147. }
  148. }
  149. }
  150. #endregion
  151. #region On Deletion
  152. if (timing == EffectTiming.OnDestroyedAnyone)
  153. {
  154. ActivateClass activateClass = new ActivateClass();
  155. activateClass.SetUpICardEffect("Play Digimon from hand or trash.", CanUseCondition, card);
  156. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  157. cardEffects.Add(activateClass);
  158. string EffectDescription()
  159. {
  160. return
  161. "[On Deletion] If deleted by an effect, you may play 1 [Gulfmon] or 1 level 6 Digimon with the [Dark Masters] trait from your hand or trash without paying the cost.";
  162. }
  163. bool CanUseCondition(Hashtable hashtable)
  164. {
  165. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass) &&
  166. CardEffectCommons.IsByEffect(hashtable, null);
  167. }
  168. bool CanSelectCardCondition(CardSource cardSource)
  169. {
  170. return cardSource.EqualsCardName("Gulfmon") ||
  171. (cardSource.IsDigimon &&
  172. cardSource.HasLevel &&
  173. cardSource.Level == 6 &&
  174. cardSource.ContainsTraits("Dark Masters"));
  175. }
  176. bool CanActivateCondition(Hashtable hashtable)
  177. {
  178. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  179. (card.Owner.HandCards.Some(CanSelectCardCondition) ||
  180. card.Owner.TrashCards.Some(CanSelectCardCondition));
  181. }
  182. IEnumerator ActivateCoroutine(Hashtable hashtable)
  183. {
  184. bool canSelectHand = card.Owner.HandCards.Some(CanSelectCardCondition);
  185. bool canSelectTrash = card.Owner.TrashCards.Some(CanSelectCardCondition);
  186. if (canSelectHand || canSelectTrash)
  187. {
  188. if (canSelectHand && canSelectTrash)
  189. {
  190. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  191. {
  192. new(message: "From hand", value: true, spriteIndex: 0),
  193. new(message: "From trash", value: false, spriteIndex: 1),
  194. };
  195. string selectPlayerMessage = "From which area do you play a card?";
  196. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  197. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  198. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  199. notSelectPlayerMessage: notSelectPlayerMessage);
  200. }
  201. else
  202. {
  203. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  204. }
  205. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  206. .WaitForEndSelect());
  207. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  208. List<CardSource> selectedCards = new List<CardSource>();
  209. IEnumerator SelectCardCoroutine(CardSource cardSource)
  210. {
  211. selectedCards.Add(cardSource);
  212. yield return null;
  213. }
  214. if (fromHand)
  215. {
  216. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  217. selectHandEffect.SetUp(
  218. selectPlayer: card.Owner,
  219. canTargetCondition: CanSelectCardCondition,
  220. canTargetCondition_ByPreSelecetedList: null,
  221. canEndSelectCondition: null,
  222. maxCount: 1,
  223. canNoSelect: true,
  224. canEndNotMax: false,
  225. isShowOpponent: true,
  226. selectCardCoroutine: SelectCardCoroutine,
  227. afterSelectCardCoroutine: null,
  228. mode: SelectHandEffect.Mode.Custom,
  229. cardEffect: activateClass);
  230. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  231. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  232. yield return StartCoroutine(selectHandEffect.Activate());
  233. }
  234. else
  235. {
  236. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  237. selectCardEffect.SetUp(
  238. canTargetCondition: CanSelectCardCondition,
  239. canTargetCondition_ByPreSelecetedList: null,
  240. canEndSelectCondition: null,
  241. canNoSelect: () => true,
  242. selectCardCoroutine: SelectCardCoroutine,
  243. afterSelectCardCoroutine: null,
  244. message: "Select 1 card to play.",
  245. maxCount: 1,
  246. canEndNotMax: false,
  247. isShowOpponent: true,
  248. mode: SelectCardEffect.Mode.Custom,
  249. root: SelectCardEffect.Root.Trash,
  250. customRootCardList: null,
  251. canLookReverseCard: true,
  252. selectPlayer: card.Owner,
  253. cardEffect: activateClass);
  254. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  255. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  256. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  257. }
  258. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  259. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  260. root: (fromHand) ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash,
  261. activateETB: true));
  262. }
  263. }
  264. }
  265. #endregion
  266. #region When Attacking - ESS
  267. if (timing == EffectTiming.OnAllyAttack)
  268. {
  269. ActivateClass activateClass = new ActivateClass();
  270. activateClass.SetUpICardEffect("Place 1 digimon from trash under this Digimon's digivolution cards", CanUseCondition, card);
  271. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  272. activateClass.SetIsInheritedEffect(true);
  273. cardEffects.Add(activateClass);
  274. string EffectDescription()
  275. {
  276. return
  277. "[When Attacking] (Once Per Turn) By placing 1 level 5 or lower card with [Dark Masters] in its text from your trash as this Digimon's bottom digivolution card, this Digimon gets +2000 DP for the turn.";
  278. }
  279. bool CanUseCondition(Hashtable hashtable)
  280. {
  281. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  282. }
  283. bool IsDarkMastersCardCondition(CardSource cardSource)
  284. {
  285. return cardSource.HasLevel &&
  286. cardSource.Level <= 5 &&
  287. cardSource.HasText("Dark Masters");
  288. }
  289. bool CanActivateCondition(Hashtable hashtable)
  290. {
  291. return CardEffectCommons.IsExistOnBattleArea(card) &&
  292. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsDarkMastersCardCondition);
  293. }
  294. IEnumerator ActivateCoroutine(Hashtable hashtable)
  295. {
  296. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsDarkMastersCardCondition))
  297. {
  298. List<CardSource> selectedCards = new List<CardSource>();
  299. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  300. selectCardEffect.SetUp(
  301. canTargetCondition: IsDarkMastersCardCondition,
  302. canTargetCondition_ByPreSelecetedList: null,
  303. canEndSelectCondition: null,
  304. canNoSelect: () => true,
  305. selectCardCoroutine: SelectCardCoroutine,
  306. afterSelectCardCoroutine: null,
  307. message: "Select 1 card to place on bottom of digivolution cards.",
  308. maxCount: 1,
  309. canEndNotMax: false,
  310. isShowOpponent: true,
  311. mode: SelectCardEffect.Mode.Custom,
  312. root: SelectCardEffect.Root.Trash,
  313. customRootCardList: null,
  314. canLookReverseCard: true,
  315. selectPlayer: card.Owner,
  316. cardEffect: activateClass);
  317. selectCardEffect.SetUpCustomMessage(
  318. "Select 1 card to place on bottom of digivolution cards.",
  319. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  320. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  321. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  322. IEnumerator SelectCardCoroutine(CardSource cardSource)
  323. {
  324. selectedCards.Add(cardSource);
  325. yield return null;
  326. }
  327. if (selectedCards.Count >= 1)
  328. {
  329. if (CardEffectCommons.IsExistOnBattleArea(card))
  330. {
  331. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard()
  332. .AddDigivolutionCardsBottom(
  333. selectedCards,
  334. activateClass));
  335. yield return ContinuousController.instance.StartCoroutine(
  336. CardEffectCommons.ChangeDigimonDP(targetPermanent: card.PermanentOfThisCard(), changeValue: 2000,
  337. effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  338. }
  339. }
  340. }
  341. }
  342. }
  343. #endregion
  344. return cardEffects;
  345. }
  346. }
  347. }