diff --git a/Mage.Sets/src/mage/cards/v/VineGecko.java b/Mage.Sets/src/mage/cards/v/VineGecko.java new file mode 100644 index 0000000000..b0876eefd9 --- /dev/null +++ b/Mage.Sets/src/mage/cards/v/VineGecko.java @@ -0,0 +1,119 @@ +package mage.cards.v; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.effects.common.cost.SpellsCostReductionControllerEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.KickerAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.WatcherScope; +import mage.counters.CounterType; +import mage.filter.FilterCard; +import mage.filter.StaticFilters; +import mage.filter.predicate.ObjectPlayer; +import mage.filter.predicate.ObjectPlayerPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.stack.Spell; +import mage.watchers.Watcher; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class VineGecko extends CardImpl { + + private static final FilterCard filter = new FilterCard(); + + static { + filter.add(VineGeckoPredicate.instance); + } + + public VineGecko(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); + + this.subtype.add(SubType.ELEMENTAL); + this.subtype.add(SubType.LIZARD); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // The first kicked spell you cast each turn costs {1} less to cast. + this.addAbility(new SimpleStaticAbility(new SpellsCostReductionControllerEffect(filter, 1) + .setText("the first kicked spell you cast each turn costs {1} less to cast"))); + + // Whenever you cast a kicked spell, put a +1/+1 counter on Vine Gecko. + this.addAbility(new SpellCastControllerTriggeredAbility( + new AddCountersSourceEffect(CounterType.P1P1.createInstance()), + StaticFilters.FILTER_SPELL_KICKED_A, false + )); + } + + private VineGecko(final VineGecko card) { + super(card); + } + + @Override + public VineGecko copy() { + return new VineGecko(this); + } +} + +enum VineGeckoPredicate implements ObjectPlayerPredicate> { + instance; + + @Override + public boolean apply(ObjectPlayer input, Game game) { + VineGeckoWatcher watcher = game.getState().getWatcher(VineGeckoWatcher.class); + if (watcher == null || watcher.checkPlayer(input.getPlayerId())) { + return false; + } + for (Ability ability : input.getObject().getAbilities()) { + if (ability instanceof KickerAbility + && ((KickerAbility) ability).getKickedCounter(game, input.getObject().getSpellAbility()) > 0) { + return true; + } + } + return false; + } +} + +class VineGeckoWatcher extends Watcher { + + private final Set playerSet = new HashSet<>(); + + VineGeckoWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() != GameEvent.EventType.SPELL_CAST) { + return; + } + Spell spell = game.getStack().getSpell(event.getTargetId()); + if (spell != null && StaticFilters.FILTER_SPELL_KICKED_A.match( + spell, getSourceId(), getControllerId(), game + )) { + playerSet.add(event.getPlayerId()); + } + } + + @Override + public void reset() { + super.reset(); + playerSet.clear(); + } + + public boolean checkPlayer(UUID playerId) { + return playerSet.contains(playerId); + } +} diff --git a/Mage.Sets/src/mage/sets/ZendikarRising.java b/Mage.Sets/src/mage/sets/ZendikarRising.java index 78d565d4ee..1257911f46 100644 --- a/Mage.Sets/src/mage/sets/ZendikarRising.java +++ b/Mage.Sets/src/mage/sets/ZendikarRising.java @@ -364,6 +364,7 @@ public final class ZendikarRising extends ExpansionSet { cards.add(new SetCardInfo("Vastwood Surge", 217, Rarity.UNCOMMON, mage.cards.v.VastwoodSurge.class)); cards.add(new SetCardInfo("Vastwood Thicket", 216, Rarity.UNCOMMON, mage.cards.v.VastwoodThicket.class)); cards.add(new SetCardInfo("Veteran Adventurer", 218, Rarity.UNCOMMON, mage.cards.v.VeteranAdventurer.class)); + cards.add(new SetCardInfo("Vine Gecko", 219, Rarity.UNCOMMON, mage.cards.v.VineGecko.class)); cards.add(new SetCardInfo("Wayward Guide-Beast", 176, Rarity.RARE, mage.cards.w.WaywardGuideBeast.class)); cards.add(new SetCardInfo("Windrider Wizard", 87, Rarity.UNCOMMON, mage.cards.w.WindriderWizard.class)); cards.add(new SetCardInfo("Yasharn, Implacable Earth", 240, Rarity.RARE, mage.cards.y.YasharnImplacableEarth.class)); diff --git a/Mage/src/main/java/mage/filter/StaticFilters.java b/Mage/src/main/java/mage/filter/StaticFilters.java index 128d129877..9f269d4020 100644 --- a/Mage/src/main/java/mage/filter/StaticFilters.java +++ b/Mage/src/main/java/mage/filter/StaticFilters.java @@ -6,6 +6,7 @@ import mage.constants.SuperType; import mage.constants.TargetController; import mage.filter.common.*; import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.KickedPredicate; import mage.filter.predicate.mageobject.MulticoloredPredicate; import mage.filter.predicate.permanent.AnotherPredicate; import mage.filter.predicate.permanent.AttackingPredicate; @@ -618,6 +619,13 @@ public final class StaticFilters { FILTER_SPELL_INSTANT_SORCERY_WIZARD.setLockedFilter(true); } + public static final FilterSpell FILTER_SPELL_KICKED_A = new FilterSpell("a kicked spell"); + + static { + FILTER_SPELL_KICKED_A.add(KickedPredicate.instance); + FILTER_SPELL_KICKED_A.setLockedFilter(true); + } + public static final FilterCreaturePermanent FILTER_CREATURE_TOKENS = new FilterCreaturePermanent("creature tokens"); static {