EX5_034.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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 EX5_034 : 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.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.ContainsCardName("Leomon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.None)
  22. {
  23. ChangeCostClass changeCostClass = new ChangeCostClass();
  24. changeCostClass.SetUpICardEffect($"Play Cost -5", CanUseCondition, card);
  25. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  26. cardEffects.Add(changeCostClass);
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. if (card.Owner.HandCards.Contains(card))
  30. {
  31. if (card.Owner.SecurityCards.Count + card.Owner.Enemy.SecurityCards.Count <= 6)
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  39. {
  40. if (CardSourceCondition(cardSource))
  41. {
  42. if (RootCondition(root))
  43. {
  44. if (PermanentsCondition(targetPermanents))
  45. {
  46. Cost -= 5;
  47. }
  48. }
  49. }
  50. return Cost;
  51. }
  52. bool PermanentsCondition(List<Permanent> targetPermanents)
  53. {
  54. if (targetPermanents == null)
  55. {
  56. return true;
  57. }
  58. else
  59. {
  60. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. bool CardSourceCondition(CardSource cardSource)
  68. {
  69. return cardSource == card;
  70. }
  71. bool RootCondition(SelectCardEffect.Root root)
  72. {
  73. if (root == SelectCardEffect.Root.Hand)
  74. {
  75. return true;
  76. }
  77. return false;
  78. }
  79. bool isUpDown()
  80. {
  81. return true;
  82. }
  83. }
  84. if (timing == EffectTiming.OnEnterFieldAnyone)
  85. {
  86. ActivateClass activateClass = new ActivateClass();
  87. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  88. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  89. cardEffects.Add(activateClass);
  90. string EffectDiscription()
  91. {
  92. return "[On Play] Suspend 1 of your opponent's Digimon.";
  93. }
  94. bool CanSelectPermanentCondition(Permanent permanent)
  95. {
  96. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  101. }
  102. bool CanActivateCondition(Hashtable hashtable)
  103. {
  104. if (CardEffectCommons.IsExistOnBattleArea(card))
  105. {
  106. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  107. {
  108. return true;
  109. }
  110. }
  111. return false;
  112. }
  113. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  114. {
  115. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  116. {
  117. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  118. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  119. selectPermanentEffect.SetUp(
  120. selectPlayer: card.Owner,
  121. canTargetCondition: CanSelectPermanentCondition,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. maxCount: maxCount,
  125. canNoSelect: false,
  126. canEndNotMax: false,
  127. selectPermanentCoroutine: null,
  128. afterSelectPermanentCoroutine: null,
  129. mode: SelectPermanentEffect.Mode.Tap,
  130. cardEffect: activateClass);
  131. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  132. }
  133. }
  134. }
  135. if (timing == EffectTiming.OnEnterFieldAnyone)
  136. {
  137. ActivateClass activateClass = new ActivateClass();
  138. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  139. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  140. cardEffects.Add(activateClass);
  141. string EffectDiscription()
  142. {
  143. return "[When Digivolving] Suspend 1 of your opponent's Digimon.";
  144. }
  145. bool CanSelectPermanentCondition(Permanent permanent)
  146. {
  147. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  148. }
  149. bool CanUseCondition(Hashtable hashtable)
  150. {
  151. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  152. }
  153. bool CanActivateCondition(Hashtable hashtable)
  154. {
  155. if (CardEffectCommons.IsExistOnBattleArea(card))
  156. {
  157. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  158. {
  159. return true;
  160. }
  161. }
  162. return false;
  163. }
  164. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  165. {
  166. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  167. {
  168. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  169. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  170. selectPermanentEffect.SetUp(
  171. selectPlayer: card.Owner,
  172. canTargetCondition: CanSelectPermanentCondition,
  173. canTargetCondition_ByPreSelecetedList: null,
  174. canEndSelectCondition: null,
  175. maxCount: maxCount,
  176. canNoSelect: false,
  177. canEndNotMax: false,
  178. selectPermanentCoroutine: null,
  179. afterSelectPermanentCoroutine: null,
  180. mode: SelectPermanentEffect.Mode.Tap,
  181. cardEffect: activateClass);
  182. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  183. }
  184. }
  185. }
  186. if (timing == EffectTiming.OnTappedAnyone)
  187. {
  188. ActivateClass activateClass = new ActivateClass();
  189. activateClass.SetUpICardEffect("Opponent's 1 Digimon gains DP -4000 and Security Attack -1", CanUseCondition, card);
  190. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  191. activateClass.SetHashString("DP-4000_EX5_034");
  192. cardEffects.Add(activateClass);
  193. string EffectDiscription()
  194. {
  195. return "[All Turns] [Once Per Turn] When a Digimon becomes suspended, you may have 1 of your opponent's Digimon get -4000 DP and gain <Security Attack -1> (This Digimon checks 1 fewer security card) until the end of their turn.";
  196. }
  197. bool PermanentCondition(Permanent permanent)
  198. {
  199. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  200. {
  201. if (permanent.IsDigimon)
  202. {
  203. return true;
  204. }
  205. }
  206. return false;
  207. }
  208. bool CanSelectPermanentCondition(Permanent permanent)
  209. {
  210. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  211. }
  212. bool CanUseCondition(Hashtable hashtable)
  213. {
  214. if (CardEffectCommons.IsExistOnBattleArea(card))
  215. {
  216. if (CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, PermanentCondition))
  217. {
  218. return true;
  219. }
  220. }
  221. return false;
  222. }
  223. bool CanActivateCondition(Hashtable hashtable)
  224. {
  225. if (CardEffectCommons.IsExistOnBattleArea(card))
  226. {
  227. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  228. {
  229. return true;
  230. }
  231. }
  232. return false;
  233. }
  234. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  235. {
  236. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  237. {
  238. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  239. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  240. selectPermanentEffect.SetUp(
  241. selectPlayer: card.Owner,
  242. canTargetCondition: CanSelectPermanentCondition,
  243. canTargetCondition_ByPreSelecetedList: null,
  244. canEndSelectCondition: null,
  245. maxCount: maxCount,
  246. canNoSelect: false,
  247. canEndNotMax: false,
  248. selectPermanentCoroutine: SelectPermanentCoroutine,
  249. afterSelectPermanentCoroutine: null,
  250. mode: SelectPermanentEffect.Mode.Custom,
  251. cardEffect: activateClass);
  252. selectPermanentEffect.SetUpCustomMessage(
  253. "Select 1 Digimon that will gain DP -4000 and Security Attack -1.",
  254. "The opponent is selecting 1 Digimon that will gain DP -4000 and Security Attack -1.");
  255. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  256. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  257. {
  258. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  259. targetPermanent: permanent,
  260. changeValue: -4000,
  261. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  262. activateClass: activateClass));
  263. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  264. targetPermanent: permanent,
  265. changeValue: -1,
  266. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  267. activateClass: activateClass));
  268. }
  269. }
  270. }
  271. }
  272. return cardEffects;
  273. }
  274. }