EX3_043.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX3
  5. {
  6. public class EX3_043 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.BeforePayCost)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Digisorption -3", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  16. activateClass.SetHashString("Digisorption-3_EX3_043");
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. 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 2.)";
  21. }
  22. bool CanSelectCondition_CheckAvailability(Permanent permanent)
  23. {
  24. if (card.Owner.CanTapWhenAbsorbEvolution_CheckAvailability(permanent, activateClass))
  25. {
  26. if (permanent.CanSelectBySkill(activateClass))
  27. {
  28. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. if (card.Owner.CanTapWhenAbsorbEvolution(permanent, activateClass))
  39. {
  40. if (permanent.CanSelectBySkill(activateClass))
  41. {
  42. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. if (hashtable != null)
  53. {
  54. if (hashtable.ContainsKey("Card"))
  55. {
  56. if (hashtable["Card"] is CardSource)
  57. {
  58. CardSource Card = (CardSource)hashtable["Card"];
  59. if (Card == card)
  60. {
  61. if (hashtable.ContainsKey("isEvolution"))
  62. {
  63. if (hashtable["isEvolution"] is bool)
  64. {
  65. bool isEvolution = (bool)hashtable["isEvolution"];
  66. if (isEvolution)
  67. {
  68. if (hashtable.ContainsKey("Permanents"))
  69. {
  70. if (hashtable["Permanents"] is List<Permanent>)
  71. {
  72. List<Permanent> Permanents = (List<Permanent>)hashtable["Permanents"];
  73. if (Permanents != null)
  74. {
  75. if (Permanents.Count((permanent) => permanent.TopCard.Owner == card.Owner && permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent)) >= 1)
  76. {
  77. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count(CanSelectCondition_CheckAvailability) >= 1) >= 1)
  78. {
  79. return true;
  80. }
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. return false;
  93. }
  94. bool CanActivateCondition(Hashtable hashtable)
  95. {
  96. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count(CanSelectCondition_CheckAvailability) >= 1) >= 1)
  97. {
  98. return true;
  99. }
  100. return false;
  101. }
  102. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  103. {
  104. #region ?z???i???????????
  105. Hashtable hashtable = new Hashtable();
  106. hashtable.Add("CardEffect", activateClass);
  107. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  108. {
  109. #region ???p?[?}?l???g?????
  110. foreach (Permanent permanent1 in player.GetFieldPermanents())
  111. {
  112. foreach (ICardEffect cardEffect in permanent1.EffectList(EffectTiming.WhenDigisorption))
  113. {
  114. if (cardEffect is ActivateICardEffect)
  115. {
  116. if (cardEffect.CanTrigger(hashtable))
  117. {
  118. GManager.instance.autoProcessing_CutIn.PutStackedSkill(new SkillInfo(cardEffect, hashtable, EffectTiming.WhenDigisorption));
  119. }
  120. }
  121. }
  122. }
  123. #endregion
  124. #region ?v???C???[?????
  125. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.WhenDigisorption))
  126. {
  127. if (cardEffect is ActivateICardEffect)
  128. {
  129. if (cardEffect.CanTrigger(hashtable))
  130. {
  131. GManager.instance.autoProcessing_CutIn.PutStackedSkill(new SkillInfo(cardEffect, hashtable, EffectTiming.WhenDigisorption));
  132. }
  133. }
  134. }
  135. #endregion
  136. }
  137. //??????????????
  138. yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.TriggeredSkillProcess(false, AutoProcessing.HasExecutedSameEffect));
  139. #endregion
  140. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.GetBattleAreaDigimons().Count(CanSelectPermanentCondition) >= 1) >= 1)
  141. {
  142. int maxCount = 1;
  143. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  144. selectPermanentEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: CanSelectPermanentCondition,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: maxCount,
  150. canNoSelect: true,
  151. canEndNotMax: false,
  152. selectPermanentCoroutine: null,
  153. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  154. mode: SelectPermanentEffect.Mode.Tap,
  155. cardEffect: activateClass);
  156. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  157. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  158. {
  159. yield return null;
  160. if (permanents.Count >= 1)
  161. {
  162. if (card.Owner.CanReduceCost(new List<Permanent>() { new Permanent(new List<CardSource>()) }, card))
  163. {
  164. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  165. }
  166. ChangeCostClass changeCostClass = new ChangeCostClass();
  167. changeCostClass.SetUpICardEffect("Digivolution Cost -3", CanUseCondition1, card);
  168. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  169. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  170. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  171. bool CanUseCondition1(Hashtable hashtable)
  172. {
  173. return true;
  174. }
  175. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  176. {
  177. if (CardSourceCondition(cardSource))
  178. {
  179. if (RootCondition(root))
  180. {
  181. if (PermanentsCondition(targetPermanents))
  182. {
  183. Cost -= 3;
  184. }
  185. }
  186. }
  187. return Cost;
  188. }
  189. bool PermanentsCondition(List<Permanent> targetPermanents)
  190. {
  191. if (targetPermanents != null)
  192. {
  193. if (targetPermanents.Count(PermanentCondition) >= 1)
  194. {
  195. return true;
  196. }
  197. }
  198. return false;
  199. }
  200. bool PermanentCondition(Permanent targetPermanent)
  201. {
  202. if (targetPermanent.TopCard != null)
  203. {
  204. if (targetPermanent.TopCard.Owner == card.Owner)
  205. {
  206. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  207. {
  208. return true;
  209. }
  210. }
  211. }
  212. return false;
  213. }
  214. bool CardSourceCondition(CardSource cardSource)
  215. {
  216. if (cardSource != null)
  217. {
  218. if (cardSource == card)
  219. {
  220. return true;
  221. }
  222. }
  223. return false;
  224. }
  225. bool RootCondition(SelectCardEffect.Root root)
  226. {
  227. return true;
  228. }
  229. bool isUpDown()
  230. {
  231. return true;
  232. }
  233. }
  234. }
  235. }
  236. }
  237. }
  238. if (timing == EffectTiming.OnEnterFieldAnyone)
  239. {
  240. ActivateClass activateClass = new ActivateClass();
  241. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  242. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  243. cardEffects.Add(activateClass);
  244. string EffectDiscription()
  245. {
  246. return "[When Digivolving] If you have 2 or more suspended Digimon in play, unsuspend this Digimon.";
  247. }
  248. bool CanUseCondition(Hashtable hashtable)
  249. {
  250. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  251. }
  252. bool CanActivateCondition(Hashtable hashtable)
  253. {
  254. if (CardEffectCommons.IsExistOnBattleArea(card))
  255. {
  256. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  257. {
  258. if (card.Owner.GetBattleAreaDigimons().Count((permanent) => permanent.IsSuspended) >= 2)
  259. {
  260. return true;
  261. }
  262. }
  263. }
  264. return false;
  265. }
  266. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  267. {
  268. Permanent selectedPermanent = card.PermanentOfThisCard();
  269. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  270. }
  271. }
  272. return cardEffects;
  273. }
  274. }
  275. }