BT3_056.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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. public class BT3_056 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.BeforePayCost)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Digisorption -3", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. activateClass.SetHashString("Digisorption-3_BT2_047");
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "<Digisorption -3> (When one of your Digimon digivolves into this card from your hand, you may suspend 1 of your Digimon to reduce the memory cost of the digivolution by 3.)";
  23. }
  24. bool CanSelectCondition_CheckAvailability(Permanent permanent)
  25. {
  26. if (card.Owner.CanTapWhenAbsorbEvolution_CheckAvailability(permanent, activateClass))
  27. {
  28. if (permanent.CanSelectBySkill(activateClass))
  29. {
  30. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanSelectPermanentCondition(Permanent permanent)
  39. {
  40. if (card.Owner.CanTapWhenAbsorbEvolution(permanent, activateClass))
  41. {
  42. if (permanent.CanSelectBySkill(activateClass))
  43. {
  44. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. if (hashtable != null)
  55. {
  56. if (hashtable.ContainsKey("Card"))
  57. {
  58. if (hashtable["Card"] is CardSource)
  59. {
  60. CardSource Card = (CardSource)hashtable["Card"];
  61. if (Card == card)
  62. {
  63. if (hashtable.ContainsKey("isEvolution"))
  64. {
  65. if (hashtable["isEvolution"] is bool)
  66. {
  67. bool isEvolution = (bool)hashtable["isEvolution"];
  68. if (isEvolution)
  69. {
  70. if (hashtable.ContainsKey("Permanents"))
  71. {
  72. if (hashtable["Permanents"] is List<Permanent>)
  73. {
  74. List<Permanent> Permanents = (List<Permanent>)hashtable["Permanents"];
  75. if (Permanents != null)
  76. {
  77. if (Permanents.Count((permanent) => permanent.TopCard.Owner == card.Owner && permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent)) >= 1)
  78. {
  79. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count(CanSelectCondition_CheckAvailability) >= 1) >= 1)
  80. {
  81. return true;
  82. }
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
  94. return false;
  95. }
  96. bool CanActivateCondition(Hashtable hashtable)
  97. {
  98. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count(CanSelectCondition_CheckAvailability) >= 1) >= 1)
  99. {
  100. return true;
  101. }
  102. return false;
  103. }
  104. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  105. {
  106. #region
  107. Hashtable hashtable = new Hashtable();
  108. hashtable.Add("CardEffect", activateClass);
  109. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  110. {
  111. #region
  112. foreach (Permanent permanent1 in player.GetFieldPermanents())
  113. {
  114. foreach (ICardEffect cardEffect in permanent1.EffectList(EffectTiming.WhenDigisorption))
  115. {
  116. if (cardEffect is ActivateICardEffect)
  117. {
  118. if (cardEffect.CanTrigger(hashtable))
  119. {
  120. GManager.instance.autoProcessing_CutIn.PutStackedSkill(new SkillInfo(cardEffect, hashtable, EffectTiming.WhenDigisorption));
  121. }
  122. }
  123. }
  124. }
  125. #endregion
  126. #region
  127. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.WhenDigisorption))
  128. {
  129. if (cardEffect is ActivateICardEffect)
  130. {
  131. if (cardEffect.CanTrigger(hashtable))
  132. {
  133. GManager.instance.autoProcessing_CutIn.PutStackedSkill(new SkillInfo(cardEffect, hashtable, EffectTiming.WhenDigisorption));
  134. }
  135. }
  136. }
  137. #endregion
  138. }
  139. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.TriggeredSkillProcess(false, AutoProcessing.HasExecutedSameEffect));
  140. #endregion
  141. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count(CanSelectPermanentCondition) >= 1) >= 1)
  142. {
  143. int maxCount = 1;
  144. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  145. selectPermanentEffect.SetUp(
  146. selectPlayer: card.Owner,
  147. canTargetCondition: CanSelectPermanentCondition,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. maxCount: maxCount,
  151. canNoSelect: true,
  152. canEndNotMax: false,
  153. selectPermanentCoroutine: null,
  154. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  155. mode: SelectPermanentEffect.Mode.Tap,
  156. cardEffect: activateClass);
  157. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  158. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  159. {
  160. yield return null;
  161. if (permanents.Count >= 1)
  162. {
  163. if (card.Owner.CanReduceCost(new List<Permanent>() { new Permanent(new List<CardSource>()) }, card))
  164. {
  165. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  166. }
  167. ChangeCostClass changeCostClass = new ChangeCostClass();
  168. changeCostClass.SetUpICardEffect("Digivolution Cost -3", CanUseCondition1, card);
  169. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  170. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  171. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  172. bool CanUseCondition1(Hashtable hashtable)
  173. {
  174. return true;
  175. }
  176. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  177. {
  178. if (CardSourceCondition(cardSource))
  179. {
  180. if (RootCondition(root))
  181. {
  182. if (PermanentsCondition(targetPermanents))
  183. {
  184. Cost -= 3;
  185. }
  186. }
  187. }
  188. return Cost;
  189. }
  190. bool PermanentsCondition(List<Permanent> targetPermanents)
  191. {
  192. if (targetPermanents != null)
  193. {
  194. if (targetPermanents.Count(PermanentCondition) >= 1)
  195. {
  196. return true;
  197. }
  198. }
  199. return false;
  200. }
  201. bool PermanentCondition(Permanent targetPermanent)
  202. {
  203. if (targetPermanent.TopCard != null)
  204. {
  205. if (targetPermanent.TopCard.Owner == card.Owner)
  206. {
  207. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  208. {
  209. return true;
  210. }
  211. }
  212. }
  213. return false;
  214. }
  215. bool CardSourceCondition(CardSource cardSource)
  216. {
  217. if (cardSource != null)
  218. {
  219. if (cardSource == card)
  220. {
  221. return true;
  222. }
  223. }
  224. return false;
  225. }
  226. bool RootCondition(SelectCardEffect.Root root)
  227. {
  228. return true;
  229. }
  230. bool isUpDown()
  231. {
  232. return true;
  233. }
  234. }
  235. }
  236. }
  237. }
  238. }
  239. if (timing == EffectTiming.WhenDigisorption)
  240. {
  241. ActivateClass activateClass = new ActivateClass();
  242. activateClass.SetUpICardEffect("Suspend opponent's Digimon for Digisorption instead", CanUseCondition, card);
  243. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  244. activateClass.SetHashString("SuspendEnemyDigimonWhenDigisorption_BT3_056");
  245. cardEffects.Add(activateClass);
  246. string EffectDiscription()
  247. {
  248. return "[Your Turn][Once Per Turn] When suspending Digimon for a <Digisorption> skill, you may suspend your opponent's Digimon instead.";
  249. }
  250. bool PermanentCondition(Permanent targetPermanent)
  251. {
  252. if (targetPermanent != null)
  253. {
  254. if (targetPermanent.TopCard != null)
  255. {
  256. if (targetPermanent.TopCard.Owner == card.Owner.Enemy)
  257. {
  258. if (!targetPermanent.IsSuspended)
  259. {
  260. if (targetPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(targetPermanent))
  261. {
  262. return true;
  263. }
  264. }
  265. }
  266. }
  267. }
  268. return false;
  269. }
  270. bool CanUseCondition(Hashtable hashtable)
  271. {
  272. if (isExistOnField(card))
  273. {
  274. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  275. {
  276. if (CardEffectCommons.IsOwnerTurn(card))
  277. {
  278. if (hashtable != null)
  279. {
  280. if (hashtable.ContainsKey("CardEffect"))
  281. {
  282. if (hashtable["CardEffect"] is ICardEffect)
  283. {
  284. ICardEffect CardEffect = (ICardEffect)hashtable["CardEffect"];
  285. if (CardEffect != null)
  286. {
  287. if (CardEffect.EffectName.Contains("Digisorption"))
  288. {
  289. if (CardEffect.EffectSourceCard != null)
  290. {
  291. if (CardEffect.EffectSourceCard.Owner == card.Owner)
  292. {
  293. return true;
  294. }
  295. }
  296. }
  297. }
  298. }
  299. }
  300. }
  301. }
  302. }
  303. }
  304. return false;
  305. }
  306. bool CanActivateCondition(Hashtable hashtable)
  307. {
  308. if (CardEffectCommons.IsExistOnBattleArea(card))
  309. {
  310. if (card.Owner.Enemy.GetBattleAreaDigimons().Count(PermanentCondition) >= 1)
  311. {
  312. return true;
  313. }
  314. }
  315. return false;
  316. }
  317. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  318. {
  319. if (isExistOnField(card))
  320. {
  321. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  322. {
  323. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  324. CanSuspendByDigisorptionClass canTapDigisorptionClass = new CanSuspendByDigisorptionClass();
  325. canTapDigisorptionClass.SetUpICardEffect("Suspend your opponent's Digimon instead", CanUseCondition1, card);
  326. canTapDigisorptionClass.SetUpCanSuspendByDigisorptionClass(PermanentCondition: PermanentCondition, CardEffectCondition: CardEffectCondition, () => false);
  327. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => canTapDigisorptionClass);
  328. bool CanUseCondition1(Hashtable hashtable)
  329. {
  330. return true;
  331. }
  332. bool CardEffectCondition(ICardEffect cardEffect)
  333. {
  334. if (cardEffect != null)
  335. {
  336. if (cardEffect.EffectName.Contains("Digisorption"))
  337. {
  338. if (cardEffect.EffectSourceCard != null)
  339. {
  340. if (cardEffect.EffectSourceCard.Owner == card.Owner)
  341. {
  342. return true;
  343. }
  344. }
  345. }
  346. }
  347. return false;
  348. }
  349. yield return null;
  350. }
  351. }
  352. }
  353. }
  354. if (timing == EffectTiming.None)
  355. {
  356. CanSuspendByDigisorptionClass canTapDigisorptionClass = new CanSuspendByDigisorptionClass();
  357. canTapDigisorptionClass.SetUpICardEffect("Suspend your opponent's Digimon instead", CanUseCondition, card);
  358. canTapDigisorptionClass.SetUpCanSuspendByDigisorptionClass(PermanentCondition: PermanentCondition, CardEffectCondition: CardEffectCondition, () => true);
  359. canTapDigisorptionClass.SetNotShowUI(true);
  360. cardEffects.Add(canTapDigisorptionClass);
  361. bool CanUseCondition(Hashtable hashtable)
  362. {
  363. if (isExistOnField(card))
  364. {
  365. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  366. {
  367. if (CardEffectCommons.IsOwnerTurn(card))
  368. {
  369. if (card.EffectList(EffectTiming.WhenDigisorption).Count >= 1)
  370. {
  371. ICardEffect cardEffect = card.EffectList(EffectTiming.WhenDigisorption)[0];
  372. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(cardEffect, cardEffect.MaxCountPerTurn))
  373. {
  374. return true;
  375. }
  376. }
  377. }
  378. }
  379. }
  380. return false;
  381. }
  382. bool PermanentCondition(Permanent targetPermanent)
  383. {
  384. if (targetPermanent != null)
  385. {
  386. if (targetPermanent.TopCard != null)
  387. {
  388. if (targetPermanent.TopCard.Owner == card.Owner.Enemy)
  389. {
  390. if (!targetPermanent.IsSuspended)
  391. {
  392. if (targetPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(targetPermanent))
  393. {
  394. return true;
  395. }
  396. }
  397. }
  398. }
  399. }
  400. return false;
  401. }
  402. bool CardEffectCondition(ICardEffect cardEffect)
  403. {
  404. if (cardEffect != null)
  405. {
  406. if (cardEffect.EffectName.Contains("Digisorption"))
  407. {
  408. if (cardEffect.EffectSourceCard != null)
  409. {
  410. if (cardEffect.EffectSourceCard.Owner == card.Owner)
  411. {
  412. return true;
  413. }
  414. }
  415. }
  416. }
  417. return false;
  418. }
  419. }
  420. return cardEffects;
  421. }
  422. }