BT10_052.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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_052 : 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.BeforePayCost)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Digisorption -2", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  20. activateClass.SetHashString("Digisorption-3_BT2_045");
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "<Digisorption -2> (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 2.)";
  25. }
  26. bool CanSelectCondition_CheckAvailability(Permanent permanent)
  27. {
  28. if (card.Owner.CanTapWhenAbsorbEvolution_CheckAvailability(permanent, activateClass))
  29. {
  30. if (permanent.CanSelectBySkill(activateClass))
  31. {
  32. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  33. {
  34. return true;
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanSelectPermanentCondition(Permanent permanent)
  41. {
  42. if (card.Owner.CanTapWhenAbsorbEvolution(permanent, activateClass))
  43. {
  44. if (permanent.CanSelectBySkill(activateClass))
  45. {
  46. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. if (hashtable != null)
  57. {
  58. if (hashtable.ContainsKey("Card"))
  59. {
  60. if (hashtable["Card"] is CardSource)
  61. {
  62. CardSource Card = (CardSource)hashtable["Card"];
  63. if (Card == card)
  64. {
  65. if (hashtable.ContainsKey("isEvolution"))
  66. {
  67. if (hashtable["isEvolution"] is bool)
  68. {
  69. bool isEvolution = (bool)hashtable["isEvolution"];
  70. if (isEvolution)
  71. {
  72. if (hashtable.ContainsKey("Permanents"))
  73. {
  74. if (hashtable["Permanents"] is List<Permanent>)
  75. {
  76. List<Permanent> Permanents = (List<Permanent>)hashtable["Permanents"];
  77. if (Permanents != null)
  78. {
  79. if (Permanents.Count((permanent) => permanent.TopCard.Owner == card.Owner && permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent)) >= 1)
  80. {
  81. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count(CanSelectCondition_CheckAvailability) >= 1) >= 1)
  82. {
  83. return true;
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }
  95. }
  96. return false;
  97. }
  98. bool CanActivateCondition(Hashtable hashtable)
  99. {
  100. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count(CanSelectCondition_CheckAvailability) >= 1) >= 1)
  101. {
  102. return true;
  103. }
  104. return false;
  105. }
  106. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  107. {
  108. #region ?z???i???????????
  109. Hashtable hashtable = new Hashtable();
  110. hashtable.Add("CardEffect", activateClass);
  111. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  112. {
  113. #region ???p?[?}?l???g?????
  114. foreach (Permanent permanent1 in player.GetFieldPermanents())
  115. {
  116. foreach (ICardEffect cardEffect in permanent1.EffectList(EffectTiming.WhenDigisorption))
  117. {
  118. if (cardEffect is ActivateICardEffect)
  119. {
  120. if (cardEffect.CanTrigger(hashtable))
  121. {
  122. GManager.instance.autoProcessing_CutIn.PutStackedSkill(new SkillInfo(cardEffect, hashtable, EffectTiming.WhenDigisorption));
  123. }
  124. }
  125. }
  126. }
  127. #endregion
  128. #region ?v???C???[?????
  129. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.WhenDigisorption))
  130. {
  131. if (cardEffect is ActivateICardEffect)
  132. {
  133. if (cardEffect.CanTrigger(hashtable))
  134. {
  135. GManager.instance.autoProcessing_CutIn.PutStackedSkill(new SkillInfo(cardEffect, hashtable, EffectTiming.WhenDigisorption));
  136. }
  137. }
  138. }
  139. #endregion
  140. }
  141. //??????????????
  142. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.TriggeredSkillProcess(false, AutoProcessing.HasExecutedSameEffect));
  143. #endregion
  144. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count(CanSelectPermanentCondition) >= 1) >= 1)
  145. {
  146. int maxCount = 1;
  147. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  148. selectPermanentEffect.SetUp(
  149. selectPlayer: card.Owner,
  150. canTargetCondition: CanSelectPermanentCondition,
  151. canTargetCondition_ByPreSelecetedList: null,
  152. canEndSelectCondition: null,
  153. maxCount: maxCount,
  154. canNoSelect: true,
  155. canEndNotMax: false,
  156. selectPermanentCoroutine: null,
  157. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  158. mode: SelectPermanentEffect.Mode.Tap,
  159. cardEffect: activateClass);
  160. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  161. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  162. {
  163. yield return null;
  164. if (permanents.Count >= 1)
  165. {
  166. if (card.Owner.CanReduceCost(new List<Permanent>() { new Permanent(new List<CardSource>()) }, card))
  167. {
  168. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  169. }
  170. ChangeCostClass changeCostClass = new ChangeCostClass();
  171. changeCostClass.SetUpICardEffect("Digivolution Cost -2", CanUseCondition1, card);
  172. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  173. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  174. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  175. bool CanUseCondition1(Hashtable hashtable)
  176. {
  177. return true;
  178. }
  179. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  180. {
  181. if (CardSourceCondition(cardSource))
  182. {
  183. if (RootCondition(root))
  184. {
  185. if (PermanentsCondition(targetPermanents))
  186. {
  187. Cost -= 2;
  188. }
  189. }
  190. }
  191. return Cost;
  192. }
  193. bool PermanentsCondition(List<Permanent> targetPermanents)
  194. {
  195. if (targetPermanents != null)
  196. {
  197. if (targetPermanents.Count(PermanentCondition) >= 1)
  198. {
  199. return true;
  200. }
  201. }
  202. return false;
  203. }
  204. bool PermanentCondition(Permanent targetPermanent)
  205. {
  206. if (targetPermanent.TopCard != null)
  207. {
  208. if (targetPermanent.TopCard.Owner == card.Owner)
  209. {
  210. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  211. {
  212. return true;
  213. }
  214. }
  215. }
  216. return false;
  217. }
  218. bool CardSourceCondition(CardSource cardSource)
  219. {
  220. if (cardSource != null)
  221. {
  222. if (cardSource == card)
  223. {
  224. return true;
  225. }
  226. }
  227. return false;
  228. }
  229. bool RootCondition(SelectCardEffect.Root root)
  230. {
  231. return true;
  232. }
  233. bool isUpDown()
  234. {
  235. return true;
  236. }
  237. }
  238. }
  239. }
  240. }
  241. }
  242. if (timing == EffectTiming.OnAllyAttack)
  243. {
  244. ActivateClass activateClass = new ActivateClass();
  245. activateClass.SetUpICardEffect("Switch Attack Target", CanUseCondition, card);
  246. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  247. cardEffects.Add(activateClass);
  248. string EffectDiscription()
  249. {
  250. return "[Opponent's Turn][Once Per Turn] When an opponent's Digimon attacks, you may switch the target of attack to 1 of your suspended Digimon.";
  251. }
  252. bool PermanentCondition(Permanent permanent)
  253. {
  254. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  255. }
  256. bool CanSelectPermanentCondition(Permanent permanent)
  257. {
  258. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  259. {
  260. if (permanent.IsSuspended)
  261. {
  262. return true;
  263. }
  264. }
  265. return false;
  266. }
  267. bool CanUseCondition(Hashtable hashtable)
  268. {
  269. if (CardEffectCommons.IsExistOnBattleArea(card))
  270. {
  271. if (CardEffectCommons.IsOpponentTurn(card))
  272. {
  273. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  274. {
  275. return true;
  276. }
  277. }
  278. }
  279. return false;
  280. }
  281. bool CanActivateCondition(Hashtable hashtable)
  282. {
  283. if (CardEffectCommons.IsExistOnBattleArea(card))
  284. {
  285. if (GManager.instance.attackProcess.AttackingPermanent != null)
  286. {
  287. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  288. {
  289. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  290. {
  291. return true;
  292. }
  293. }
  294. }
  295. }
  296. return false;
  297. }
  298. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  299. {
  300. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  301. {
  302. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  303. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  304. selectPermanentEffect.SetUp(
  305. selectPlayer: card.Owner,
  306. canTargetCondition: CanSelectPermanentCondition,
  307. canTargetCondition_ByPreSelecetedList: null,
  308. canEndSelectCondition: null,
  309. maxCount: maxCount,
  310. canNoSelect: true,
  311. canEndNotMax: false,
  312. selectPermanentCoroutine: SelectPermanentCoroutine,
  313. afterSelectPermanentCoroutine: null,
  314. mode: SelectPermanentEffect.Mode.Custom,
  315. cardEffect: activateClass);
  316. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that opponent's Digimon attacks to.", "The opponent is selecting 1 Digimon that opponent's Digimon attacks to.");
  317. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  318. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  319. {
  320. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  321. activateClass,
  322. false,
  323. permanent));
  324. }
  325. }
  326. }
  327. }
  328. return cardEffects;
  329. }
  330. }
  331. }