Nidhoggmon_EX7_060.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX7
  6. {
  7. public class Nidhoggmon_EX7_060 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Blocker
  13. if (timing == EffectTiming.None)
  14. {
  15. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  16. isInheritedEffect: false,
  17. card: card,
  18. condition: null));
  19. }
  20. #endregion
  21. #region Trash Main
  22. if (timing == EffectTiming.OnDeclaration)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Play this card from trash with reduced cost", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  27. activateClass.SetIsInheritedEffect(true);
  28. cardEffects.Add(activateClass);
  29. string EffectDiscription()
  30. {
  31. return "[Trash] [Main] If you have 4 or fewer cards in your hand, you may play this card from your trash with the play cost reduced by 4.";
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. if (CardEffectCommons.IsOwnerTurn(card))
  36. {
  37. if(CardEffectCommons.IsExistOnTrash(card))
  38. {
  39. return true;
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. if (card.Owner.LibraryCards.Count >= 1)
  49. {
  50. if (card.Owner.HandCards.Count <= 4)
  51. {
  52. return true;
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. bool CanSelectCardCondition(CardSource cardSource)
  59. {
  60. if (cardSource.IsDigimon)
  61. {
  62. if(cardSource.name.Contains("Nidhoggmon"))
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. #region reduce play cost
  72. ChangeCostClass changeCostClass = new ChangeCostClass();
  73. changeCostClass.SetUpICardEffect($"Play Cost -3", CanUseCondition1, card);
  74. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  75. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  76. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  77. ICardEffect GetCardEffect(EffectTiming _timing)
  78. {
  79. if (_timing == EffectTiming.None)
  80. {
  81. return changeCostClass;
  82. }
  83. return null;
  84. }
  85. bool CanUseCondition1(Hashtable hashtable)
  86. {
  87. return true;
  88. }
  89. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  90. {
  91. return Cost -3;
  92. }
  93. bool CardSourceCondition(CardSource cardSource)
  94. {
  95. if (cardSource.IsDigimon)
  96. {
  97. if (cardSource.ContainsCardName("Nidhoggmon"))
  98. {
  99. return true;
  100. }
  101. }
  102. return false;
  103. }
  104. bool RootCondition(SelectCardEffect.Root root)
  105. {
  106. return true;
  107. }
  108. bool isUpDown()
  109. {
  110. return true;
  111. }
  112. #endregion
  113. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  114. {
  115. List<CardSource> selectedCards = new List<CardSource>();
  116. int maxCount = 1;
  117. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  118. selectCardEffect.SetUp(
  119. canTargetCondition: CanSelectCardCondition,
  120. canTargetCondition_ByPreSelecetedList: null,
  121. canEndSelectCondition: null,
  122. canNoSelect: () => true,
  123. selectCardCoroutine: SelectCardCoroutine,
  124. afterSelectCardCoroutine: null,
  125. message: "Select cards to play.",
  126. maxCount: maxCount,
  127. canEndNotMax: true,
  128. isShowOpponent: true,
  129. mode: SelectCardEffect.Mode.Custom,
  130. root: SelectCardEffect.Root.Trash,
  131. customRootCardList: null,
  132. canLookReverseCard: true,
  133. selectPlayer: card.Owner,
  134. cardEffect: activateClass);
  135. selectCardEffect.SetUpCustomMessage("Select cards to play.", "The opponent is selecting cards to play.");
  136. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  137. yield return StartCoroutine(selectCardEffect.Activate());
  138. IEnumerator SelectCardCoroutine(CardSource cardSource)
  139. {
  140. selectedCards.Add(cardSource);
  141. yield return null;
  142. }
  143. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  144. cardSources: selectedCards,
  145. activateClass: activateClass,
  146. payCost: true,
  147. isTapped: false,
  148. root: SelectCardEffect.Root.Trash,
  149. activateETB: true));
  150. }
  151. #region release effect reducing play cost
  152. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  153. #endregion
  154. }
  155. }
  156. #endregion
  157. #region On Deletion
  158. if (timing == EffectTiming.OnDestroyedAnyone)
  159. {
  160. ActivateClass activateClass = new ActivateClass();
  161. activateClass.SetUpICardEffect("Play Digimons from trash", CanUseCondition, card);
  162. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  163. cardEffects.Add(activateClass);
  164. string EffectDiscription()
  165. {
  166. return "[On Play] You may play up to 2 level 4 or lower purple Digimon cards from your trash without paying their memory costs. Any [On Play] effects on Digimon played with this effect don't activate. ";
  167. }
  168. bool CanSelectCardCondition(CardSource cardSource)
  169. {
  170. if (cardSource.IsDigimon)
  171. {
  172. if (cardSource.Level <= 5 && cardSource.CardTraits.Contains("Dark Dragon") || cardSource.Level <= 5 && cardSource.CardTraits.Contains("Evil Dragon"))
  173. {
  174. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  175. {
  176. if (cardSource.HasLevel)
  177. {
  178. return true;
  179. }
  180. }
  181. }
  182. }
  183. return false;
  184. }
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  188. }
  189. bool CanActivateCondition(Hashtable hashtable)
  190. {
  191. if (CardEffectCommons.IsExistOnBattleArea(card))
  192. {
  193. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  194. {
  195. return true;
  196. }
  197. }
  198. return false;
  199. }
  200. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  201. {
  202. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  203. {
  204. List<CardSource> selectedCards = new List<CardSource>();
  205. int maxCount = 1;
  206. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  207. selectCardEffect.SetUp(
  208. canTargetCondition: CanSelectCardCondition,
  209. canTargetCondition_ByPreSelecetedList: null,
  210. canEndSelectCondition: null,
  211. canNoSelect: () => true,
  212. selectCardCoroutine: SelectCardCoroutine,
  213. afterSelectCardCoroutine: null,
  214. message: "Select 1 card to play.",
  215. maxCount: maxCount,
  216. canEndNotMax: true,
  217. isShowOpponent: true,
  218. mode: SelectCardEffect.Mode.Custom,
  219. root: SelectCardEffect.Root.Trash,
  220. customRootCardList: null,
  221. canLookReverseCard: true,
  222. selectPlayer: card.Owner,
  223. cardEffect: activateClass);
  224. selectCardEffect.SetUpCustomMessage("Select 1 card with [Dark Dragon]/[Evil Dragon] trait to play.", "The opponent is selecting 1 card to play.");
  225. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  226. yield return StartCoroutine(selectCardEffect.Activate());
  227. IEnumerator SelectCardCoroutine(CardSource cardSource)
  228. {
  229. selectedCards.Add(cardSource);
  230. yield return null;
  231. }
  232. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  233. cardSources: selectedCards,
  234. activateClass: activateClass,
  235. payCost: false,
  236. isTapped: false,
  237. root: SelectCardEffect.Root.Trash,
  238. activateETB: true));
  239. }
  240. }
  241. }
  242. #endregion
  243. return cardEffects;
  244. }
  245. }
  246. }