BT15_058.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT15
  6. {
  7. public class BT15_058 : 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.None)
  13. {
  14. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  15. }
  16. if (timing == EffectTiming.None)
  17. {
  18. static bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. if (targetPermanent.TopCard.CardTraits.Contains("DigiPolice") || targetPermanent.TopCard.HasXAntibodyTraits)
  21. {
  22. if (targetPermanent.TopCard.HasLevel)
  23. {
  24. if (targetPermanent.Level == 3)
  25. {
  26. return true;
  27. }
  28. }
  29. }
  30. return false;
  31. }
  32. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  33. }
  34. //Inherited effect
  35. if (timing == EffectTiming.OnTappedAnyone)
  36. {
  37. ActivateClass activateClass = new ActivateClass();
  38. activateClass.SetUpICardEffect("Suspend opponent's Digimon or Tamers with play cost less than this Digimon.", CanUseCondition, card);
  39. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  40. activateClass.SetIsInheritedEffect(true);
  41. activateClass.SetHashString("suspend_BT15_058_inherited");
  42. cardEffects.Add(activateClass);
  43. string EffectDiscription()
  44. {
  45. return "[All Turns] [Once Per Turn] When this Digimon becomes suspended, suspend 1 of your opponent's Digimon or Tamers with a play cost less than or equal to this Digimon's play cost.";
  46. }
  47. bool CanSelectPermanentCondition(Permanent permanent)
  48. {
  49. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  50. {
  51. if (permanent.IsDigimon || permanent.IsTamer)
  52. {
  53. if (permanent.TopCard.GetCostItself <= card.PermanentOfThisCard().TopCard.GetCostItself)
  54. {
  55. return true;
  56. }
  57. }
  58. }
  59. return false;
  60. }
  61. bool CanActivateCondition(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.IsExistOnBattleArea(card))
  64. {
  65. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  66. {
  67. return true;
  68. }
  69. }
  70. return false;
  71. }
  72. bool CanUseCondition(Hashtable hashtable)
  73. {
  74. if (CardEffectCommons.IsExistOnBattleArea(card))
  75. {
  76. if (CardEffectCommons.CanTriggerWhenSelfPermanentSuspends(hashtable, card))
  77. {
  78. return true;
  79. }
  80. }
  81. return false;
  82. }
  83. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  84. {
  85. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  86. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  87. selectPermanentEffect.SetUp(
  88. selectPlayer: card.Owner,
  89. canTargetCondition: CanSelectPermanentCondition,
  90. canTargetCondition_ByPreSelecetedList: null,
  91. canEndSelectCondition: null,
  92. maxCount: maxCount,
  93. canNoSelect: false,
  94. canEndNotMax: false,
  95. selectPermanentCoroutine: null,
  96. afterSelectPermanentCoroutine: null,
  97. mode: SelectPermanentEffect.Mode.Tap,
  98. cardEffect: activateClass);
  99. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  100. }
  101. }
  102. //On Play
  103. if (timing == EffectTiming.OnEnterFieldAnyone)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect("Suspend 1 of your opponent's Digimon.", CanUseCondition, card);
  107. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  108. cardEffects.Add(activateClass);
  109. string EffectDiscription()
  110. {
  111. return "[On Play] Suspend 1 of your opponent's Digimon. If a Tamer card with the [Digipolice] trait is in this Digimon's digivolution cards, that Digimon can't unsuspend until the end of their turn.";
  112. }
  113. bool CanSelectPermanentCondition(Permanent permanent)
  114. {
  115. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  116. }
  117. //Check if digipolice tamer is in sources
  118. bool CanSelectPermanentCondition1(Permanent permanent)
  119. {
  120. if (CardEffectCommons.IsExistOnBattleArea(card))
  121. {
  122. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => (cardSource.CardTraits.Contains("DigiPolice") && cardSource.IsTamer)) >= 1)
  123. {
  124. return true;
  125. }
  126. }
  127. /*
  128. if (permanent.DigivolutionCards.Count((cardSource) => (cardSource.CardTraits.Contains("DigiPolice") && cardSource.IsTamer)) >= 1)
  129. {
  130. return true;
  131. }
  132. */
  133. return false;
  134. }
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  138. }
  139. bool CanActivateCondition(Hashtable hashtable)
  140. {
  141. if (CardEffectCommons.IsExistOnBattleArea(card))
  142. {
  143. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  144. {
  145. return true;
  146. }
  147. }
  148. return false;
  149. }
  150. //Activate effect
  151. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  152. {
  153. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  154. {
  155. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  156. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  157. selectPermanentEffect.SetUp(
  158. selectPlayer: card.Owner,
  159. canTargetCondition: CanSelectPermanentCondition,
  160. canTargetCondition_ByPreSelecetedList: null,
  161. canEndSelectCondition: null,
  162. maxCount: maxCount,
  163. canNoSelect: false,
  164. canEndNotMax: false,
  165. selectPermanentCoroutine: null,
  166. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  167. mode: SelectPermanentEffect.Mode.Tap,
  168. cardEffect: activateClass);
  169. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  170. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  171. {
  172. foreach (Permanent selectedPermanent in permanents)
  173. {
  174. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  175. {
  176. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  177. targetPermanent: selectedPermanent,
  178. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  179. activateClass: activateClass,
  180. condition: null,
  181. effectName: "Can't unsuspend"
  182. ));
  183. }
  184. }
  185. yield return null;
  186. }
  187. }
  188. }
  189. }
  190. //When Digivolving
  191. if (timing == EffectTiming.OnEnterFieldAnyone)
  192. {
  193. ActivateClass activateClass = new ActivateClass();
  194. activateClass.SetUpICardEffect("Suspend 1 of your opponent's Digimon.", CanUseCondition, card);
  195. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  196. cardEffects.Add(activateClass);
  197. string EffectDiscription()
  198. {
  199. return "[When Digivolving] Suspend 1 of your opponent's Digimon. If a Tamer card with the [Digipolice] trait is in this Digimon's digivolution cards, that Digimon can't unsuspend until the end of their turn.";
  200. }
  201. bool CanSelectPermanentCondition(Permanent permanent)
  202. {
  203. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  204. }
  205. //Check if digipolice tamer is in sources
  206. bool CanSelectPermanentCondition1(Permanent permanent)
  207. {
  208. if (permanent.DigivolutionCards.Count((cardSource) => (cardSource.CardTraits.Contains("DigiPolice") && cardSource.IsTamer)) >= 1)
  209. {
  210. return true;
  211. }
  212. return false;
  213. }
  214. bool CanUseCondition(Hashtable hashtable)
  215. {
  216. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  217. }
  218. bool CanActivateCondition(Hashtable hashtable)
  219. {
  220. if (CardEffectCommons.IsExistOnBattleArea(card))
  221. {
  222. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  223. {
  224. return true;
  225. }
  226. }
  227. return false;
  228. }
  229. //Activate effect
  230. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  231. {
  232. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  233. {
  234. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  235. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  236. selectPermanentEffect.SetUp(
  237. selectPlayer: card.Owner,
  238. canTargetCondition: CanSelectPermanentCondition,
  239. canTargetCondition_ByPreSelecetedList: null,
  240. canEndSelectCondition: null,
  241. maxCount: maxCount,
  242. canNoSelect: false,
  243. canEndNotMax: false,
  244. selectPermanentCoroutine: null,
  245. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  246. mode: SelectPermanentEffect.Mode.Tap,
  247. cardEffect: activateClass);
  248. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  249. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  250. {
  251. foreach (Permanent selectedPermanent in permanents)
  252. {
  253. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  254. {
  255. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  256. targetPermanent: selectedPermanent,
  257. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  258. activateClass: activateClass,
  259. condition: null,
  260. effectName: "Can't unsuspend"
  261. ));
  262. }
  263. }
  264. yield return null;
  265. }
  266. }
  267. }
  268. }
  269. return cardEffects;
  270. }
  271. }
  272. }