From f6872732f2ab917dc55e56ec7e1d1498dd35362e Mon Sep 17 00:00:00 2001 From: htrajan Date: Wed, 22 Apr 2020 04:38:34 -0700 Subject: [PATCH] C20 Gavi Nest Warden (#6452) * C20 Gavi Nest Warden * remove unneeded predicate; set text in effect; remove unneeded constructor param for static ability * staticText * rebuild --- .../src/mage/cards/g/GaviNestWarden.java | 118 ++++++++++++++++++ .../src/mage/sets/Commander2020Edition.java | 1 + .../permanent/token/DinosaurCatToken.java | 27 ++++ 3 files changed, 146 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GaviNestWarden.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/DinosaurCatToken.java diff --git a/Mage.Sets/src/mage/cards/g/GaviNestWarden.java b/Mage.Sets/src/mage/cards/g/GaviNestWarden.java new file mode 100644 index 0000000000..6defd10597 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GaviNestWarden.java @@ -0,0 +1,118 @@ +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; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.token.DinosaurCatToken; +import mage.watchers.Watcher; + +import java.util.HashMap; +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); + this.power = new MageInt(2); + 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()); + + // 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); + } + + private GaviNestWarden(final GaviNestWarden card) { + super(card); + } + + @Override + public GaviNestWarden copy() { + return new GaviNestWarden(this); + } +} + +class GaviNestWardenWatcher extends Watcher { + + private final Map playerCyclingActivations; + + public GaviNestWardenWatcher() { + super(WatcherScope.GAME); + playerCyclingActivations = new HashMap<>(); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.CYCLED_CARD) { + playerCyclingActivations.merge(event.getPlayerId(), 1, Integer::sum); + } + } + + public int cyclingActivationsThisTurn(UUID playerId) { + return playerCyclingActivations.getOrDefault(playerId, 0); + } + + @Override + public void reset() { + super.reset(); + playerCyclingActivations.clear(); + } +} + +class CyclingZeroCostEffect extends CostModificationEffectImpl { + + + public 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) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + abilityToModify.getManaCostsToPay().clear(); + abilityToModify.getManaCostsToPay().add(new GenericManaCost(0)); + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + GaviNestWardenWatcher watcher = game.getState().getWatcher(GaviNestWardenWatcher.class); + return abilityToModify instanceof CyclingAbility + && watcher != null + && watcher.cyclingActivationsThisTurn(abilityToModify.getControllerId()) == 0 + && abilityToModify.getControllerId().equals(source.getControllerId()); + } + + @Override + public CyclingZeroCostEffect copy() { + return new CyclingZeroCostEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2020Edition.java b/Mage.Sets/src/mage/sets/Commander2020Edition.java index 98beca6918..14baae31cf 100644 --- a/Mage.Sets/src/mage/sets/Commander2020Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2020Edition.java @@ -142,6 +142,7 @@ public final class Commander2020Edition extends ExpansionSet { cards.add(new SetCardInfo("Frontline Medic", 89, Rarity.RARE, mage.cards.f.FrontlineMedic.class)); cards.add(new SetCardInfo("Fumiko the Lowblood", 152, Rarity.RARE, mage.cards.f.FumikoTheLowblood.class)); cards.add(new SetCardInfo("Garna, the Bloodflame", 213, Rarity.UNCOMMON, mage.cards.g.GarnaTheBloodflame.class)); + cards.add(new SetCardInfo("Gavi, Nest Warden", 7, Rarity.MYTHIC, mage.cards.g.GaviNestWarden.class)); cards.add(new SetCardInfo("Gavony Township", 276, Rarity.RARE, mage.cards.g.GavonyTownship.class)); cards.add(new SetCardInfo("Gaze of Granite", 214, Rarity.RARE, mage.cards.g.GazeOfGranite.class)); cards.add(new SetCardInfo("Genesis Hydra", 172, Rarity.RARE, mage.cards.g.GenesisHydra.class)); diff --git a/Mage/src/main/java/mage/game/permanent/token/DinosaurCatToken.java b/Mage/src/main/java/mage/game/permanent/token/DinosaurCatToken.java new file mode 100644 index 0000000000..c5a2db7fd2 --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/DinosaurCatToken.java @@ -0,0 +1,27 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.constants.CardType; +import mage.constants.SubType; + +public final class DinosaurCatToken extends TokenImpl { + public DinosaurCatToken() { + super("Dinosaur Cat", "2/2 red and white Dinosaur Cat creature token"); + cardType.add(CardType.CREATURE); + color.setRed(true); + color.setWhite(true); + subtype.add(SubType.DINOSAUR); + subtype.add(SubType.CAT); + power = new MageInt(2); + toughness = new MageInt(2); + } + + public DinosaurCatToken(final DinosaurCatToken token) { + super(token); + } + + @Override + public DinosaurCatToken copy() { + return new DinosaurCatToken(this); + } +}