EX11_031.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Vespamon
  6. namespace DCGO.CardEffects.EX11
  7. {
  8. public class EX11_031 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel4 &&
  19. targetPermanent.TopCard.EqualsTraits("Royal Base");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  23. card: card, condition: null));
  24. }
  25. #endregion
  26. #region Shared OP / WD
  27. string SharedEffectName()
  28. {
  29. return "Suspend opponent's Digimon and tamers equal to your face-up security count, then 1 can't unsuspend.";
  30. }
  31. string SharedEffectDescription(string tag)
  32. {
  33. return $"[{tag}] For each of your face-up security cards, suspend 1 of your opponent's Digimon or Tamers. Then, 1 of their Digimon or Tamers can't unsuspend until their turn ends.";
  34. }
  35. bool SharedCanActivateCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.IsExistOnBattleArea(card)
  38. && card.Owner.Enemy.GetBattleAreaPermanents().Count(permanent => permanent.IsDigimon || permanent.IsTamer) > 0;
  39. }
  40. bool CanSelectPermanentCondition(Permanent permanent)
  41. {
  42. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  43. && (permanent.IsDigimon
  44. || permanent.IsTamer);
  45. }
  46. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  47. {
  48. #region Suspend
  49. int maxCount = Math.Min(card.Owner.SecurityCards.Count(source => !source.IsFlipped), CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  50. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  51. selectPermanentEffect.SetUp(
  52. selectPlayer: card.Owner,
  53. canTargetCondition: CanSelectPermanentCondition,
  54. canTargetCondition_ByPreSelecetedList: null,
  55. canEndSelectCondition: null,
  56. maxCount: maxCount,
  57. canNoSelect: false,
  58. canEndNotMax: false,
  59. selectPermanentCoroutine: null,
  60. afterSelectPermanentCoroutine: null,
  61. mode: SelectPermanentEffect.Mode.Tap,
  62. cardEffect: activateClass);
  63. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  64. #endregion
  65. #region Stun 1
  66. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  67. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  68. selectPermanentEffect1.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: CanSelectPermanentCondition,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: maxCount1,
  74. canNoSelect: false,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: SelectPermanentCoroutine,
  77. afterSelectPermanentCoroutine: null,
  78. mode: SelectPermanentEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  81. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  82. {
  83. if (permanent != null)
  84. {
  85. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  86. targetPermanent: permanent,
  87. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  88. activateClass: activateClass,
  89. condition: null,
  90. effectName: "Can't Unsuspend"));
  91. }
  92. }
  93. #endregion
  94. }
  95. #endregion
  96. #region On Play
  97. if (timing == EffectTiming.OnEnterFieldAnyone)
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  101. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  102. cardEffects.Add(activateClass);
  103. bool CanUseCondition(Hashtable hashtable)
  104. {
  105. return CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  106. && CardEffectCommons.IsExistOnBattleArea(card);
  107. }
  108. }
  109. #endregion
  110. #region When Digivolving
  111. if (timing == EffectTiming.OnEnterFieldAnyone)
  112. {
  113. ActivateClass activateClass = new ActivateClass();
  114. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  115. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  116. cardEffects.Add(activateClass);
  117. bool CanUseCondition(Hashtable hashtable)
  118. {
  119. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  120. && CardEffectCommons.IsExistOnBattleArea(card);
  121. }
  122. }
  123. #endregion
  124. #region All Turns - ESS - OPT
  125. if (timing == EffectTiming.WhenRemoveField)
  126. {
  127. List<Permanent> removedPermanents = new List<Permanent>();
  128. ActivateClass activateClass = new ActivateClass();
  129. activateClass.SetUpICardEffect("By flipping your top face up security card face down, prevent remove from field", CanUseCondition, card);
  130. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  131. activateClass.SetHashString("EX11_031_ESS_AT");
  132. activateClass.SetIsInheritedEffect(true);
  133. cardEffects.Add(activateClass);
  134. string EffectDescription()
  135. {
  136. return "[All Turns] [Once Per Turn] When any of your [Royal Base] trait Digimon would leave the battle area other than by your effects, by flipping your top face-up security card face down, 1 of those Digimon doesn't leave.";
  137. }
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  141. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, CanSelectPermanentCondition1)
  142. && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  143. }
  144. bool CanActivateCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  147. && card.Owner.SecurityCards.Count(source => !source.IsFlipped) > 0;
  148. }
  149. bool CanSelectPermanentCondition1(Permanent permanent)
  150. {
  151. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  152. && permanent.TopCard.HasRoyalBaseTraits;
  153. }
  154. bool CanSelectPermament(Permanent permanent)
  155. {
  156. return removedPermanents.Contains(permanent);
  157. }
  158. IEnumerator ActivateCoroutine(Hashtable hashtable)
  159. {
  160. removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(CanSelectPermanentCondition1);
  161. var flippedSecurity = false;
  162. foreach (CardSource source in card.Owner.SecurityCards)
  163. {
  164. if (source.IsFlipped) continue;
  165. source.SetReverse();
  166. GManager.OnSecurityStackChanged?.Invoke(card.Owner.Enemy);
  167. flippedSecurity = true;
  168. break;
  169. }
  170. if (flippedSecurity)
  171. {
  172. Permanent selectedPermanent = null;
  173. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  174. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermament));
  175. selectPermanentEffect.SetUp(
  176. selectPlayer: card.Owner,
  177. canTargetCondition: CanSelectPermament,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. maxCount: maxCount,
  181. canNoSelect: false,
  182. canEndNotMax: false,
  183. selectPermanentCoroutine: SelectPermanentCoroutine,
  184. afterSelectPermanentCoroutine: null,
  185. mode: SelectPermanentEffect.Mode.Custom,
  186. cardEffect: activateClass);
  187. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  188. {
  189. selectedPermanent = permanent;
  190. yield return null;
  191. }
  192. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to prevent removal.", "The opponent is selecting 1 Digimon to prevent removal.");
  193. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  194. if (selectedPermanent != null)
  195. {
  196. selectedPermanent.HideDeleteEffect();
  197. selectedPermanent.HideHandBounceEffect();
  198. selectedPermanent.HideDeckBounceEffect();
  199. selectedPermanent.HideWillRemoveFieldEffect();
  200. selectedPermanent.DestroyingEffect = null;
  201. selectedPermanent.IsDestroyedByBattle = false;
  202. selectedPermanent.HandBounceEffect = null;
  203. selectedPermanent.LibraryBounceEffect = null;
  204. selectedPermanent.willBeRemoveField = false;
  205. }
  206. }
  207. yield return null;
  208. }
  209. }
  210. #endregion
  211. #region All Turns - Security
  212. if (timing == EffectTiming.None)
  213. {
  214. bool CanUseCondition()
  215. {
  216. return CardEffectCommons.IsExistInSecurity(card, false)
  217. && CardEffectCommons.IsOpponentTurn(card);
  218. }
  219. bool PermanentCondition(Permanent permanent)
  220. {
  221. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  222. && permanent.TopCard.EqualsTraits("Royal Base");
  223. }
  224. cardEffects.Add(CardEffectFactory.BlockerStaticEffect(
  225. permanentCondition: PermanentCondition,
  226. isInheritedEffect: false,
  227. card: card,
  228. condition: CanUseCondition));
  229. }
  230. #endregion
  231. return cardEffects;
  232. }
  233. }
  234. }