BT20_057.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Gankoomon
  5. namespace DCGO.CardEffects.BT20
  6. {
  7. public class BT20_057 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Reduce Play Cost
  13. bool HasProperTraitInPlay(Permanent permanent)
  14. {
  15. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  16. {
  17. if (permanent.IsDigimon)
  18. {
  19. return permanent.TopCard.ContainsCardName("Huckmon") ||
  20. permanent.TopCard.ContainsCardName("Jesmon") ||
  21. permanent.TopCard.ContainsCardName("Sistermon");
  22. }
  23. }
  24. return false;
  25. }
  26. #region Before Pay Cost - Condition Effect
  27. if (timing == EffectTiming.BeforePayCost)
  28. {
  29. ActivateClass activateClass = new ActivateClass();
  30. activateClass.SetUpICardEffect("Reduce the play cost by 4", CanUseCondition, card);
  31. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  32. activateClass.SetHashString("PlayCost-4_BT20_057");
  33. cardEffects.Add(activateClass);
  34. string EffectDiscription()
  35. {
  36. return "When this card would be played, if you have a Digimon with [Huckmon], [Jesmon], or [Sistermon] in its name, reduce the play cost by 4.";
  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 CanUseCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. if (CardEffectCommons.IsExistOnHand(card))
  56. {
  57. return CardEffectCommons.HasMatchConditionPermanent(HasProperTraitInPlay);
  58. }
  59. return false;
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  62. {
  63. if (card.Owner.CanReduceCost(null, card))
  64. {
  65. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  66. }
  67. ChangeCostClass changeCostClass = new ChangeCostClass();
  68. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  69. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  70. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  71. bool CanUseCondition1(Hashtable hashtable)
  72. {
  73. return true;
  74. }
  75. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  76. {
  77. if (CardSourceCondition(cardSource))
  78. {
  79. if (RootCondition(root))
  80. {
  81. if (PermanentsCondition(targetPermanents))
  82. {
  83. int targetCost = 0;
  84. if (CardEffectCommons.HasMatchConditionPermanent(HasProperTraitInPlay))
  85. targetCost += 4;
  86. Cost -= targetCost;
  87. }
  88. }
  89. }
  90. return Cost;
  91. }
  92. bool PermanentsCondition(List<Permanent> targetPermanents)
  93. {
  94. if (targetPermanents == null)
  95. {
  96. return true;
  97. }
  98. else
  99. {
  100. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  101. {
  102. return true;
  103. }
  104. }
  105. return false;
  106. }
  107. bool CardSourceCondition(CardSource cardSource)
  108. {
  109. return cardSource == card;
  110. }
  111. bool RootCondition(SelectCardEffect.Root root)
  112. {
  113. return true;
  114. }
  115. bool isUpDown()
  116. {
  117. return true;
  118. }
  119. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  120. }
  121. }
  122. #endregion
  123. #region Reduce Play Cost - Not Shown
  124. if (timing == EffectTiming.None)
  125. {
  126. ChangeCostClass changeCostClass = new ChangeCostClass();
  127. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition, card);
  128. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  129. changeCostClass.SetNotShowUI(true);
  130. cardEffects.Add(changeCostClass);
  131. bool CanUseCondition(Hashtable hashtable)
  132. {
  133. if (card.Owner.HandCards.Contains(card))
  134. {
  135. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Reduce the play cost by 4");
  136. if (activateClass != null)
  137. {
  138. return CardEffectCommons.HasMatchConditionPermanent(HasProperTraitInPlay);
  139. }
  140. }
  141. return false;
  142. }
  143. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  144. {
  145. if (CardSourceCondition(cardSource))
  146. {
  147. if (RootCondition(root))
  148. {
  149. if (PermanentsCondition(targetPermanents))
  150. {
  151. int targetCount = 0;
  152. if (CardEffectCommons.HasMatchConditionPermanent(HasProperTraitInPlay))
  153. targetCount += 4;
  154. Cost -= targetCount;
  155. }
  156. }
  157. }
  158. return Cost;
  159. }
  160. bool PermanentsCondition(List<Permanent> targetPermanents)
  161. {
  162. if (targetPermanents == null)
  163. {
  164. return true;
  165. }
  166. else
  167. {
  168. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  169. {
  170. return true;
  171. }
  172. }
  173. return false;
  174. }
  175. bool CardSourceCondition(CardSource cardSource)
  176. {
  177. if (cardSource != null)
  178. {
  179. if (cardSource == card)
  180. {
  181. return true;
  182. }
  183. }
  184. return false;
  185. }
  186. bool RootCondition(SelectCardEffect.Root root)
  187. {
  188. return true;
  189. }
  190. bool isUpDown()
  191. {
  192. return true;
  193. }
  194. }
  195. #endregion
  196. #endregion
  197. #region Reboot/Blocker
  198. if (timing == EffectTiming.None)
  199. {
  200. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(
  201. isInheritedEffect: false,
  202. card: card,
  203. condition: null));
  204. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  205. isInheritedEffect: false,
  206. card: card,
  207. condition: null));
  208. }
  209. #endregion
  210. #region On Play
  211. if (timing == EffectTiming.OnEnterFieldAnyone)
  212. {
  213. ActivateClass activateClass = new ActivateClass();
  214. activateClass.SetUpICardEffect("Digivolve into level 6", CanUseCondition, card);
  215. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  216. cardEffects.Add(activateClass);
  217. string EffectDiscription()
  218. {
  219. return "[On Play] 1 of your Digimon may digivolve into a level 6 or lower Digimon card with [Huckmon] in its name or the [Royal Knight] trait in the hand or trash without paying the cost.";
  220. }
  221. bool CanSelectPermanentCondition(Permanent permanent)
  222. {
  223. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  224. {
  225. foreach (CardSource cardSource in card.Owner.HandCards)
  226. {
  227. if (CanSelectCardCondition(cardSource))
  228. {
  229. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass))
  230. {
  231. return true;
  232. }
  233. }
  234. }
  235. foreach (CardSource cardSource in card.Owner.TrashCards)
  236. {
  237. if (CanSelectCardCondition(cardSource))
  238. {
  239. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass))
  240. {
  241. return true;
  242. }
  243. }
  244. }
  245. }
  246. return false;
  247. }
  248. bool CanSelectCardCondition(CardSource cardSource)
  249. {
  250. return cardSource.IsDigimon &&
  251. cardSource.HasLevel && cardSource.Level <= 6 &&
  252. (cardSource.ContainsCardName("Huckmon") || cardSource.HasRoyalKnightTraits);
  253. }
  254. bool CanUseCondition(Hashtable hashtable)
  255. {
  256. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  257. }
  258. bool CanActivateCondition(Hashtable hashtable)
  259. {
  260. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  261. {
  262. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  263. {
  264. return true;
  265. }
  266. }
  267. return false;
  268. }
  269. IEnumerator ActivateCoroutine(Hashtable hashtable)
  270. {
  271. Permanent selectedPermanent = null;
  272. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  273. selectPermanentEffect.SetUp(
  274. selectPlayer: card.Owner,
  275. canTargetCondition: CanSelectPermanentCondition,
  276. canTargetCondition_ByPreSelecetedList: null,
  277. canEndSelectCondition: null,
  278. maxCount: 1,
  279. canNoSelect: true,
  280. canEndNotMax: false,
  281. selectPermanentCoroutine: SelectPermanentCoroutine,
  282. afterSelectPermanentCoroutine: null,
  283. mode: SelectPermanentEffect.Mode.Custom,
  284. cardEffect: activateClass);
  285. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  286. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  287. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  288. {
  289. selectedPermanent = permanent;
  290. yield return null;
  291. }
  292. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  293. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  294. if (canSelectHand || canSelectTrash)
  295. {
  296. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  297. {
  298. new(message: "Digivolve", value: true, spriteIndex: 0),
  299. new(message: "Do not digivolve", value: false, spriteIndex: 1),
  300. };
  301. string selectPlayerMessage = "Digivolve?";
  302. string notSelectPlayerMessage = "The opponent is choosing whether to digivolve.";
  303. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  304. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  305. notSelectPlayerMessage: notSelectPlayerMessage);
  306. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  307. .WaitForEndSelect());
  308. if (GManager.instance.userSelectionManager.SelectedBoolValue)
  309. {
  310. if (canSelectHand && canSelectTrash)
  311. {
  312. selectionElements = new List<SelectionElement<bool>>()
  313. {
  314. new(message: "From hand", value: true, spriteIndex: 0),
  315. new(message: "From trash", value: false, spriteIndex: 1),
  316. };
  317. selectPlayerMessage = "From which area do you play a card?";
  318. notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  319. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  320. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  321. notSelectPlayerMessage: notSelectPlayerMessage);
  322. }
  323. else
  324. {
  325. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  326. }
  327. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  328. .WaitForEndSelect());
  329. yield return ContinuousController.instance.StartCoroutine(
  330. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  331. targetPermanent: selectedPermanent,
  332. cardCondition: CanSelectCardCondition,
  333. payCost: false,
  334. reduceCostTuple: null,
  335. fixedCostTuple: null,
  336. ignoreDigivolutionRequirementFixedCost: -1,
  337. isHand: GManager.instance.userSelectionManager.SelectedBoolValue,
  338. activateClass: activateClass,
  339. successProcess: null));
  340. }
  341. }
  342. }
  343. }
  344. #endregion
  345. #region When Digivolving
  346. if (timing == EffectTiming.OnEnterFieldAnyone)
  347. {
  348. ActivateClass activateClass = new ActivateClass();
  349. activateClass.SetUpICardEffect("Digivolve into level 6", CanUseCondition, card);
  350. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  351. cardEffects.Add(activateClass);
  352. string EffectDiscription()
  353. {
  354. return "[When Digivolving] 1 of your Digimon may digivolve into a level 6 or lower Digimon card with [Huckmon] in its name or the [Royal Knight] trait in the hand or trash without paying the cost.";
  355. }
  356. bool CanSelectPermanentCondition(Permanent permanent)
  357. {
  358. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  359. {
  360. foreach (CardSource cardSource in card.Owner.HandCards)
  361. {
  362. if (CanSelectCardCondition(cardSource))
  363. {
  364. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass))
  365. {
  366. return true;
  367. }
  368. }
  369. }
  370. foreach (CardSource cardSource in card.Owner.TrashCards)
  371. {
  372. if (CanSelectCardCondition(cardSource))
  373. {
  374. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass))
  375. {
  376. return true;
  377. }
  378. }
  379. }
  380. }
  381. return false;
  382. }
  383. bool CanSelectCardCondition(CardSource cardSource)
  384. {
  385. return cardSource.IsDigimon &&
  386. cardSource.HasLevel && cardSource.Level <= 6 &&
  387. (cardSource.ContainsCardName("Huckmon") || cardSource.HasRoyalKnightTraits);
  388. }
  389. bool CanUseCondition(Hashtable hashtable)
  390. {
  391. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  392. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  393. }
  394. bool CanActivateCondition(Hashtable hashtable)
  395. {
  396. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  397. {
  398. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  399. {
  400. return true;
  401. }
  402. }
  403. return false;
  404. }
  405. IEnumerator ActivateCoroutine(Hashtable hashtable)
  406. {
  407. Permanent selectedPermanent = null;
  408. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  409. selectPermanentEffect.SetUp(
  410. selectPlayer: card.Owner,
  411. canTargetCondition: CanSelectPermanentCondition,
  412. canTargetCondition_ByPreSelecetedList: null,
  413. canEndSelectCondition: null,
  414. maxCount: 1,
  415. canNoSelect: true,
  416. canEndNotMax: false,
  417. selectPermanentCoroutine: SelectPermanentCoroutine,
  418. afterSelectPermanentCoroutine: null,
  419. mode: SelectPermanentEffect.Mode.Custom,
  420. cardEffect: activateClass);
  421. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  422. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  423. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  424. {
  425. selectedPermanent = permanent;
  426. yield return null;
  427. }
  428. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  429. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  430. if (canSelectHand || canSelectTrash)
  431. {
  432. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  433. {
  434. new(message: "Digivolve", value: true, spriteIndex: 0),
  435. new(message: "Do not digivolve", value: false, spriteIndex: 1),
  436. };
  437. string selectPlayerMessage = "Digivolve?";
  438. string notSelectPlayerMessage = "The opponent is choosing whether to digivolve.";
  439. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  440. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  441. notSelectPlayerMessage: notSelectPlayerMessage);
  442. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  443. .WaitForEndSelect());
  444. if (GManager.instance.userSelectionManager.SelectedBoolValue)
  445. {
  446. if (canSelectHand && canSelectTrash)
  447. {
  448. selectionElements = new List<SelectionElement<bool>>()
  449. {
  450. new(message: "From hand", value: true, spriteIndex: 0),
  451. new(message: "From trash", value: false, spriteIndex: 1),
  452. };
  453. selectPlayerMessage = "From which area do you play a card?";
  454. notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  455. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  456. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  457. notSelectPlayerMessage: notSelectPlayerMessage);
  458. }
  459. else
  460. {
  461. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  462. }
  463. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  464. .WaitForEndSelect());
  465. yield return ContinuousController.instance.StartCoroutine(
  466. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  467. targetPermanent: selectedPermanent,
  468. cardCondition: CanSelectCardCondition,
  469. payCost: false,
  470. reduceCostTuple: null,
  471. fixedCostTuple: null,
  472. ignoreDigivolutionRequirementFixedCost: -1,
  473. isHand: GManager.instance.userSelectionManager.SelectedBoolValue,
  474. activateClass: activateClass,
  475. successProcess: null));
  476. }
  477. }
  478. }
  479. }
  480. #endregion
  481. return cardEffects;
  482. }
  483. }
  484. }