BT24_076.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //WarGrowlmon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_076 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Trash Main
  14. if (timing == EffectTiming.OnDeclaration)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Play this card from trash with reduced cost", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  19. activateClass.SetIsDigimonEffect(true);
  20. cardEffects.Add(activateClass);
  21. string EffectDescription()
  22. {
  23. 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 2.";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.IsOwnerTurn(card)
  28. && CardEffectCommons.IsExistOnTrash(card)
  29. && card.Owner.HandCards.Count <= 4;
  30. }
  31. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  32. {
  33. #region reduce play cost
  34. ChangeCostClass changeCostClass = new ChangeCostClass();
  35. changeCostClass.SetUpICardEffect($"Play Cost -2", CanUseCondition1, card);
  36. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  37. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  38. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  39. ICardEffect GetCardEffect(EffectTiming _timing)
  40. {
  41. if (_timing == EffectTiming.None)
  42. {
  43. return changeCostClass;
  44. }
  45. return null;
  46. }
  47. bool CanUseCondition1(Hashtable hashtable)
  48. {
  49. return true;
  50. }
  51. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  52. {
  53. return Cost - 2;
  54. }
  55. bool CardSourceCondition(CardSource cardSource)
  56. {
  57. return (cardSource == card);
  58. }
  59. bool RootCondition(SelectCardEffect.Root root)
  60. {
  61. return true;
  62. }
  63. bool isUpDown()
  64. {
  65. return true;
  66. }
  67. #endregion
  68. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  69. cardSources: new List<CardSource> { card },
  70. activateClass: activateClass,
  71. payCost: true,
  72. isTapped: false,
  73. root: SelectCardEffect.Root.Trash,
  74. activateETB: true));
  75. #region release effect reducing play cost
  76. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  77. #endregion
  78. }
  79. }
  80. #endregion
  81. #region Shared OP/WD
  82. string SharedEffectName() => "Delete 1 lvl 4 or lower.";
  83. string SharedEffectDescription(string tag) => $"[{tag}] Delete 1 of your opponent's level 4 or lower Digimon.";
  84. bool SharedCanActivateCondition(Hashtable hashtable)
  85. {
  86. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  87. }
  88. bool CanSelectLevelOpponentPermanentCondition(Permanent permanent)
  89. {
  90. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  91. && permanent.TopCard.HasLevel
  92. && permanent.Level <= 4;
  93. }
  94. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  95. {
  96. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectLevelOpponentPermanentCondition))
  97. {
  98. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  99. selectPermanentEffect.SetUp(
  100. selectPlayer: card.Owner,
  101. canTargetCondition: CanSelectLevelOpponentPermanentCondition,
  102. canTargetCondition_ByPreSelecetedList: null,
  103. canEndSelectCondition: null,
  104. maxCount: 1,
  105. canNoSelect: false,
  106. canEndNotMax: false,
  107. selectPermanentCoroutine: null,
  108. afterSelectPermanentCoroutine: null,
  109. mode: SelectPermanentEffect.Mode.Destroy,
  110. cardEffect: activateClass);
  111. selectPermanentEffect.SetUpCustomMessage("Select 1 of your opponents lvl 4 or lower Digimon to delete.", "The opponent is selecting 1 of your Digimon to delete.");
  112. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  113. }
  114. }
  115. #endregion
  116. #region On Play
  117. if (timing == EffectTiming.OnEnterFieldAnyone)
  118. {
  119. ActivateClass activateClass = new ActivateClass();
  120. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  121. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  122. cardEffects.Add(activateClass);
  123. bool CanUseCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  126. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  127. }
  128. }
  129. #endregion
  130. #region When Digivolving
  131. if (timing == EffectTiming.OnEnterFieldAnyone)
  132. {
  133. ActivateClass activateClass = new ActivateClass();
  134. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  135. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  136. cardEffects.Add(activateClass);
  137. bool CanUseCondition(Hashtable hashtable)
  138. {
  139. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  140. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  141. }
  142. }
  143. #endregion
  144. #region ESS - On Deletion
  145. if (timing == EffectTiming.OnDestroyedAnyone)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect("Play 1 Digimon from trash", CanUseCondition, card);
  149. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  150. activateClass.SetIsInheritedEffect(true);
  151. cardEffects.Add(activateClass);
  152. string EffectDescription()
  153. {
  154. return "[On Deletion] You may play 1 level 4 or lower Digimon card with the [Dark Dragon] or [Evil Dragon] trait from your trash without paying the cost.";
  155. }
  156. bool CanSelectCardCondition(CardSource cardSource)
  157. {
  158. return cardSource.IsDigimon
  159. && cardSource.HasLevel
  160. && cardSource.Level <= 4
  161. && (cardSource.EqualsTraits("Dark Dragon") || cardSource.EqualsTraits("Evil Dragon"))
  162. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  163. }
  164. bool CanUseCondition(Hashtable hashtable)
  165. {
  166. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  167. }
  168. bool CanActivateCondition(Hashtable hashtable)
  169. {
  170. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  171. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  172. }
  173. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  174. {
  175. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  176. {
  177. List<CardSource> selectedCards = new List<CardSource>();
  178. int maxCount = 1;
  179. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  180. selectCardEffect.SetUp(
  181. canTargetCondition: CanSelectCardCondition,
  182. canTargetCondition_ByPreSelecetedList: null,
  183. canEndSelectCondition: null,
  184. canNoSelect: () => true,
  185. selectCardCoroutine: SelectCardCoroutine,
  186. afterSelectCardCoroutine: null,
  187. message: "Select 1 card to play.",
  188. maxCount: maxCount,
  189. canEndNotMax: true,
  190. isShowOpponent: true,
  191. mode: SelectCardEffect.Mode.Custom,
  192. root: SelectCardEffect.Root.Trash,
  193. customRootCardList: null,
  194. canLookReverseCard: true,
  195. selectPlayer: card.Owner,
  196. cardEffect: activateClass);
  197. selectCardEffect.SetUpCustomMessage("Select 1 card with [Dark Dragon]/[Evil Dragon] trait to play.", "The opponent is selecting 1 card to play.");
  198. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  199. yield return StartCoroutine(selectCardEffect.Activate());
  200. IEnumerator SelectCardCoroutine(CardSource cardSource)
  201. {
  202. selectedCards.Add(cardSource);
  203. yield return null;
  204. }
  205. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  206. cardSources: selectedCards,
  207. activateClass: activateClass,
  208. payCost: false,
  209. isTapped: false,
  210. root: SelectCardEffect.Root.Trash,
  211. activateETB: true));
  212. }
  213. }
  214. }
  215. #endregion
  216. return cardEffects;
  217. }
  218. }
  219. }