diff --git a/Mage.Sets/src/mage/cards/a/AxgardArtisan.java b/Mage.Sets/src/mage/cards/a/AxgardArtisan.java new file mode 100644 index 0000000000..4610a188bd --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AxgardArtisan.java @@ -0,0 +1,77 @@ +package mage.cards.a; + +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.TreasureToken; +import mage.watchers.common.BoostCountersAddedFirstTimeWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class AxgardArtisan extends CardImpl { + + public AxgardArtisan(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}"); + + this.subtype.add(SubType.DWARF); + this.subtype.add(SubType.ARTIFICER); + this.power = new MageInt(2); + this.toughness = new MageInt(1); + + // Whenever one or more +1/+1 counters are put on Axgard Artisan for the first time each turn, create a Treasure token. + this.addAbility(new AxgardArtisanTriggeredAbility()); + } + + private AxgardArtisan(final AxgardArtisan card) { + super(card); + } + + @Override + public AxgardArtisan copy() { + return new AxgardArtisan(this); + } +} + +class AxgardArtisanTriggeredAbility extends TriggeredAbilityImpl { + + AxgardArtisanTriggeredAbility() { + super(Zone.BATTLEFIELD, new CreateTokenEffect(new TreasureToken())); + this.setTriggerPhrase("Whenever one or more +1/+1 counters are put on {this} for the first time each turn, "); + this.addWatcher(new BoostCountersAddedFirstTimeWatcher()); + } + + private AxgardArtisanTriggeredAbility(final AxgardArtisanTriggeredAbility ability) { + super(ability); + } + + @Override + public AxgardArtisanTriggeredAbility copy() { + return new AxgardArtisanTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.COUNTERS_ADDED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Permanent permanent = game.getPermanent(event.getTargetId()); + return permanent != null + && this.getSourceId().equals(event.getTargetId()) + && event.getData().equals(CounterType.P1P1.getName()) + && BoostCountersAddedFirstTimeWatcher.checkEvent(event, permanent, game); + } +} diff --git a/Mage.Sets/src/mage/cards/b/BotanicalBrawler.java b/Mage.Sets/src/mage/cards/b/BotanicalBrawler.java index 67513785f9..df4c50707c 100644 --- a/Mage.Sets/src/mage/cards/b/BotanicalBrawler.java +++ b/Mage.Sets/src/mage/cards/b/BotanicalBrawler.java @@ -1,7 +1,6 @@ package mage.cards.b; import mage.MageInt; -import mage.MageObjectReference; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.effects.common.counter.AddCountersSourceEffect; @@ -10,16 +9,13 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.WatcherScope; import mage.constants.Zone; import mage.counters.CounterType; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import mage.watchers.Watcher; +import mage.watchers.common.BoostCountersAddedFirstTimeWatcher; -import java.util.HashMap; -import java.util.Map; import java.util.UUID; /** @@ -61,7 +57,7 @@ class BotanicalBrawlerTriggeredAbility extends TriggeredAbilityImpl { BotanicalBrawlerTriggeredAbility() { super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance())); - this.addWatcher(new BotanicalBrawlerWatcher()); + this.addWatcher(new BoostCountersAddedFirstTimeWatcher()); } private BotanicalBrawlerTriggeredAbility(final BotanicalBrawlerTriggeredAbility ability) { @@ -85,7 +81,7 @@ class BotanicalBrawlerTriggeredAbility extends TriggeredAbilityImpl { && !getSourceId().equals(event.getTargetId()) && isControlledBy(permanent.getControllerId()) && event.getData().equals(CounterType.P1P1.getName()) - && BotanicalBrawlerWatcher.checkEvent(event, permanent, game); + && BoostCountersAddedFirstTimeWatcher.checkEvent(event, permanent, game); } @Override @@ -95,39 +91,3 @@ class BotanicalBrawlerTriggeredAbility extends TriggeredAbilityImpl { "put a +1/+1 counter on {this}."; } } - -class BotanicalBrawlerWatcher extends Watcher { - - private final Map map = new HashMap<>(); - - BotanicalBrawlerWatcher() { - super(WatcherScope.GAME); - } - - @Override - public void watch(GameEvent event, Game game) { - if (event.getType() != GameEvent.EventType.COUNTERS_ADDED) { - return; - } - Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && event.getData().equals(CounterType.P1P1.getName())) { - map.putIfAbsent(new MageObjectReference(permanent, game), event.getId()); - } - } - - @Override - public void reset() { - super.reset(); - map.clear(); - } - - static boolean checkEvent(GameEvent event, Permanent permanent, Game game) { - return event - .getId() - .equals(game - .getState() - .getWatcher(BotanicalBrawlerWatcher.class) - .map - .getOrDefault(new MageObjectReference(permanent, game), null)); - } -} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index 19a9eb9755..184c26648b 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -44,6 +44,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Attentive Skywarden", 7, Rarity.COMMON, mage.cards.a.AttentiveSkywarden.class)); cards.add(new SetCardInfo("Awaken the Maelstrom", 230, Rarity.RARE, mage.cards.a.AwakenTheMaelstrom.class)); cards.add(new SetCardInfo("Awakened Skyclave", 194, Rarity.UNCOMMON, mage.cards.a.AwakenedSkyclave.class)); + cards.add(new SetCardInfo("Axgard Artisan", 332, Rarity.UNCOMMON, mage.cards.a.AxgardArtisan.class)); cards.add(new SetCardInfo("Ayara, Furnace Queen", 90, Rarity.RARE, mage.cards.a.AyaraFurnaceQueen.class)); cards.add(new SetCardInfo("Ayara, Widow of the Realm", 90, Rarity.RARE, mage.cards.a.AyaraWidowOfTheRealm.class)); cards.add(new SetCardInfo("Baral and Kari Zev", 218, Rarity.RARE, mage.cards.b.BaralAndKariZev.class)); diff --git a/Mage/src/main/java/mage/watchers/common/BoostCountersAddedFirstTimeWatcher.java b/Mage/src/main/java/mage/watchers/common/BoostCountersAddedFirstTimeWatcher.java new file mode 100644 index 0000000000..efbb228a6c --- /dev/null +++ b/Mage/src/main/java/mage/watchers/common/BoostCountersAddedFirstTimeWatcher.java @@ -0,0 +1,52 @@ +package mage.watchers.common; + +import mage.MageObjectReference; +import mage.constants.WatcherScope; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.watchers.Watcher; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public class BoostCountersAddedFirstTimeWatcher extends Watcher { + + private final Map map = new HashMap<>(); + + public BoostCountersAddedFirstTimeWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() != GameEvent.EventType.COUNTERS_ADDED) { + return; + } + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent != null && event.getData().equals(CounterType.P1P1.getName())) { + map.putIfAbsent(new MageObjectReference(permanent, game), event.getId()); + } + } + + @Override + public void reset() { + super.reset(); + map.clear(); + } + + public static boolean checkEvent(GameEvent event, Permanent permanent, Game game) { + return event + .getId() + .equals(game + .getState() + .getWatcher(BoostCountersAddedFirstTimeWatcher.class) + .map + .getOrDefault(new MageObjectReference(permanent, game), null)); + } +}