BT10_093.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.BT10
  9. {
  10. public class BT10_093 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.OnAddDigivolutionCards)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Draw 1 and Memory +1", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  20. activateClass.SetHashString("Draw1Memory+1_BT10_093");
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[All Turns] [Once Per Turn] When a purple card is placed under this Tamer, <Draw 1> (Draw 1 card from your deck.) and memory +1.";
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. if (CardEffectCommons.IsExistOnBattleArea(card))
  29. {
  30. if (CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  31. hashtable: hashtable,
  32. permanentCondition: permanent => permanent == card.PermanentOfThisCard(),
  33. cardEffectCondition: null,
  34. cardCondition: cardSource => cardSource.HasCardColor(CardColor.Purple)))
  35. {
  36. return true;
  37. }
  38. }
  39. return false;
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. return true;
  46. }
  47. return false;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  50. {
  51. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  52. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  53. }
  54. }
  55. ActivateClass activateClass2 = new ActivateClass();
  56. activateClass2.SetUpICardEffect("Reduce play cost", CanUseCondition2, card);
  57. activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, 1, true, EffectDiscription2());
  58. activateClass2.SetHashString("Reduce_BT10_093");
  59. string EffectDiscription2()
  60. {
  61. return "[Your turn] [Once per turn] When you would play 1 level 4 or higher Digimon card with [Bagra Army] in its traits, by placing up to 3 purple Digimon cards from under your Tamers in the digivolution cards of the Digimon card played, reduce the memory cost of that Digimon by 2 for each card placed.";
  62. }
  63. bool CardCondition(CardSource cardSource)
  64. {
  65. if (cardSource.Owner == card.Owner)
  66. {
  67. if (cardSource.IsDigimon)
  68. {
  69. if (cardSource.Level >= 4 && cardSource.HasLevel)
  70. {
  71. if (cardSource.CardTraits.Contains("Bagra Army") || cardSource.CardTraits.Contains("BagraArmy"))
  72. {
  73. return true;
  74. }
  75. }
  76. }
  77. }
  78. return false;
  79. }
  80. bool CanUseCondition2(Hashtable hashtable)
  81. {
  82. if (CardEffectCommons.IsExistOnBattleArea(card))
  83. {
  84. if (CardEffectCommons.IsOwnerTurn(card))
  85. {
  86. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  87. {
  88. if (CardEffectCommons.IsOnly1CardPlayed(hashtable))
  89. {
  90. return true;
  91. }
  92. }
  93. }
  94. }
  95. return false;
  96. }
  97. bool CanActivateCondition2(Hashtable hashtable)
  98. {
  99. if (CardEffectCommons.IsExistOnBattleArea(card))
  100. {
  101. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer && permanent.DigivolutionCards.Count((cardSource) => cardSource.IsDigimon && cardSource.HasCardColor(CardColor.Purple) && GManager.instance.GetComponent<SelectDigiXrosClass>().addDigivolutionCardInfos.Count((addDigivolutionCardInfo) => addDigivolutionCardInfo.cardSources.Contains(cardSource)) == 0) >= 1))
  102. {
  103. return true;
  104. }
  105. }
  106. return false;
  107. }
  108. IEnumerator ActivateCoroutine2(Hashtable _hashtable)
  109. {
  110. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer && permanent.DigivolutionCards.Count((cardSource) => cardSource.IsDigimon && cardSource.HasCardColor(CardColor.Purple)) >= 1))
  111. {
  112. List<CardSource> digivolutionCards = new List<CardSource>();
  113. bool CanSelectCardCondition(CardSource cardSource)
  114. {
  115. if (!digivolutionCards.Contains(cardSource))
  116. {
  117. if (GManager.instance.GetComponent<SelectDigiXrosClass>().addDigivolutionCardInfos.Count((addDigivolutionCardInfo) => addDigivolutionCardInfo.cardSources.Contains(cardSource)) == 0)
  118. {
  119. if (cardSource.HasCardColor(CardColor.Purple))
  120. {
  121. if (cardSource.IsDigimon)
  122. {
  123. return true;
  124. }
  125. }
  126. }
  127. }
  128. return false;
  129. }
  130. bool CanSelectPermanentCondition(Permanent permanent)
  131. {
  132. if (permanent != null)
  133. {
  134. if (permanent.TopCard != null)
  135. {
  136. if (permanent.IsTamer)
  137. {
  138. if (permanent.TopCard.Owner == card.Owner)
  139. {
  140. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  141. {
  142. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  143. {
  144. return true;
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. return false;
  152. }
  153. while (digivolutionCards.Count < 3 && card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  154. {
  155. if (!card.Owner.isYou && GManager.instance.IsAI)
  156. {
  157. break;
  158. }
  159. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  160. {
  161. Permanent selectedPermanent = null;
  162. int maxCount = Math.Min(1, card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  163. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  164. selectPermanentEffect.SetUp(
  165. selectPlayer: card.Owner,
  166. canTargetCondition: CanSelectPermanentCondition,
  167. canTargetCondition_ByPreSelecetedList: null,
  168. canEndSelectCondition: null,
  169. maxCount: maxCount,
  170. canNoSelect: true,
  171. canEndNotMax: false,
  172. selectPermanentCoroutine: SelectPermanentCoroutine,
  173. afterSelectPermanentCoroutine: null,
  174. mode: SelectPermanentEffect.Mode.Custom,
  175. cardEffect: activateClass2);
  176. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  177. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  178. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  179. {
  180. selectedPermanent = permanent;
  181. yield return null;
  182. }
  183. if (selectedPermanent == null)
  184. {
  185. break;
  186. }
  187. else
  188. {
  189. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  190. {
  191. maxCount = 3 - digivolutionCards.Count;
  192. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) < maxCount)
  193. {
  194. maxCount = selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition);
  195. }
  196. List<CardSource> selectedCards = new List<CardSource>();
  197. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  198. selectCardEffect.SetUp(
  199. canTargetCondition: CanSelectCardCondition,
  200. canTargetCondition_ByPreSelecetedList: null,
  201. canEndSelectCondition: null,
  202. canNoSelect: () => true,
  203. selectCardCoroutine: SelectCardCoroutine,
  204. afterSelectCardCoroutine: null,
  205. message: "Select digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  206. maxCount: maxCount,
  207. canEndNotMax: true,
  208. isShowOpponent: true,
  209. mode: SelectCardEffect.Mode.Custom,
  210. root: SelectCardEffect.Root.Custom,
  211. customRootCardList: selectedPermanent.DigivolutionCards,
  212. canLookReverseCard: true,
  213. selectPlayer: card.Owner,
  214. cardEffect: activateClass2);
  215. selectCardEffect.SetUpCustomMessage("Select digivolution cards.", "The opponent is selecting digivolution cards.");
  216. //selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  217. yield return StartCoroutine(selectCardEffect.Activate());
  218. IEnumerator SelectCardCoroutine(CardSource cardSource)
  219. {
  220. selectedCards.Add(cardSource);
  221. yield return null;
  222. }
  223. if (selectedCards.Count >= 1)
  224. {
  225. foreach (CardSource cardSource in selectedCards)
  226. {
  227. digivolutionCards.Add(cardSource);
  228. }
  229. }
  230. }
  231. }
  232. if (digivolutionCards.Count >= 1)
  233. {
  234. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(digivolutionCards, "Digivolution Cards", true, true));
  235. }
  236. }
  237. }
  238. if (digivolutionCards.Count >= 1)
  239. {
  240. GManager.instance.GetComponent<SelectDigiXrosClass>().AddDigivolutionCardInfos(new AddDigivolutionCardsInfo(activateClass2, digivolutionCards));
  241. int reduceCount = 2 * digivolutionCards.Count;
  242. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  243. ChangeCostClass changeCostClass = new ChangeCostClass();
  244. changeCostClass.SetUpICardEffect($"Play Cost -{reduceCount}", CanUseCondition1, card);
  245. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  246. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  247. yield return new WaitForSeconds(0.2f);
  248. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  249. bool CanUseCondition1(Hashtable hashtable)
  250. {
  251. return true;
  252. }
  253. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  254. {
  255. if (CardSourceCondition(cardSource))
  256. {
  257. if (RootCondition(root))
  258. {
  259. if (PermanentsCondition(targetPermanents))
  260. {
  261. Cost -= reduceCount;
  262. }
  263. }
  264. }
  265. return Cost;
  266. }
  267. bool PermanentsCondition(List<Permanent> targetPermanents)
  268. {
  269. if (targetPermanents == null)
  270. {
  271. return true;
  272. }
  273. else
  274. {
  275. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  276. {
  277. return true;
  278. }
  279. }
  280. return false;
  281. }
  282. bool CardSourceCondition(CardSource cardSource)
  283. {
  284. if (cardSource != null)
  285. {
  286. if (cardSource.Owner == card.Owner)
  287. {
  288. return true;
  289. }
  290. }
  291. return false;
  292. }
  293. bool RootCondition(SelectCardEffect.Root root)
  294. {
  295. return true;
  296. }
  297. bool isUpDown()
  298. {
  299. return true;
  300. }
  301. }
  302. }
  303. }
  304. if (timing == EffectTiming.BeforePayCost)
  305. {
  306. cardEffects.Add(activateClass2);
  307. }
  308. if (timing == EffectTiming.None)
  309. {
  310. ChangeCostClass changeCostClass = new ChangeCostClass();
  311. changeCostClass.SetUpICardEffect("Play Cost -", CanUseCondition, card);
  312. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  313. changeCostClass.SetNotShowUI(true);
  314. cardEffects.Add(changeCostClass);
  315. bool CanUseCondition(Hashtable hashtable)
  316. {
  317. if (!card.Owner.isYou && GManager.instance.IsAI)
  318. {
  319. return false;
  320. }
  321. if (CardEffectCommons.IsExistOnBattleArea(card))
  322. {
  323. if (CardEffectCommons.IsOwnerTurn(card))
  324. {
  325. if (activateClass2 != null)
  326. {
  327. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass2, activateClass2.MaxCountPerTurn))
  328. {
  329. return true;
  330. }
  331. }
  332. }
  333. }
  334. return false;
  335. }
  336. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  337. {
  338. if (CardSourceCondition(cardSource))
  339. {
  340. if (RootCondition(root))
  341. {
  342. if (PermanentsCondition(targetPermanents))
  343. {
  344. if (!card.Owner.isYou && GManager.instance.IsAI)
  345. {
  346. return Cost;
  347. }
  348. int maxCount = 0;
  349. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  350. {
  351. if (permanent.IsTamer)
  352. {
  353. maxCount += permanent.DigivolutionCards.Count((cardSource) => cardSource.HasCardColor(CardColor.Purple) && cardSource.IsDigimon);
  354. }
  355. if (maxCount >= 3)
  356. {
  357. break;
  358. }
  359. }
  360. if (maxCount >= 3)
  361. {
  362. maxCount = 3;
  363. }
  364. Cost -= 2 * maxCount;
  365. }
  366. }
  367. }
  368. return Cost;
  369. }
  370. bool PermanentsCondition(List<Permanent> targetPermanents)
  371. {
  372. if (targetPermanents == null)
  373. {
  374. return true;
  375. }
  376. else
  377. {
  378. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  379. {
  380. return true;
  381. }
  382. }
  383. return false;
  384. }
  385. bool CardSourceCondition(CardSource cardSource)
  386. {
  387. if (cardSource != null)
  388. {
  389. if (cardSource.Owner == card.Owner)
  390. {
  391. if (cardSource.Level >= 4 && cardSource.HasLevel)
  392. {
  393. if (cardSource.IsDigimon)
  394. {
  395. if (cardSource.CardTraits.Contains("Bagra Army"))
  396. {
  397. return true;
  398. }
  399. if (cardSource.CardTraits.Contains("BagraArmy"))
  400. {
  401. return true;
  402. }
  403. }
  404. }
  405. }
  406. }
  407. return false;
  408. }
  409. bool RootCondition(SelectCardEffect.Root root)
  410. {
  411. return true;
  412. }
  413. bool isUpDown()
  414. {
  415. return true;
  416. }
  417. }
  418. if (timing == EffectTiming.SecuritySkill)
  419. {
  420. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  421. }
  422. return cardEffects;
  423. }
  424. }
  425. }