BT2_047.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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 BT2_047 : 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.OnAllyAttack)
  240. {
  241. ActivateClass activateClass = new ActivateClass();
  242. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  243. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  244. activateClass.SetIsInheritedEffect(true);
  245. cardEffects.Add(activateClass);
  246. string EffectDiscription()
  247. {
  248. return "[When Attacking] You may play 1 level 3 green Digimon card from your hand suspended without paying its memory cost.";
  249. }
  250. bool CanSelectCardCondition(CardSource cardSource)
  251. {
  252. if (cardSource != null)
  253. {
  254. if (cardSource.IsDigimon)
  255. {
  256. if (cardSource.Owner == card.Owner)
  257. {
  258. if (cardSource.HasCardColor(CardColor.Green))
  259. {
  260. if (cardSource.Level == 3)
  261. {
  262. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  263. {
  264. if (cardSource.HasLevel)
  265. {
  266. return true;
  267. }
  268. }
  269. }
  270. }
  271. }
  272. }
  273. }
  274. return false;
  275. }
  276. bool CanUseCondition(Hashtable hashtable)
  277. {
  278. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  279. }
  280. bool CanActivateCondition(Hashtable hashtable)
  281. {
  282. if (CardEffectCommons.IsExistOnBattleArea(card))
  283. {
  284. if (card.Owner.HandCards.Count >= 1)
  285. {
  286. return true;
  287. }
  288. }
  289. return false;
  290. }
  291. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  292. {
  293. if (isExistOnField(card))
  294. {
  295. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  296. {
  297. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  298. {
  299. List<CardSource> selectedCards = new List<CardSource>();
  300. int maxCount = 1;
  301. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  302. selectHandEffect.SetUp(
  303. selectPlayer: card.Owner,
  304. canTargetCondition: CanSelectCardCondition,
  305. canTargetCondition_ByPreSelecetedList: null,
  306. canEndSelectCondition: null,
  307. maxCount: maxCount,
  308. canNoSelect: true,
  309. canEndNotMax: false,
  310. isShowOpponent: true,
  311. selectCardCoroutine: SelectCardCoroutine,
  312. afterSelectCardCoroutine: null,
  313. mode: SelectHandEffect.Mode.Custom,
  314. cardEffect: activateClass);
  315. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  316. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  317. yield return StartCoroutine(selectHandEffect.Activate());
  318. IEnumerator SelectCardCoroutine(CardSource cardSource)
  319. {
  320. selectedCards.Add(cardSource);
  321. yield return null;
  322. }
  323. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: true, root: SelectCardEffect.Root.Hand, activateETB: true));
  324. }
  325. }
  326. }
  327. }
  328. }
  329. return cardEffects;
  330. }
  331. }