EX9_037.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Kabuterimon
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_037 : 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 Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel3 &&
  19. targetPermanent.TopCard.EqualsTraits("DM");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 2,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null));
  27. }
  28. #endregion
  29. #region Training
  30. if (timing == EffectTiming.OnDeclaration)
  31. {
  32. cardEffects.Add(CardEffectFactory.TrainingEffect(card: card));
  33. }
  34. #endregion
  35. #region Shared OP / WD
  36. string SharedEffectName = "Place 1 hand card as FD bottom source, suspend 1 digimon";
  37. string SharedEffectDescription(string tag) => $"[{tag}] By placing 1 card in your hand face down as this Digimon's bottom digivolution card, suspend 1 of your opponent's Digimon. It can't unsuspend in their next unsuspend phase.";
  38. bool SharedCanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  41. && card.Owner.HandCards.Count >= 1;
  42. }
  43. bool SharedCanSelectPermanentCondition(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  46. }
  47. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  48. {
  49. CardSource selectedCard = null;
  50. int maxCount = Math.Min(1, card.Owner.HandCards.Count);
  51. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  52. selectHandEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: _ => true,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: maxCount,
  58. canNoSelect: true,
  59. canEndNotMax: true,
  60. isShowOpponent: false,
  61. selectCardCoroutine: SelectCardCoroutine,
  62. afterSelectCardCoroutine: null,
  63. mode: SelectHandEffect.Mode.Custom,
  64. cardEffect: activateClass);
  65. selectHandEffect.SetUpCustomMessage("Select 1 card to add as FD Source", "The opponent is selecting 1 card to add as FD source");
  66. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  67. IEnumerator SelectCardCoroutine(CardSource cardSource)
  68. {
  69. selectedCard = cardSource;
  70. yield return null;
  71. }
  72. if (selectedCard != null)
  73. {
  74. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  75. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  76. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, SharedCanSelectPermanentCondition))
  77. {
  78. Permanent selectedPermanent = null;
  79. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SharedCanSelectPermanentCondition));
  80. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  81. selectPermanentEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: SharedCanSelectPermanentCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: maxCount1,
  87. canNoSelect: false,
  88. canEndNotMax: false,
  89. selectPermanentCoroutine: SelectPermanentCoroutine,
  90. afterSelectPermanentCoroutine: null,
  91. mode: SelectPermanentEffect.Mode.Custom,
  92. cardEffect: activateClass);
  93. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend", "The opponent is selecting 1 Digimon to suspend");
  94. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  95. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  96. {
  97. selectedPermanent = permanent;
  98. yield return null;
  99. }
  100. if (selectedPermanent != null)
  101. {
  102. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  103. {
  104. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { selectedPermanent }, hashtable).Tap());
  105. }
  106. bool PermanentCondition(Permanent permanent)
  107. {
  108. return permanent == selectedPermanent;
  109. }
  110. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspendPlayerEffect(
  111. permanentCondition: PermanentCondition,
  112. effectDuration: EffectDuration.UntilOwnerActivePhase,
  113. activateClass: activateClass,
  114. isOnlyActivePhase: true,
  115. effectName: "Your Digimon can't unsuspend"));
  116. }
  117. }
  118. }
  119. }
  120. #endregion
  121. #region On Play
  122. if (timing == EffectTiming.OnEnterFieldAnyone)
  123. {
  124. ActivateClass activateClass = new ActivateClass();
  125. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  126. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("On Play"));
  127. cardEffects.Add(activateClass);
  128. bool CanUseCondition(Hashtable hashtable)
  129. {
  130. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  131. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  132. }
  133. }
  134. #endregion
  135. #region When Digivolving
  136. if (timing == EffectTiming.OnEnterFieldAnyone)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  140. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  141. cardEffects.Add(activateClass);
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  145. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  146. }
  147. }
  148. #endregion
  149. #region ESS
  150. if (timing == EffectTiming.OnAllyAttack)
  151. {
  152. ActivateClass activateClass = new ActivateClass();
  153. activateClass.SetUpICardEffect("Suspend 1 digimon", CanUseCondition, card);
  154. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  155. activateClass.SetHashString("EX9_037_Attacking");
  156. activateClass.SetIsInheritedEffect(true);
  157. cardEffects.Add(activateClass);
  158. string EffectDiscription()
  159. {
  160. return "[When Attacking] [Once Per Turn] Suspend 1 of your opponent's Digimon.";
  161. }
  162. bool CanUseCondition(Hashtable hashtable)
  163. {
  164. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  165. }
  166. bool CanActivateCondition(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  169. }
  170. bool CanSelectPermanentCondition(Permanent permanent)
  171. {
  172. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  173. }
  174. IEnumerator ActivateCoroutine(Hashtable hashtable)
  175. {
  176. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  177. {
  178. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  179. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  180. selectPermanentEffect.SetUp(
  181. selectPlayer: card.Owner,
  182. canTargetCondition: CanSelectPermanentCondition,
  183. canTargetCondition_ByPreSelecetedList: null,
  184. canEndSelectCondition: null,
  185. maxCount: maxCount,
  186. canNoSelect: false,
  187. canEndNotMax: false,
  188. selectPermanentCoroutine: null,
  189. afterSelectPermanentCoroutine: null,
  190. mode: SelectPermanentEffect.Mode.Tap,
  191. cardEffect: activateClass);
  192. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend", "The opponent is selecting 1 Digimon to suspend");
  193. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  194. }
  195. }
  196. }
  197. #endregion
  198. return cardEffects;
  199. }
  200. }
  201. }