From a91b210456cf1484229d91cde7fa1f367d441221 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 29 Apr 2020 22:48:07 -0400 Subject: [PATCH] fixed issues with Gavi, Nest Warden --- .../src/mage/cards/g/GaviNestWarden.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Mage.Sets/src/mage/cards/g/GaviNestWarden.java b/Mage.Sets/src/mage/cards/g/GaviNestWarden.java index 6defd10597..65b8b9f922 100644 --- a/Mage.Sets/src/mage/cards/g/GaviNestWarden.java +++ b/Mage.Sets/src/mage/cards/g/GaviNestWarden.java @@ -2,11 +2,9 @@ package mage.cards.g; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.Mode; import mage.abilities.common.DrawSecondCardTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.GenericManaCost; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.cost.CostModificationEffectImpl; import mage.abilities.keyword.CyclingAbility; @@ -16,6 +14,7 @@ import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.token.DinosaurCatToken; +import mage.players.Player; import mage.watchers.Watcher; import java.util.HashMap; @@ -23,14 +22,13 @@ import java.util.Map; import java.util.UUID; /** - * * @author htrajan */ public final class GaviNestWarden extends CardImpl { public GaviNestWarden(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}{R}{W}"); - + this.addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.SHAMAN); @@ -38,12 +36,10 @@ public final class GaviNestWarden extends CardImpl { this.toughness = new MageInt(5); // You may pay {0} rather than pay the cycling cost of the first card you cycle each turn. - Effect effect = new CyclingZeroCostEffect(); - this.addAbility(new SimpleStaticAbility(effect), new GaviNestWardenWatcher()); + this.addAbility(new SimpleStaticAbility(new CyclingZeroCostEffect()), new GaviNestWardenWatcher()); // Whenever you draw your second card each turn, create a 2/2 red and white Dinosaur Cat creature token. - Ability ability = new DrawSecondCardTriggeredAbility(new CreateTokenEffect(new DinosaurCatToken()), false); - this.addAbility(ability); + this.addAbility(new DrawSecondCardTriggeredAbility(new CreateTokenEffect(new DinosaurCatToken()), false)); } private GaviNestWarden(final GaviNestWarden card) { @@ -58,11 +54,10 @@ public final class GaviNestWarden extends CardImpl { class GaviNestWardenWatcher extends Watcher { - private final Map playerCyclingActivations; + private final Map playerCyclingActivations = new HashMap<>(); - public GaviNestWardenWatcher() { + GaviNestWardenWatcher() { super(WatcherScope.GAME); - playerCyclingActivations = new HashMap<>(); } @Override @@ -72,7 +67,7 @@ class GaviNestWardenWatcher extends Watcher { } } - public int cyclingActivationsThisTurn(UUID playerId) { + int cyclingActivationsThisTurn(UUID playerId) { return playerCyclingActivations.getOrDefault(playerId, 0); } @@ -85,19 +80,23 @@ class GaviNestWardenWatcher extends Watcher { class CyclingZeroCostEffect extends CostModificationEffectImpl { - - public CyclingZeroCostEffect() { + CyclingZeroCostEffect() { super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.SET_COST); staticText = "You may pay {0} rather than pay the cycling cost of the first card you cycle each turn."; } - public CyclingZeroCostEffect(CyclingZeroCostEffect effect) { + private CyclingZeroCostEffect(CyclingZeroCostEffect effect) { super(effect); } @Override public boolean apply(Game game, Ability source, Ability abilityToModify) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || !player.chooseUse(outcome, "Pay {0} to cycle this card?", source, game)) { + return true; + } abilityToModify.getManaCostsToPay().clear(); + abilityToModify.getCosts().clear(); abilityToModify.getManaCostsToPay().add(new GenericManaCost(0)); return true; }