EX3_040.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX3
  6. {
  7. public class EX3_040 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.BeforePayCost)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Play Cost -1", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. activateClass.SetHashString("Playcost-1_EX3_040");
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Your Turn] When you would play a green Digimon card, by suspending this Digimon, reduce the cost by 1.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. if (CardEffectCommons.IsExistOnBattleArea(card))
  26. {
  27. if (CardEffectCommons.IsOwnerTurn(card))
  28. {
  29. if (hashtable != null)
  30. {
  31. if (hashtable.ContainsKey("Card"))
  32. {
  33. if (hashtable["Card"] is CardSource)
  34. {
  35. CardSource Card = (CardSource)hashtable["Card"];
  36. if (Card != null)
  37. {
  38. if (Card.IsDigimon)
  39. {
  40. if (Card.HasCardColor(CardColor.Green))
  41. {
  42. if (Card.Owner == card.Owner)
  43. {
  44. if (hashtable.ContainsKey("isEvolution"))
  45. {
  46. if (hashtable["isEvolution"] is bool)
  47. {
  48. bool isEvolution = (bool)hashtable["isEvolution"];
  49. if (!isEvolution)
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. }
  63. }
  64. return false;
  65. }
  66. bool CanActivateCondition(Hashtable hashtable)
  67. {
  68. if (CardEffectCommons.IsExistOnBattleArea(card))
  69. {
  70. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  71. {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  78. {
  79. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  80. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  81. ChangeCostClass changeCostClass = new ChangeCostClass();
  82. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition1, card);
  83. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  84. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  85. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  86. bool CanUseCondition1(Hashtable hashtable)
  87. {
  88. return true;
  89. }
  90. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  91. {
  92. if (CardSourceCondition(cardSource))
  93. {
  94. if (RootCondition(root))
  95. {
  96. if (PermanentsCondition(targetPermanents))
  97. {
  98. Cost -= 1;
  99. }
  100. }
  101. }
  102. return Cost;
  103. }
  104. bool PermanentsCondition(List<Permanent> targetPermanents)
  105. {
  106. if (targetPermanents == null)
  107. {
  108. return true;
  109. }
  110. else
  111. {
  112. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  113. {
  114. return true;
  115. }
  116. }
  117. return false;
  118. }
  119. bool CardSourceCondition(CardSource cardSource)
  120. {
  121. return cardSource.HasCardColor(CardColor.Green);
  122. }
  123. bool RootCondition(SelectCardEffect.Root root)
  124. {
  125. return true;
  126. }
  127. bool isUpDown()
  128. {
  129. return true;
  130. }
  131. }
  132. }
  133. if (timing == EffectTiming.None)
  134. {
  135. ChangeCostClass changeCostClass = new ChangeCostClass();
  136. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition, card);
  137. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  138. changeCostClass.SetNotShowUI(true);
  139. cardEffects.Add(changeCostClass);
  140. bool CanUseCondition(Hashtable hashtable)
  141. {
  142. if (!card.Owner.isYou && GManager.instance.IsAI)
  143. {
  144. return false;
  145. }
  146. if (CardEffectCommons.IsExistOnBattleArea(card))
  147. {
  148. if (CardEffectCommons.IsOwnerTurn(card))
  149. {
  150. if (!card.PermanentOfThisCard().IsSuspended && card.PermanentOfThisCard().CanSuspend)
  151. {
  152. return true;
  153. }
  154. }
  155. }
  156. return false;
  157. }
  158. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  159. {
  160. if (CardSourceCondition(cardSource))
  161. {
  162. if (RootCondition(root))
  163. {
  164. if (PermanentsCondition(targetPermanents))
  165. {
  166. Cost -= 1;
  167. }
  168. }
  169. }
  170. return Cost;
  171. }
  172. bool PermanentsCondition(List<Permanent> targetPermanents)
  173. {
  174. if (targetPermanents == null)
  175. {
  176. return true;
  177. }
  178. else
  179. {
  180. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  181. {
  182. return true;
  183. }
  184. }
  185. return false;
  186. }
  187. bool CardSourceCondition(CardSource cardSource)
  188. {
  189. if (cardSource.Owner == card.Owner)
  190. {
  191. if (cardSource.IsDigimon)
  192. {
  193. if (cardSource.HasCardColor(CardColor.Green))
  194. {
  195. return true;
  196. }
  197. }
  198. }
  199. return false;
  200. }
  201. bool RootCondition(SelectCardEffect.Root root)
  202. {
  203. return true;
  204. }
  205. bool isUpDown()
  206. {
  207. return true;
  208. }
  209. }
  210. if (timing == EffectTiming.OnTappedAnyone)
  211. {
  212. ActivateClass activateClass = new ActivateClass();
  213. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  214. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  215. activateClass.SetIsInheritedEffect(true);
  216. activateClass.SetHashString("Suspend_EX3_040");
  217. cardEffects.Add(activateClass);
  218. string EffectDiscription()
  219. {
  220. return "[Your Turn][Once Per Turn] When an effect suspends one of your Digimon, suspend 1 of your opponent's Digimon.";
  221. }
  222. bool PermanentCondition(Permanent permanent)
  223. {
  224. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  225. }
  226. bool CanSelectPermanentCondition(Permanent permanent)
  227. {
  228. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  229. }
  230. bool CanUseCondition(Hashtable hashtable)
  231. {
  232. if (CardEffectCommons.IsExistOnBattleArea(card))
  233. {
  234. if (CardEffectCommons.IsOwnerTurn(card))
  235. {
  236. if (CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, PermanentCondition))
  237. {
  238. if (CardEffectCommons.IsByEffect(hashtable, null))
  239. {
  240. return true;
  241. }
  242. }
  243. }
  244. }
  245. return false;
  246. }
  247. bool CanActivateCondition(Hashtable hashtable)
  248. {
  249. if (CardEffectCommons.IsExistOnBattleArea(card))
  250. {
  251. return true;
  252. }
  253. return false;
  254. }
  255. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  256. {
  257. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  258. {
  259. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  260. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  261. selectPermanentEffect.SetUp(
  262. selectPlayer: card.Owner,
  263. canTargetCondition: CanSelectPermanentCondition,
  264. canTargetCondition_ByPreSelecetedList: null,
  265. canEndSelectCondition: null,
  266. maxCount: maxCount,
  267. canNoSelect: false,
  268. canEndNotMax: false,
  269. selectPermanentCoroutine: null,
  270. afterSelectPermanentCoroutine: null,
  271. mode: SelectPermanentEffect.Mode.Tap,
  272. cardEffect: activateClass);
  273. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  274. }
  275. }
  276. }
  277. return cardEffects;
  278. }
  279. }
  280. }