BT23_057.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Gankoomon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_057 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolve Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel5 &&
  18. targetPermanent.TopCard.HasCSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  22. card: card, condition: null));
  23. }
  24. #endregion
  25. bool CanSelectReturnCardCondition(CardSource cardSource)
  26. {
  27. return cardSource.ContainsCardName("Huckmon") ||
  28. cardSource.ContainsCardName("Sistermon") ||
  29. cardSource.ContainsCardName("Jesmon");
  30. }
  31. #region Before Pay Cost - Condition Effect
  32. if (timing == EffectTiming.BeforePayCost)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("Return 3 cards with [Huckmon], [Sistermon] or [Jesmon] in their names to get Play Cost -5", CanUseCondition, card);
  36. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  37. activateClass.SetHashString("PlayCost-5_BT12_057");
  38. cardEffects.Add(activateClass);
  39. string EffectDiscription()
  40. {
  41. return "When this card would be played, by returning 3 cards with [Huckmon], [Sistermon] or [Jesmon] in their names from your trash to the top or bottom of the deck, reduce the play cost by 5.";
  42. }
  43. bool CardCondition(CardSource cardSource)
  44. {
  45. if (cardSource == card)
  46. {
  47. if (CardEffectCommons.IsExistOnHand(cardSource))
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanNoSelect(CardSource cardSource)
  55. {
  56. if (cardSource != null)
  57. {
  58. if (cardSource.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) > cardSource.Owner.MaxMemoryCost)
  59. {
  60. return false;
  61. }
  62. }
  63. return true;
  64. }
  65. bool CanUseCondition(Hashtable hashtable)
  66. {
  67. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  68. }
  69. bool CanActivateCondition(Hashtable hashtable)
  70. {
  71. if (CardEffectCommons.IsExistOnHand(card))
  72. {
  73. if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectReturnCardCondition) >= 3)
  74. {
  75. return true;
  76. }
  77. }
  78. return false;
  79. }
  80. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  81. {
  82. List<CardSource> selectedCards = new List<CardSource>();
  83. if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectReturnCardCondition) >= 3)
  84. {
  85. bool noSelect = CanNoSelect(CardEffectCommons.GetCardFromHashtable(_hashtable));
  86. int maxCount = 3;
  87. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  88. selectCardEffect.SetUp(
  89. canTargetCondition: CanSelectReturnCardCondition,
  90. canTargetCondition_ByPreSelecetedList: null,
  91. canEndSelectCondition: null,
  92. canNoSelect: () => noSelect,
  93. selectCardCoroutine: SelectCardCoroutine,
  94. afterSelectCardCoroutine: null,
  95. message: "Select cards to add to the top your deck\n(cards will be placed back to the top of the deck so that cards with lower numbers are on top).",
  96. maxCount: maxCount,
  97. canEndNotMax: false,
  98. isShowOpponent: true,
  99. mode: SelectCardEffect.Mode.Custom,
  100. root: SelectCardEffect.Root.Trash,
  101. customRootCardList: null,
  102. canLookReverseCard: true,
  103. selectPlayer: card.Owner,
  104. cardEffect: activateClass);
  105. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  106. IEnumerator SelectCardCoroutine(CardSource cardSource)
  107. {
  108. selectedCards.Add(cardSource);
  109. yield return null;
  110. }
  111. if (selectedCards.Count == 3)
  112. {
  113. selectedCards.Reverse();
  114. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryTopCards(selectedCards));
  115. }
  116. }
  117. if (card.Owner.CanReduceCost(null, card))
  118. {
  119. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  120. }
  121. ChangeCostClass changeCostClass = new ChangeCostClass();
  122. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition1, card);
  123. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  124. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  125. bool CanUseCondition1(Hashtable hashtable)
  126. {
  127. return true;
  128. }
  129. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  130. {
  131. if (CardSourceCondition(cardSource))
  132. {
  133. if (RootCondition(root))
  134. {
  135. if (PermanentsCondition(targetPermanents))
  136. {
  137. int targetCost = 0;
  138. if (selectedCards.Count >= 3)
  139. targetCost += 5;
  140. Cost -= targetCost;
  141. }
  142. }
  143. }
  144. return Cost;
  145. }
  146. bool PermanentsCondition(List<Permanent> targetPermanents)
  147. {
  148. if (targetPermanents == null)
  149. {
  150. return true;
  151. }
  152. else
  153. {
  154. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  155. {
  156. return true;
  157. }
  158. }
  159. return false;
  160. }
  161. bool CardSourceCondition(CardSource cardSource)
  162. {
  163. return cardSource == card;
  164. }
  165. bool RootCondition(SelectCardEffect.Root root)
  166. {
  167. return true;
  168. }
  169. bool isUpDown()
  170. {
  171. return true;
  172. }
  173. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  174. }
  175. }
  176. #endregion
  177. #region Reduce Play Cost - Not Shown
  178. if (timing == EffectTiming.None)
  179. {
  180. ChangeCostClass changeCostClass = new ChangeCostClass();
  181. changeCostClass.SetUpICardEffect("Play Cost -5", CanUseCondition, card);
  182. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  183. changeCostClass.SetNotShowUI(true);
  184. cardEffects.Add(changeCostClass);
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. if (card.Owner.HandCards.Contains(card))
  188. {
  189. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Return 3 cards with [Huckmon], [Sistermon] or [Jesmon] in their names to get Play Cost -5");
  190. if (activateClass != null)
  191. {
  192. if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectReturnCardCondition) >= 3)
  193. {
  194. return true;
  195. }
  196. }
  197. }
  198. return false;
  199. }
  200. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  201. {
  202. if (CardSourceCondition(cardSource))
  203. {
  204. if (RootCondition(root))
  205. {
  206. if (PermanentsCondition(targetPermanents))
  207. {
  208. int trashCount = CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectReturnCardCondition);
  209. int targetCount = 0;
  210. if (trashCount >= 3)
  211. targetCount += 5;
  212. Cost -= targetCount;
  213. }
  214. }
  215. }
  216. return Cost;
  217. }
  218. bool PermanentsCondition(List<Permanent> targetPermanents)
  219. {
  220. if (targetPermanents == null)
  221. {
  222. return true;
  223. }
  224. else
  225. {
  226. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  227. {
  228. return true;
  229. }
  230. }
  231. return false;
  232. }
  233. bool CardSourceCondition(CardSource cardSource)
  234. {
  235. if (cardSource != null)
  236. {
  237. if (cardSource == card)
  238. {
  239. return true;
  240. }
  241. }
  242. return false;
  243. }
  244. bool RootCondition(SelectCardEffect.Root root)
  245. {
  246. return true;
  247. }
  248. bool isUpDown()
  249. {
  250. return true;
  251. }
  252. }
  253. #endregion
  254. #region OP/WD Shared
  255. string SharedEffectDiscription(string tag)
  256. {
  257. return $"[{tag}] You may play 1 [Hinukamuy] Token. (Digimon/White/6000 DP/<Alliance> <Reboot> <Blocker>) Then, delete 1 of your opponent's Digimon with a play cost of 6 or less. For each of your other Digimon, add 3 to this effect's play cost maximum.";
  258. }
  259. bool SharedCanActivateCondition(Hashtable hashtable)
  260. {
  261. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  262. {
  263. if (card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) >= 1)
  264. {
  265. return true;
  266. }
  267. }
  268. return false;
  269. }
  270. bool SharedCanSelectPermanentCondition(Permanent permanent)
  271. {
  272. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  273. {
  274. int maxCost = 6;
  275. maxCost += 3 * card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsDigimon && permanent != card.PermanentOfThisCard());
  276. if (permanent.TopCard.GetCostItself <= maxCost)
  277. {
  278. if (permanent.TopCard.HasPlayCost)
  279. {
  280. return true;
  281. }
  282. }
  283. }
  284. return false;
  285. }
  286. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  287. {
  288. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayHinukamuyToken(activateClass));
  289. if (CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectPermanentCondition))
  290. {
  291. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  292. selectPermanentEffect.SetUp(
  293. selectPlayer: card.Owner,
  294. canTargetCondition: SharedCanSelectPermanentCondition,
  295. canTargetCondition_ByPreSelecetedList: null,
  296. canEndSelectCondition: null,
  297. maxCount: 1,
  298. canNoSelect: false,
  299. canEndNotMax: false,
  300. selectPermanentCoroutine: null,
  301. afterSelectPermanentCoroutine: null,
  302. mode: SelectPermanentEffect.Mode.Destroy,
  303. cardEffect: activateClass);
  304. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  305. }
  306. }
  307. #endregion
  308. #region On Play
  309. if (timing == EffectTiming.OnEnterFieldAnyone)
  310. {
  311. ActivateClass activateClass = new ActivateClass();
  312. activateClass.SetUpICardEffect("Play token", CanUseCondition, card);
  313. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, true, SharedEffectDiscription("On Play"));
  314. cardEffects.Add(activateClass);
  315. bool CanUseCondition(Hashtable hashtable)
  316. {
  317. return (CardEffectCommons.CanTriggerOnPlay(hashtable, card));
  318. }
  319. }
  320. #endregion
  321. #region When Digivolving
  322. if (timing == EffectTiming.OnEnterFieldAnyone)
  323. {
  324. ActivateClass activateClass = new ActivateClass();
  325. activateClass.SetUpICardEffect("Play token", CanUseCondition, card);
  326. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, true, SharedEffectDiscription("When Digivolving"));
  327. cardEffects.Add(activateClass);
  328. bool CanUseCondition(Hashtable hashtable)
  329. {
  330. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  331. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  332. }
  333. }
  334. #endregion
  335. return cardEffects;
  336. }
  337. }
  338. }