EX11_017.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Skadimon
  5. namespace DCGO.CardEffects.EX11
  6. {
  7. public class EX11_017
  8. : 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.EqualsTraits("Ice-Snow") && targetPermanent.TopCard.IsLevel5;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Iceclad
  24. if (timing == EffectTiming.None)
  25. {
  26. cardEffects.Add(CardEffectFactory.IcecladSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region Barrier
  30. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  31. {
  32. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: false, card: card, condition: null));
  33. }
  34. #endregion
  35. #region Shared OP / WD / WA
  36. string SharedEffectName = "Play [Suzune Kazuki] or a level 4 or lower [Ice-Snow] Digimon from hand.";
  37. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] You may play 1 [Suzune Kazuki] or level 4 or lower [Ice-Snow] trait Digimon card from your hand without paying the cost.";
  38. string SharedHashString = "EX11_017_OP_WD_WA_Play_Card";
  39. bool SharedCanActivateCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnBattleArea(card)
  42. && CardEffectCommons.HasMatchConditionOwnersHand(card, ValidCardToPlay);
  43. }
  44. bool ValidCardToPlay(CardSource cardSource)
  45. {
  46. return cardSource.EqualsCardName("Suzune Kazuki")
  47. || (cardSource.IsDigimon
  48. && cardSource.EqualsTraits("Ice-Snow")
  49. && cardSource.HasLevel
  50. && cardSource.Level <= 4);
  51. }
  52. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  53. {
  54. List<CardSource> selectedCards = new List<CardSource>();
  55. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  56. selectHandEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: ValidCardToPlay,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: 1,
  62. canNoSelect: true,
  63. canEndNotMax: false,
  64. isShowOpponent: true,
  65. selectCardCoroutine: SelectCardCoroutine,
  66. afterSelectCardCoroutine: null,
  67. mode: SelectHandEffect.Mode.Custom,
  68. cardEffect: activateClass);
  69. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  70. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  71. yield return StartCoroutine(selectHandEffect.Activate());
  72. IEnumerator SelectCardCoroutine(CardSource cardSource)
  73. {
  74. selectedCards.Add(cardSource);
  75. yield return null;
  76. }
  77. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  78. cardSources: selectedCards,
  79. activateClass: activateClass,
  80. payCost: false,
  81. isTapped: false,
  82. root: SelectCardEffect.Root.Hand,
  83. activateETB: true));
  84. }
  85. #endregion
  86. #region On Play
  87. if (timing == EffectTiming.OnEnterFieldAnyone)
  88. {
  89. ActivateClass activateClass = new ActivateClass();
  90. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  91. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("On Play"));
  92. activateClass.SetHashString(SharedHashString);
  93. cardEffects.Add(activateClass);
  94. bool CanUseCondition(Hashtable hashtable)
  95. {
  96. return CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  97. && CardEffectCommons.IsExistOnBattleArea(card);
  98. }
  99. }
  100. #endregion
  101. #region When Digivolving
  102. if (timing == EffectTiming.OnEnterFieldAnyone)
  103. {
  104. ActivateClass activateClass = new ActivateClass();
  105. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  106. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Digivolving"));
  107. activateClass.SetHashString(SharedHashString);
  108. cardEffects.Add(activateClass);
  109. bool CanUseCondition(Hashtable hashtable)
  110. {
  111. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  112. && CardEffectCommons.IsExistOnBattleArea(card);
  113. }
  114. }
  115. #endregion
  116. #region When Attacking
  117. if (timing == EffectTiming.OnAllyAttack)
  118. {
  119. ActivateClass activateClass = new ActivateClass();
  120. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  121. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Attacking"));
  122. activateClass.SetHashString(SharedHashString);
  123. cardEffects.Add(activateClass);
  124. bool CanUseCondition(Hashtable hashtable)
  125. {
  126. return CardEffectCommons.CanTriggerOnAttack(hashtable, card)
  127. && CardEffectCommons.IsExistOnBattleArea(card);
  128. }
  129. }
  130. #endregion
  131. #region All Turns
  132. if(timing == EffectTiming.OnEnterFieldAnyone)
  133. {
  134. ActivateClass activateClass = new ActivateClass();
  135. activateClass.SetUpICardEffect("Trash any 3 sources from opponent's Digimon. 1 of their Digimon with no sources can't suspend until their turn ends.", CanUseCondition, card);
  136. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  137. activateClass.SetHashString("EX11_017_AT_Trash_3_Stun");
  138. cardEffects.Add(activateClass);
  139. string EffectDescription() => "[All Turns] [Once Per Turn] When other Digimon are played or digivolve, trash any 3 digivolution cards from your opponent's Digimon. Then, 1 of their Digimon with no digivolution cards can't suspend until their turn ends.";
  140. bool CanUseCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.IsExistOnBattleArea(card)
  143. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition)
  144. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition));
  145. }
  146. bool PermanentCondition(Permanent permanent)
  147. {
  148. return permanent != card.PermanentOfThisCard()
  149. && CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  150. }
  151. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  152. bool CanSelectTrashSourceCondition(Permanent permanent)
  153. {
  154. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  155. && permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  156. }
  157. bool CanSelectCardCondition(CardSource cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  158. bool StunPermanentCondition(Permanent permanent)
  159. {
  160. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  161. && permanent.HasNoDigivolutionCards;
  162. }
  163. IEnumerator ActivateCoroutine(Hashtable hashtable)
  164. {
  165. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  166. permanentCondition: CanSelectTrashSourceCondition,
  167. cardCondition: CanSelectCardCondition,
  168. maxCount: 3,
  169. canNoTrash: false,
  170. isFromOnly1Permanent: false,
  171. activateClass: activateClass
  172. ));
  173. if(CardEffectCommons.HasMatchConditionOpponentsPermanent(card, StunPermanentCondition))
  174. {
  175. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  176. selectPermanentEffect.SetUp(
  177. selectPlayer: card.Owner,
  178. canTargetCondition: StunPermanentCondition,
  179. canTargetCondition_ByPreSelecetedList: null,
  180. canEndSelectCondition: null,
  181. maxCount: 1,
  182. canNoSelect: false,
  183. canEndNotMax: false,
  184. selectPermanentCoroutine: SelectPermanentCoroutine,
  185. afterSelectPermanentCoroutine: null,
  186. mode: SelectPermanentEffect.Mode.Custom,
  187. cardEffect: activateClass);
  188. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will not be able to suspend.",
  189. "The opponent is selecting 1 Digimon that will not be able to suspend.");
  190. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  191. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  192. {
  193. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  194. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCanNotSuspendCondition, card);
  195. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCanNotSuspendCondition);
  196. permanent.UntilOwnerTurnEndEffects.Add(_ => canNotSuspendClass);
  197. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  198. {
  199. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  200. .CreateDebuffEffect(permanent));
  201. }
  202. bool CanUseCanNotSuspendCondition(Hashtable hashtableCanNotSuspend)
  203. {
  204. return permanent.TopCard != null && !permanent.TopCard.CanNotBeAffected(activateClass);
  205. }
  206. bool PermanentCanNotSuspendCondition(Permanent permanentCanNotSuspend)
  207. {
  208. return permanentCanNotSuspend == permanent;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. #endregion
  215. return cardEffects;
  216. }
  217. }
  218. }