BT21_050.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT21
  5. {
  6. public class BT21_050 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternative Digivolution Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return (targetPermanent.TopCard.EqualsTraits("WG") && targetPermanent.TopCard.IsLevel4);
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region On Play
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Suspend", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[On Play] You may suspend 1 Digimon.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  35. }
  36. bool PermanentCondition(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  39. }
  40. bool CanActivateCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  47. {
  48. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  49. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  50. selectPermanentEffect.SetUp(
  51. selectPlayer: card.Owner,
  52. canTargetCondition: PermanentCondition,
  53. canTargetCondition_ByPreSelecetedList: null,
  54. canEndSelectCondition: null,
  55. maxCount: maxCount,
  56. canNoSelect: true,
  57. canEndNotMax: false,
  58. selectPermanentCoroutine: null,
  59. afterSelectPermanentCoroutine: null,
  60. mode: SelectPermanentEffect.Mode.Tap,
  61. cardEffect: activateClass);
  62. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  63. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  64. }
  65. }
  66. }
  67. #endregion
  68. #region When Digivolving
  69. if (timing == EffectTiming.OnEnterFieldAnyone)
  70. {
  71. ActivateClass activateClass = new ActivateClass();
  72. activateClass.SetUpICardEffect("Suspend", CanUseCondition, card);
  73. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  74. cardEffects.Add(activateClass);
  75. string EffectDiscription()
  76. {
  77. return "[When Digivolving] You may suspend 1 Digimon.";
  78. }
  79. bool CanUseCondition(Hashtable hashtable)
  80. {
  81. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  82. }
  83. bool PermanentCondition(Permanent permanent)
  84. {
  85. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  86. }
  87. bool CanActivateCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  90. }
  91. IEnumerator ActivateCoroutine(Hashtable hashtable)
  92. {
  93. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  94. {
  95. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  96. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  97. selectPermanentEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: PermanentCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: true,
  104. canEndNotMax: false,
  105. selectPermanentCoroutine: null,
  106. afterSelectPermanentCoroutine: null,
  107. mode: SelectPermanentEffect.Mode.Tap,
  108. cardEffect: activateClass);
  109. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  110. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  111. }
  112. }
  113. }
  114. #endregion
  115. #region Opponents Turn
  116. if (timing == EffectTiming.OnAllyAttack)
  117. {
  118. ActivateClass activateClass = new ActivateClass();
  119. activateClass.SetUpICardEffect("Switch attack target", CanUseCondition, card);
  120. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  121. activateClass.SetHashString("SwitchTarget_BT21_050");
  122. cardEffects.Add(activateClass);
  123. string EffectDiscription()
  124. {
  125. return "[Opponent's Turn][Once Per Turn] When one of your opponent's Digimon attacks, if this Digimon is suspended, you may change the attack target to 1 of your Digimon with the [WG] trait.";
  126. }
  127. bool CanSelectPermanentCondition(Permanent permanent)
  128. {
  129. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && permanent.TopCard.EqualsTraits("WG");
  130. }
  131. bool PermanentCondition(Permanent permanent)
  132. {
  133. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  134. }
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  138. {
  139. if (CardEffectCommons.IsOpponentTurn(card))
  140. {
  141. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  142. {
  143. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  144. {
  145. return true;
  146. }
  147. }
  148. }
  149. }
  150. return false;
  151. }
  152. bool CanActivateCondition(Hashtable hashtable)
  153. {
  154. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  155. {
  156. if (GManager.instance.attackProcess.IsAttacking)
  157. {
  158. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  159. {
  160. if (card.PermanentOfThisCard().IsSuspended)
  161. {
  162. return true;
  163. }
  164. }
  165. }
  166. }
  167. return false;
  168. }
  169. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  170. {
  171. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(GManager.instance.attackProcess.AttackingPermanent, card))
  172. {
  173. if (GManager.instance.attackProcess.IsAttacking)
  174. {
  175. if (GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget)
  176. {
  177. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  178. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  179. selectPermanentEffect.SetUp(
  180. selectPlayer: card.Owner,
  181. canTargetCondition: CanSelectPermanentCondition,
  182. canTargetCondition_ByPreSelecetedList: null,
  183. canEndSelectCondition: null,
  184. maxCount: maxCount,
  185. canNoSelect: false,
  186. canEndNotMax: false,
  187. selectPermanentCoroutine: SelectPermanentCoroutine,
  188. afterSelectPermanentCoroutine: null,
  189. mode: SelectPermanentEffect.Mode.Custom,
  190. cardEffect: activateClass);
  191. selectPermanentEffect.SetUpCustomMessage(
  192. "Select 1 Digimon to switch the attack to.",
  193. "The opponent is selecting 1 Digimon to switch the attack to.");
  194. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  195. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  196. {
  197. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  198. activateClass,
  199. false,
  200. permanent));
  201. }
  202. }
  203. }
  204. }
  205. }
  206. }
  207. #endregion
  208. #region Inherit
  209. if (timing == EffectTiming.OnEnterFieldAnyone)
  210. {
  211. ActivateClass activateClass = new ActivateClass();
  212. activateClass.SetUpICardEffect("Suspend an opponent's Digimon", CanUseCondition, card);
  213. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  214. activateClass.SetHashString("Suspend_BT21_050");
  215. activateClass.SetIsInheritedEffect(true);
  216. cardEffects.Add(activateClass);
  217. string EffectDescription()
  218. {
  219. return "[All Turns][Once Per Turn] When any of your [WG] trait Digimon are played, you may Suspend 1 of your opponent's Digimon.";
  220. }
  221. bool CanUseCondition(Hashtable hashtable)
  222. {
  223. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PlayerPermanentCondition);
  224. }
  225. bool PlayerPermanentCondition(Permanent permanent)
  226. {
  227. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && permanent.TopCard.EqualsTraits("WG");
  228. }
  229. bool CanSelectPermanentCondition(Permanent permanent)
  230. {
  231. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  232. }
  233. bool CanActivateCondition(Hashtable hashtable)
  234. {
  235. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  236. }
  237. IEnumerator ActivateCoroutine(Hashtable hashtable)
  238. {
  239. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  240. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  241. selectPermanentEffect.SetUp(
  242. selectPlayer: card.Owner,
  243. canTargetCondition: CanSelectPermanentCondition,
  244. canTargetCondition_ByPreSelecetedList: null,
  245. canEndSelectCondition: null,
  246. maxCount: maxCount,
  247. canNoSelect: false,
  248. canEndNotMax: false,
  249. selectPermanentCoroutine: null,
  250. afterSelectPermanentCoroutine: null,
  251. mode: SelectPermanentEffect.Mode.Tap,
  252. cardEffect: activateClass);
  253. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  254. }
  255. }
  256. #endregion
  257. return cardEffects;
  258. }
  259. }
  260. }