EX7_049.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX7
  5. {
  6. public class EX7_049 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Play/ When Attacking Shared
  12. bool CanSelectPermanentSharedCondition(Permanent permanent)
  13. {
  14. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  15. }
  16. bool CanActivateSharedCondition(Hashtable hashtable)
  17. {
  18. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  19. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition);
  20. }
  21. #endregion
  22. #region On Play
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("De-Digivolve 4", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, false, EffectDescription());
  28. cardEffects.Add(activateClass);
  29. string EffectDescription()
  30. {
  31. return
  32. "[On Play] <De-Digivolve 4> 1 of your opponent's Digimon (Trash up to 4 cards from the top. You can't trash past level 3 cards).";
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable hashtable)
  39. {
  40. SelectPermanentEffect selectPermanentEffect =
  41. GManager.instance.GetComponent<SelectPermanentEffect>();
  42. selectPermanentEffect.SetUp(
  43. selectPlayer: card.Owner,
  44. canTargetCondition: CanSelectPermanentSharedCondition,
  45. canTargetCondition_ByPreSelecetedList: null,
  46. canEndSelectCondition: null,
  47. maxCount: 1,
  48. canNoSelect: false,
  49. canEndNotMax: false,
  50. selectPermanentCoroutine: SelectPermanentCoroutine,
  51. afterSelectPermanentCoroutine: null,
  52. mode: SelectPermanentEffect.Mode.Custom,
  53. cardEffect: activateClass);
  54. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve 4.",
  55. "The opponent is selecting 1 Digimon to De-Digivolve 4.");
  56. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  57. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  58. {
  59. yield return ContinuousController.instance.StartCoroutine(
  60. new IDegeneration(permanent, 4, activateClass).Degeneration());
  61. }
  62. }
  63. }
  64. #endregion
  65. #region When Attacking
  66. if (timing == EffectTiming.OnAllyAttack)
  67. {
  68. ActivateClass activateClass = new ActivateClass();
  69. activateClass.SetUpICardEffect("De-Digivolve 4", CanUseCondition, card);
  70. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, false, EffectDescription());
  71. cardEffects.Add(activateClass);
  72. string EffectDescription()
  73. {
  74. return
  75. "[When Attacking] <De-Digivolve 4> 1 of your opponent's Digimon (Trash up to 4 cards from the top. You can't trash past level 3 cards).";
  76. }
  77. bool CanUseCondition(Hashtable hashtable)
  78. {
  79. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  80. }
  81. IEnumerator ActivateCoroutine(Hashtable hashtable)
  82. {
  83. SelectPermanentEffect selectPermanentEffect =
  84. GManager.instance.GetComponent<SelectPermanentEffect>();
  85. selectPermanentEffect.SetUp(
  86. selectPlayer: card.Owner,
  87. canTargetCondition: CanSelectPermanentSharedCondition,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. maxCount: 1,
  91. canNoSelect: false,
  92. canEndNotMax: false,
  93. selectPermanentCoroutine: SelectPermanentCoroutine,
  94. afterSelectPermanentCoroutine: null,
  95. mode: SelectPermanentEffect.Mode.Custom,
  96. cardEffect: activateClass);
  97. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve 4.",
  98. "The opponent is selecting 1 Digimon to De-Digivolve 4.");
  99. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  100. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  101. {
  102. yield return ContinuousController.instance.StartCoroutine(
  103. new IDegeneration(permanent, 4, activateClass).Degeneration());
  104. }
  105. }
  106. }
  107. #endregion
  108. #region When Digivolving
  109. if (timing == EffectTiming.OnEnterFieldAnyone)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("Opponent's level 4 or lower Digimon can't digivolve", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  114. cardEffects.Add(activateClass);
  115. string EffectDescription()
  116. {
  117. return
  118. "[When Digivolving] None of your opponent's level 4 or lower Digimon can digivolve until the end of their turn.";
  119. }
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  123. }
  124. bool OpponentPermanentCondition(Permanent permanent)
  125. {
  126. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  127. permanent.TopCard.HasLevel &&
  128. permanent.Level <= 4;
  129. }
  130. bool CanActivateCondition(Hashtable hashtable)
  131. {
  132. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  133. }
  134. IEnumerator ActivateCoroutine(Hashtable hashtable)
  135. {
  136. CanNotDigivolveClass canNotDigivolveClass = new CanNotDigivolveClass();
  137. canNotDigivolveClass.SetUpICardEffect("Can't Digivolve", _ => true, card);
  138. canNotDigivolveClass.SetUpCanNotEvolveClass(permanentCondition: OpponentPermanentCondition,
  139. cardCondition: cardSource => cardSource.Owner == card.Owner.Enemy);
  140. card.Owner.Enemy.UntilOwnerTurnEndEffects.Add(_ => canNotDigivolveClass);
  141. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().DebuffSE);
  142. foreach (var permanent in card.Owner.Enemy.GetBattleAreaDigimons().Where(OpponentPermanentCondition))
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(
  145. GManager.instance.GetComponent<Effects>().CreateDebuffEffect(permanent));
  146. }
  147. }
  148. }
  149. #endregion
  150. #region All Turns
  151. if (timing == EffectTiming.WhenRemoveField)
  152. {
  153. ActivateClass activateClass = new ActivateClass();
  154. activateClass.SetUpICardEffect("Play 1 Digimon card with the [Rock Dragon]/[Earth Dragon] trait", CanUseCondition, card);
  155. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  156. activateClass.SetHashString("PlayDigimon_EX7_049");
  157. cardEffects.Add(activateClass);
  158. string EffectDescription()
  159. {
  160. return
  161. "[All Turns] (Once Per Turn) When this Digimon would leave the battle area other than by one of your effects, you may play 1 Digimon card with the [Rock Dragon]/[Earth Dragon] trait from your trash without paying the cost.";
  162. }
  163. bool CanUseCondition(Hashtable hashtable)
  164. {
  165. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  166. {
  167. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  168. {
  169. if (!CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card)))
  170. {
  171. return true;
  172. }
  173. }
  174. }
  175. return false;
  176. }
  177. bool CanSelectCardToPlayFromTrash(CardSource cardSource)
  178. {
  179. return CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass) &&
  180. cardSource.IsDigimon &&
  181. (cardSource.ContainsTraits("Rock Dragon") || cardSource.ContainsTraits("Earth Dragon"));
  182. }
  183. bool CanActivateCondition(Hashtable hashtable)
  184. {
  185. return CardEffectCommons.IsExistOnBattleArea(card) &&
  186. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardToPlayFromTrash);
  187. }
  188. IEnumerator ActivateCoroutine(Hashtable hashtable)
  189. {
  190. List<CardSource> selectedCards = new List<CardSource>();
  191. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  192. selectCardEffect.SetUp(
  193. canTargetCondition: CanSelectCardToPlayFromTrash,
  194. canTargetCondition_ByPreSelecetedList: null,
  195. canEndSelectCondition: null,
  196. canNoSelect: () => true,
  197. selectCardCoroutine: SelectCardCoroutine,
  198. afterSelectCardCoroutine: null,
  199. message: "Select 1 card to play.",
  200. maxCount: 1,
  201. canEndNotMax: false,
  202. isShowOpponent: true,
  203. mode: SelectCardEffect.Mode.Custom,
  204. root: SelectCardEffect.Root.Trash,
  205. customRootCardList: null,
  206. canLookReverseCard: true,
  207. selectPlayer: card.Owner,
  208. cardEffect: activateClass);
  209. selectCardEffect.SetUpCustomMessage("Select 1 card to play.",
  210. "The opponent is selecting 1 card to play.");
  211. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  212. yield return StartCoroutine(selectCardEffect.Activate());
  213. IEnumerator SelectCardCoroutine(CardSource cardSource)
  214. {
  215. selectedCards.Add(cardSource);
  216. yield return null;
  217. }
  218. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  219. cardSources: selectedCards,
  220. activateClass: activateClass,
  221. payCost: false,
  222. isTapped: false,
  223. root: SelectCardEffect.Root.Trash,
  224. activateETB: true));
  225. }
  226. }
  227. #endregion
  228. return cardEffects;
  229. }
  230. }
  231. }