AD1_014.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // MetalGarurumon
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_014 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Blocker and Evade
  14. if (timing == EffectTiming.None)
  15. {
  16. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  17. }
  18. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  19. {
  20. cardEffects.Add(CardEffectFactory.EvadeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Alternative Digivolution Condition
  24. if (timing == EffectTiming.None)
  25. {
  26. bool PermanentCondition(Permanent targetPermanent)
  27. {
  28. return targetPermanent.TopCard.ContainsCardName("Garurumon")
  29. || targetPermanent.TopCard.EqualsTraits("ADVENTURE")
  30. || targetPermanent.TopCard.EqualsTraits("HERO");
  31. }
  32. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  33. level: 5,
  34. permanentCondition: PermanentCondition,
  35. digivolutionCost: 3,
  36. ignoreDigivolutionRequirement: false,
  37. card: card,
  38. condition: null)
  39. );
  40. }
  41. #endregion
  42. #region Shared OP / WD / WA
  43. string SharedHashString = "AD1_014_OP_WD_WA";
  44. string SharedEffectName = "Delete 1 of your Opponent's level 5 or lower digimon. For every 2 colors on your tamers, 1 opponent's Digimon or Tamers can't suspend";
  45. string SharedEffectDescription(string tag)
  46. => $"[{tag}] [Once Per Turn] Delete 1 of your opponent's level 5 or lower Digimon. Then, for every 2 of your Tamers' colors, 1 of your opponent's Digimon or Tamers can't suspend until their turn ends.";
  47. bool IsEnemyDigimonOrTamer(Permanent permanent)
  48. {
  49. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  50. && permanent.TopCard.IsPermanent;
  51. }
  52. bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  53. bool IsLevel5OrLowerDigimon(Permanent permanent)
  54. {
  55. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  56. && permanent.TopCard.HasLevel
  57. && permanent.Level <= 5;
  58. }
  59. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  60. {
  61. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsLevel5OrLowerDigimon))
  62. {
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: IsLevel5OrLowerDigimon,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: 1,
  70. canNoSelect: false,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: null,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Destroy,
  75. cardEffect: activateClass);
  76. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  77. }
  78. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsEnemyDigimonOrTamer))
  79. {
  80. List<CardSource> tamerCards = new List<CardSource>();
  81. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  82. {
  83. if (permanent.IsTamer)
  84. {
  85. tamerCards.Add(permanent.TopCard);
  86. }
  87. }
  88. int suspendCount = Combinations.GetDifferenetColorCardCount(tamerCards) / 2;
  89. if (suspendCount > 0)
  90. {
  91. int maxCount = Math.Min(suspendCount, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsEnemyDigimonOrTamer));
  92. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  93. selectPermanentEffect.SetUp(
  94. selectPlayer: card.Owner,
  95. canTargetCondition: IsEnemyDigimonOrTamer,
  96. canTargetCondition_ByPreSelecetedList: null,
  97. canEndSelectCondition: null,
  98. maxCount: maxCount,
  99. canNoSelect: false,
  100. canEndNotMax: false,
  101. selectPermanentCoroutine: SelectPermanentCoroutine,
  102. afterSelectPermanentCoroutine: null,
  103. mode: SelectPermanentEffect.Mode.Custom,
  104. cardEffect: activateClass);
  105. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or Tamer that will get unable to suspend.", "The opponent is selecting 1 Digimon or Tamer that will get unable to suspend.");
  106. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  107. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  108. {
  109. Permanent selectedPermanent = permanent;
  110. if (selectedPermanent != null)
  111. {
  112. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  113. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCondition1, card);
  114. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCondition);
  115. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotSuspendClass);
  116. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  117. {
  118. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  119. }
  120. bool CanUseCondition1(Hashtable hashtable)
  121. {
  122. return selectedPermanent.TopCard != null
  123. && !selectedPermanent.TopCard.CanNotBeAffected(activateClass);
  124. }
  125. bool PermanentCondition(Permanent permanent)
  126. {
  127. return permanent == selectedPermanent;
  128. }
  129. }
  130. }
  131. }
  132. }
  133. }
  134. #endregion
  135. #region On Play
  136. if (timing == EffectTiming.OnEnterFieldAnyone)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  140. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("On Play"));
  141. activateClass.SetHashString(SharedHashString);
  142. cardEffects.Add(activateClass);
  143. bool CanUseCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.IsExistOnBattleArea(card)
  146. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  147. }
  148. }
  149. #endregion
  150. #region When Digivolving
  151. if (timing == EffectTiming.OnEnterFieldAnyone)
  152. {
  153. ActivateClass activateClass = new ActivateClass();
  154. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  155. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Digivolving"));
  156. activateClass.SetHashString(SharedHashString);
  157. cardEffects.Add(activateClass);
  158. bool CanUseCondition(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.IsExistOnBattleArea(card)
  161. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  162. }
  163. }
  164. #endregion
  165. #region When Attacking
  166. if (timing == EffectTiming.OnAllyAttack)
  167. {
  168. ActivateClass activateClass = new ActivateClass();
  169. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  170. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Attacking"));
  171. activateClass.SetHashString(SharedHashString);
  172. cardEffects.Add(activateClass);
  173. bool CanUseCondition(Hashtable hashtable)
  174. {
  175. return CardEffectCommons.IsExistOnBattleArea(card)
  176. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  177. }
  178. }
  179. #endregion
  180. #region All Turns
  181. if (timing == EffectTiming.OnTappedAnyone)
  182. {
  183. ActivateClass activateClass = new ActivateClass();
  184. activateClass.SetUpICardEffect("Unsuspend this digimon", CanUseCondition, card);
  185. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  186. activateClass.SetHashString("AD1_014_AT");
  187. cardEffects.Add(activateClass);
  188. string EffectDescription() => "[All Turns] [Once Per Turn] When any of your Digimon suspend, this Digimon may unsuspend.";
  189. bool CanUseCondition(Hashtable hashtable)
  190. {
  191. return CardEffectCommons.IsExistOnBattleArea(card)
  192. && CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, PermanentCondition);
  193. }
  194. bool PermanentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  195. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  196. IEnumerator ActivateCoroutine(Hashtable hashtable)
  197. {
  198. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  199. permanents: new List<Permanent>() { card.PermanentOfThisCard() },
  200. cardEffect: activateClass).Unsuspend());
  201. }
  202. }
  203. #endregion
  204. #region ESS
  205. if (timing == EffectTiming.OnAllyAttack)
  206. {
  207. ActivateClass activateClass = new ActivateClass();
  208. activateClass.SetUpICardEffect("1 opponent's Digimon or Tamers cannot suspend", CanUseCondition, card);
  209. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  210. activateClass.SetHashString("AD1_014_ESS_WA");
  211. activateClass.SetIsInheritedEffect(true);
  212. cardEffects.Add(activateClass);
  213. string EffectDescription()
  214. => "[When Attacking] [Once Per Turn] If this Digimon has [Garurumon] or [Omnimon] in its name, 1 of your opponent's Digimon or Tamers can't suspend until their turn ends.";
  215. bool CanUseCondition(Hashtable hashtable)
  216. {
  217. return CardEffectCommons.IsExistOnBattleArea(card)
  218. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  219. }
  220. bool CanActivateCondition(Hashtable hashtable)
  221. {
  222. return CardEffectCommons.IsExistOnBattleArea(card)
  223. && (card.PermanentOfThisCard().TopCard.ContainsCardName("Garurumon")
  224. || card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon"));
  225. }
  226. IEnumerator ActivateCoroutine(Hashtable hashtable)
  227. {
  228. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsEnemyDigimonOrTamer))
  229. {
  230. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  231. selectPermanentEffect.SetUp(
  232. selectPlayer: card.Owner,
  233. canTargetCondition: IsEnemyDigimonOrTamer,
  234. canTargetCondition_ByPreSelecetedList: null,
  235. canEndSelectCondition: null,
  236. maxCount: 1,
  237. canNoSelect: false,
  238. canEndNotMax: false,
  239. selectPermanentCoroutine: SelectPermanentCoroutine,
  240. afterSelectPermanentCoroutine: null,
  241. mode: SelectPermanentEffect.Mode.Custom,
  242. cardEffect: activateClass);
  243. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or Tamer that will get unable to suspend.", "The opponent is selecting 1 Digimon or Tamer that will get unable to suspend.");
  244. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  245. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  246. {
  247. Permanent selectedPermanent = permanent;
  248. if (selectedPermanent != null)
  249. {
  250. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  251. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCondition1, card);
  252. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCondition);
  253. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotSuspendClass);
  254. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  255. {
  256. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  257. }
  258. bool CanUseCondition1(Hashtable hashtable)
  259. {
  260. return selectedPermanent.TopCard != null
  261. && !selectedPermanent.TopCard.CanNotBeAffected(activateClass);
  262. }
  263. bool PermanentCondition(Permanent permanent)
  264. {
  265. return permanent == selectedPermanent;
  266. }
  267. }
  268. }
  269. }
  270. }
  271. }
  272. #endregion
  273. return cardEffects;
  274. }
  275. }
  276. }