P_170.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.P
  5. {
  6. public class P_170 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution Requirement
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsTraits("Three Musketeers") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region Reduce Play Cost
  22. bool CanSelectThreeMusketeersCondition(CardSource cardSource)
  23. {
  24. return cardSource.HasText("Three Musketeers");
  25. }
  26. #region Before Pay Cost - Condition Effect
  27. if (timing == EffectTiming.BeforePayCost)
  28. {
  29. ActivateClass activateClass = new ActivateClass();
  30. activateClass.SetUpICardEffect("Return 3 [Three Musketeers] to get Play Cost -6", CanUseCondition, card);
  31. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  32. activateClass.SetHashString("PlayCost-6_P_170");
  33. cardEffects.Add(activateClass);
  34. string EffectDiscription()
  35. {
  36. return "When this card would be played, by returning 3 cards with [Three Musketeers] in their texts from your trash to the bottom of the deck, reduce the play cost by 6.";
  37. }
  38. bool CardCondition(CardSource cardSource)
  39. {
  40. if (cardSource == card)
  41. {
  42. if (CardEffectCommons.IsExistOnHand(cardSource))
  43. {
  44. return true;
  45. }
  46. }
  47. return false;
  48. }
  49. bool CanNoSelect(CardSource cardSource)
  50. {
  51. if (cardSource != null)
  52. {
  53. if (cardSource.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) > cardSource.Owner.MaxMemoryCost)
  54. {
  55. return false;
  56. }
  57. }
  58. return true;
  59. }
  60. bool CanUseCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.IsExistOnHand(card))
  67. {
  68. if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectThreeMusketeersCondition) >= 3)
  69. {
  70. return true;
  71. }
  72. }
  73. return false;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  76. {
  77. List<CardSource> selectedCards = new List<CardSource>();
  78. if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectThreeMusketeersCondition) >= 3)
  79. {
  80. bool noSelect = CanNoSelect(CardEffectCommons.GetCardFromHashtable(_hashtable));
  81. int maxCount = 3;
  82. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  83. selectCardEffect.SetUp(
  84. canTargetCondition: CanSelectThreeMusketeersCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. canNoSelect: () => noSelect,
  88. selectCardCoroutine: SelectCardCoroutine,
  89. afterSelectCardCoroutine: null,
  90. message: "Select cards to add to the bottom of your deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
  91. maxCount: maxCount,
  92. canEndNotMax: false,
  93. isShowOpponent: true,
  94. mode: SelectCardEffect.Mode.Custom,
  95. root: SelectCardEffect.Root.Trash,
  96. customRootCardList: null,
  97. canLookReverseCard: true,
  98. selectPlayer: card.Owner,
  99. cardEffect: activateClass);
  100. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  101. IEnumerator SelectCardCoroutine(CardSource cardSource)
  102. {
  103. selectedCards.Add(cardSource);
  104. yield return null;
  105. }
  106. if (selectedCards.Count == 3)
  107. {
  108. selectedCards.Reverse();
  109. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(selectedCards));
  110. }
  111. }
  112. if (card.Owner.CanReduceCost(null, card))
  113. {
  114. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  115. }
  116. ChangeCostClass changeCostClass = new ChangeCostClass();
  117. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition1, card);
  118. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  119. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  120. bool CanUseCondition1(Hashtable hashtable)
  121. {
  122. return true;
  123. }
  124. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  125. {
  126. if (CardSourceCondition(cardSource))
  127. {
  128. if (RootCondition(root))
  129. {
  130. if (PermanentsCondition(targetPermanents))
  131. {
  132. int targetCost = 0;
  133. if (selectedCards.Count >= 3)
  134. targetCost += 6;
  135. Cost -= targetCost;
  136. }
  137. }
  138. }
  139. return Cost;
  140. }
  141. bool PermanentsCondition(List<Permanent> targetPermanents)
  142. {
  143. if (targetPermanents == null)
  144. {
  145. return true;
  146. }
  147. else
  148. {
  149. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  150. {
  151. return true;
  152. }
  153. }
  154. return false;
  155. }
  156. bool CardSourceCondition(CardSource cardSource)
  157. {
  158. return cardSource == card;
  159. }
  160. bool RootCondition(SelectCardEffect.Root root)
  161. {
  162. return true;
  163. }
  164. bool isUpDown()
  165. {
  166. return true;
  167. }
  168. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  169. }
  170. }
  171. #endregion
  172. #region Reduce Play Cost - Not Shown
  173. if (timing == EffectTiming.None)
  174. {
  175. ChangeCostClass changeCostClass = new ChangeCostClass();
  176. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition, card);
  177. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  178. changeCostClass.SetNotShowUI(true);
  179. cardEffects.Add(changeCostClass);
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. if (card.Owner.HandCards.Contains(card))
  183. {
  184. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Return 3 [Three Musketeers] to get Play Cost -6");
  185. if (activateClass != null)
  186. {
  187. if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectThreeMusketeersCondition) >= 3)
  188. {
  189. return true;
  190. }
  191. }
  192. }
  193. return false;
  194. }
  195. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  196. {
  197. if (CardSourceCondition(cardSource))
  198. {
  199. if (RootCondition(root))
  200. {
  201. if (PermanentsCondition(targetPermanents))
  202. {
  203. int trashCount = CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectThreeMusketeersCondition);
  204. int targetCount = 0;
  205. if (trashCount >= 3)
  206. targetCount += 6;
  207. Cost -= targetCount;
  208. }
  209. }
  210. }
  211. return Cost;
  212. }
  213. bool PermanentsCondition(List<Permanent> targetPermanents)
  214. {
  215. if (targetPermanents == null)
  216. {
  217. return true;
  218. }
  219. else
  220. {
  221. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  222. {
  223. return true;
  224. }
  225. }
  226. return false;
  227. }
  228. bool CardSourceCondition(CardSource cardSource)
  229. {
  230. if (cardSource != null)
  231. {
  232. if (cardSource == card)
  233. {
  234. return true;
  235. }
  236. }
  237. return false;
  238. }
  239. bool RootCondition(SelectCardEffect.Root root)
  240. {
  241. return true;
  242. }
  243. bool isUpDown()
  244. {
  245. return true;
  246. }
  247. }
  248. #endregion
  249. #endregion
  250. #region Raid/Retaliation/Blocker
  251. if (timing == EffectTiming.OnAllyAttack)
  252. {
  253. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  254. }
  255. if (timing == EffectTiming.OnDestroyedAnyone)
  256. {
  257. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: false, card: card, condition: null));
  258. }
  259. if (timing == EffectTiming.None)
  260. {
  261. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  262. }
  263. #endregion
  264. #region On Deletion
  265. if (timing == EffectTiming.OnDestroyedAnyone)
  266. {
  267. ActivateClass activateClass = new ActivateClass();
  268. activateClass.SetUpICardEffect("Play 1 [Three Musketeers] trait Digimon from hand/trash", CanUseCondition, card);
  269. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  270. cardEffects.Add(activateClass);
  271. string EffectDiscription()
  272. {
  273. return "[On Deletion] You may play 1 [Three Musketeers] trait Digimon card with a play cost of 12 or less from your hand or trash without paying the cost.";
  274. }
  275. bool CanSelectCardCondition(CardSource cardSource)
  276. {
  277. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  278. {
  279. if (cardSource.EqualsTraits("Three Musketeers"))
  280. {
  281. if(cardSource.HasPlayCost && cardSource.GetCostItself <= 12)
  282. return true;
  283. }
  284. }
  285. return false;
  286. }
  287. bool CanUseCondition(Hashtable hashtable)
  288. {
  289. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  290. }
  291. bool CanActivateCondition(Hashtable hashtable)
  292. {
  293. if (CardEffectCommons.CanActivateOnDeletion(card))
  294. {
  295. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  296. {
  297. return true;
  298. }
  299. }
  300. return false;
  301. }
  302. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  303. {
  304. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  305. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  306. if (canSelectHand || canSelectTrash)
  307. {
  308. if (canSelectHand && canSelectTrash)
  309. {
  310. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  311. {
  312. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  313. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  314. };
  315. string selectPlayerMessage = "From which area do you play a card?";
  316. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  317. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  318. }
  319. else
  320. {
  321. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  322. }
  323. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  324. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  325. List<CardSource> selectedCards = new List<CardSource>();
  326. IEnumerator SelectCardCoroutine(CardSource cardSource)
  327. {
  328. selectedCards.Add(cardSource);
  329. yield return null;
  330. }
  331. if (fromHand)
  332. {
  333. int maxCount = 1;
  334. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  335. selectHandEffect.SetUp(
  336. selectPlayer: card.Owner,
  337. canTargetCondition: CanSelectCardCondition,
  338. canTargetCondition_ByPreSelecetedList: null,
  339. canEndSelectCondition: null,
  340. maxCount: maxCount,
  341. canNoSelect: true,
  342. canEndNotMax: false,
  343. isShowOpponent: true,
  344. selectCardCoroutine: SelectCardCoroutine,
  345. afterSelectCardCoroutine: null,
  346. mode: SelectHandEffect.Mode.Custom,
  347. cardEffect: activateClass);
  348. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  349. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  350. yield return StartCoroutine(selectHandEffect.Activate());
  351. }
  352. else
  353. {
  354. int maxCount = 1;
  355. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  356. selectCardEffect.SetUp(
  357. canTargetCondition: CanSelectCardCondition,
  358. canTargetCondition_ByPreSelecetedList: null,
  359. canEndSelectCondition: null,
  360. canNoSelect: () => true,
  361. selectCardCoroutine: SelectCardCoroutine,
  362. afterSelectCardCoroutine: null,
  363. message: "Select 1 card to play.",
  364. maxCount: maxCount,
  365. canEndNotMax: false,
  366. isShowOpponent: true,
  367. mode: SelectCardEffect.Mode.Custom,
  368. root: SelectCardEffect.Root.Trash,
  369. customRootCardList: null,
  370. canLookReverseCard: true,
  371. selectPlayer: card.Owner,
  372. cardEffect: activateClass);
  373. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  374. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  375. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  376. }
  377. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  378. if (!fromHand)
  379. {
  380. root = SelectCardEffect.Root.Trash;
  381. }
  382. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  383. cardSources: selectedCards,
  384. activateClass: activateClass,
  385. payCost: false,
  386. isTapped: false,
  387. root: root,
  388. activateETB: true));
  389. }
  390. }
  391. }
  392. #endregion
  393. return cardEffects;
  394. }
  395. }
  396. }