BT13_007.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_007 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. bool Condition()
  15. {
  16. if (CardEffectCommons.IsExistOnBreedingArea(card))
  17. {
  18. if (CardEffectCommons.IsOwnerTurn(card))
  19. {
  20. return true;
  21. }
  22. }
  23. return false;
  24. }
  25. bool PermanentCondition(Permanent permanent)
  26. {
  27. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  28. {
  29. return true;
  30. }
  31. return false;
  32. }
  33. cardEffects.Add(CardEffectFactory.CanNotDigivolveStaticEffect(
  34. permanentCondition: PermanentCondition,
  35. cardCondition: null,
  36. isInheritedEffect: false,
  37. card: card,
  38. condition: Condition,
  39. effectName: "Your Digimon can't digivolve")
  40. );
  41. }
  42. ActivateClass activateClass2 = new ActivateClass();
  43. activateClass2.SetUpICardEffect("Reduce play cost", CanUseCondition2, card);
  44. activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, 1, true, EffectDiscription2());
  45. activateClass2.SetHashString("Reduce_BT13_007");
  46. string EffectDiscription2()
  47. {
  48. return "[Breeding][Your Turn][Once Per Turn] When a [Royal Knight] trait Digimon card would be played, you may reduce the play cost by 4. Further reduce it by 1 for each of this Digimon's digivolution cards.";
  49. }
  50. bool CardCondition(CardSource cardSource)
  51. {
  52. if (cardSource.Owner == card.Owner)
  53. {
  54. if (cardSource.IsDigimon)
  55. {
  56. if (cardSource.HasRoyalKnightTraits)
  57. {
  58. return true;
  59. }
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanUseCondition2(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.IsExistOnBreedingArea(card))
  67. {
  68. if (CardEffectCommons.IsOwnerTurn(card))
  69. {
  70. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  71. {
  72. return true;
  73. }
  74. }
  75. }
  76. return false;
  77. }
  78. bool CanActivateCondition2(Hashtable hashtable)
  79. {
  80. if (CardEffectCommons.IsExistOnBreedingArea(card))
  81. {
  82. int reduceCount = card.PermanentOfThisCard().DigivolutionCards.Count + 4;
  83. if (reduceCount >= 1)
  84. {
  85. PlayCardClass playCardClass = CardEffectCommons.GetPlayCardClassFromHashtable(hashtable);
  86. if (playCardClass != null)
  87. {
  88. if (playCardClass.PayCost)
  89. {
  90. return true;
  91. }
  92. }
  93. }
  94. }
  95. return false;
  96. }
  97. IEnumerator ActivateCoroutine2(Hashtable _hashtable)
  98. {
  99. if (CardEffectCommons.IsExistOnBreedingArea(card))
  100. {
  101. int reduceCount = card.PermanentOfThisCard().DigivolutionCards.Count + 4;
  102. if (reduceCount >= 1)
  103. {
  104. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  105. ChangeCostClass changeCostClass = new ChangeCostClass();
  106. changeCostClass.SetUpICardEffect($"Play Cost -{reduceCount}", CanUseCondition1, card);
  107. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  108. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  109. yield return new WaitForSeconds(0.4f);
  110. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  111. bool CanUseCondition1(Hashtable hashtable)
  112. {
  113. return true;
  114. }
  115. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  116. {
  117. if (CardSourceCondition(cardSource))
  118. {
  119. if (RootCondition(root))
  120. {
  121. if (PermanentsCondition(targetPermanents))
  122. {
  123. Cost -= reduceCount;
  124. }
  125. }
  126. }
  127. return Cost;
  128. }
  129. bool PermanentsCondition(List<Permanent> targetPermanents)
  130. {
  131. if (targetPermanents == null)
  132. {
  133. return true;
  134. }
  135. else
  136. {
  137. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  138. {
  139. return true;
  140. }
  141. }
  142. return false;
  143. }
  144. bool CardSourceCondition(CardSource cardSource)
  145. {
  146. CardSource Card = CardEffectCommons.GetCardFromHashtable(_hashtable);
  147. if (Card != null)
  148. {
  149. if (cardSource == Card)
  150. {
  151. return true;
  152. }
  153. }
  154. return false;
  155. }
  156. bool RootCondition(SelectCardEffect.Root root)
  157. {
  158. return true;
  159. }
  160. bool isUpDown()
  161. {
  162. return true;
  163. }
  164. }
  165. }
  166. }
  167. if (timing == EffectTiming.BeforePayCost)
  168. {
  169. cardEffects.Add(activateClass2);
  170. }
  171. if (timing == EffectTiming.None)
  172. {
  173. ChangeCostClass changeCostClass = new ChangeCostClass();
  174. changeCostClass.SetUpICardEffect("Play Cost -", CanUseCondition, card);
  175. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  176. changeCostClass.SetNotShowUI(true);
  177. cardEffects.Add(changeCostClass);
  178. bool CanUseCondition(Hashtable hashtable)
  179. {
  180. if (!card.Owner.isYou && GManager.instance.IsAI)
  181. {
  182. return false;
  183. }
  184. if (CardEffectCommons.IsExistOnBreedingArea(card))
  185. {
  186. if (CardEffectCommons.IsOwnerTurn(card))
  187. {
  188. int reduceCount = card.PermanentOfThisCard().DigivolutionCards.Count + 4;
  189. if (reduceCount >= 1)
  190. {
  191. if (activateClass2 != null)
  192. {
  193. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass2, activateClass2.MaxCountPerTurn))
  194. {
  195. return true;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. return false;
  202. }
  203. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  204. {
  205. if (CardSourceCondition(cardSource))
  206. {
  207. if (RootCondition(root))
  208. {
  209. if (PermanentsCondition(targetPermanents))
  210. {
  211. int reduceCount = card.PermanentOfThisCard().DigivolutionCards.Count + 4;
  212. Cost -= reduceCount;
  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.IsDigimon)
  236. {
  237. if (cardSource.HasRoyalKnightTraits)
  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. if (timing == EffectTiming.OnStartMainPhase)
  254. {
  255. ActivateClass activateClass = new ActivateClass();
  256. activateClass.SetUpICardEffect("Reveal the top card of your Digi - Egg deck and place your Digimon under this Digimon", CanUseCondition, card);
  257. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  258. cardEffects.Add(activateClass);
  259. string EffectDiscription()
  260. {
  261. return "[Breeding][Start of Your Main Phase] Reveal the top card of your Digi-Egg deck, then place that card and all of your [Royal Knight] trait Digimon as this Digimon as its bottom digivolution cards.";
  262. }
  263. bool CanSelectPermanentCondition(Permanent permanent)
  264. {
  265. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  266. {
  267. if (permanent.TopCard.HasRoyalKnightTraits)
  268. {
  269. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  270. {
  271. if (!permanent.IsToken)
  272. {
  273. return true;
  274. }
  275. }
  276. }
  277. }
  278. return false;
  279. }
  280. bool CanUseCondition(Hashtable hashtable)
  281. {
  282. if (CardEffectCommons.IsExistOnBreedingArea(card))
  283. {
  284. if (CardEffectCommons.IsOwnerTurn(card))
  285. {
  286. return true;
  287. }
  288. }
  289. return false;
  290. }
  291. bool CanActivateCondition(Hashtable hashtable)
  292. {
  293. if (CardEffectCommons.IsExistOnBreedingArea(card))
  294. {
  295. if (card.Owner.DigitamaLibraryCards.Count >= 1)
  296. {
  297. return true;
  298. }
  299. if (!card.PermanentOfThisCard().IsToken)
  300. {
  301. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  302. {
  303. return true;
  304. }
  305. }
  306. }
  307. return false;
  308. }
  309. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  310. {
  311. if (CardEffectCommons.IsExistOnBreedingArea(card))
  312. {
  313. CardSource topCard = null;
  314. if (card.Owner.DigitamaLibraryCards.Count >= 1)
  315. {
  316. topCard = card.Owner.DigitamaLibraryCards[0];
  317. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { topCard }, "Revealed Card", true, true));
  318. }
  319. if (!card.PermanentOfThisCard().IsToken)
  320. {
  321. List<CardSource> selectedCards = new List<CardSource>();
  322. if (topCard != null)
  323. {
  324. selectedCards.Add(topCard);
  325. }
  326. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  327. {
  328. foreach (Permanent permanent in card.Owner.GetBattleAreaDigimons())
  329. {
  330. if (CanSelectPermanentCondition(permanent))
  331. {
  332. selectedCards.Add(permanent.TopCard);
  333. }
  334. }
  335. }
  336. if (selectedCards.Count >= 1)
  337. {
  338. List<CardSource> digivolutionCards = new List<CardSource>();
  339. if (selectedCards.Count == 1)
  340. {
  341. foreach (CardSource cardSource in selectedCards)
  342. {
  343. digivolutionCards.Add(cardSource);
  344. }
  345. }
  346. else
  347. {
  348. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  349. List<SkillInfo> skillInfos = new List<SkillInfo>();
  350. foreach (CardSource cardSource in selectedCards)
  351. {
  352. ICardEffect cardEffect = new ChangeBaseDPClass();
  353. cardEffect.SetUpICardEffect(" ", null, cardSource);
  354. skillInfos.Add(new SkillInfo(cardEffect, null, EffectTiming.None));
  355. }
  356. selectCardEffect.SetUp(
  357. canTargetCondition: (cardSource) => true,
  358. canTargetCondition_ByPreSelecetedList: null,
  359. canEndSelectCondition: null,
  360. canNoSelect: () => false,
  361. selectCardCoroutine: null,
  362. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  363. message: "Specify the order to place the cards in the digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  364. maxCount: selectedCards.Count,
  365. canEndNotMax: false,
  366. isShowOpponent: false,
  367. mode: SelectCardEffect.Mode.Custom,
  368. root: SelectCardEffect.Root.Custom,
  369. customRootCardList: selectedCards,
  370. canLookReverseCard: true,
  371. selectPlayer: card.Owner,
  372. cardEffect: activateClass);
  373. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  374. selectCardEffect.SetUpSkillInfos(skillInfos);
  375. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  376. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  377. {
  378. foreach (CardSource cardSource in cardSources)
  379. {
  380. digivolutionCards.Add(cardSource);
  381. }
  382. yield return null;
  383. }
  384. }
  385. if (CardEffectCommons.IsExistOnBreedingArea(card))
  386. {
  387. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(digivolutionCards, activateClass));
  388. }
  389. }
  390. }
  391. }
  392. }
  393. }
  394. if (timing == EffectTiming.OnEnterFieldAnyone)
  395. {
  396. ActivateClass activateClass = new ActivateClass();
  397. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  398. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  399. activateClass.SetIsInheritedEffect(true);
  400. activateClass.SetHashString("Memory+1_BT13_007");
  401. cardEffects.Add(activateClass);
  402. string EffectDiscription()
  403. {
  404. return "[Breeding][Your Turn][Once Per Turn] When an Option card with the [Royal Knight] trait is placed in the battle area, gain 1 memory.";
  405. }
  406. bool PermanentCondition(Permanent permanent)
  407. {
  408. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  409. {
  410. if (permanent.TopCard.IsOption)
  411. {
  412. if (permanent.TopCard.HasRoyalKnightTraits)
  413. {
  414. return true;
  415. }
  416. }
  417. }
  418. return false;
  419. }
  420. bool CanUseCondition(Hashtable hashtable)
  421. {
  422. if (CardEffectCommons.IsExistOnBreedingArea(card))
  423. {
  424. if (CardEffectCommons.IsOwnerTurn(card))
  425. {
  426. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  427. {
  428. return true;
  429. }
  430. }
  431. }
  432. return false;
  433. }
  434. bool CanActivateCondition(Hashtable hashtable)
  435. {
  436. if (CardEffectCommons.IsExistOnBreedingArea(card))
  437. {
  438. if (card.Owner.CanAddMemory(activateClass))
  439. {
  440. return true;
  441. }
  442. }
  443. return false;
  444. }
  445. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  446. {
  447. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  448. }
  449. }
  450. return cardEffects;
  451. }
  452. }
  453. }