From 27334c91ee67bab069383db461703ace5ac0ce14 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 5 Sep 2020 17:30:01 -0400 Subject: [PATCH] [ZNR] Implemented Iridescent Hornbeetle --- .../mage/cards/i/IridescentHornbeetle.java | 107 ++++++++++++++++++ Mage.Sets/src/mage/sets/ZendikarRising.java | 1 + 2 files changed, 108 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/i/IridescentHornbeetle.java diff --git a/Mage.Sets/src/mage/cards/i/IridescentHornbeetle.java b/Mage.Sets/src/mage/cards/i/IridescentHornbeetle.java new file mode 100644 index 0000000000..7f5cfa5852 --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/IridescentHornbeetle.java @@ -0,0 +1,107 @@ +package mage.cards.i; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +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.TargetController; +import mage.constants.WatcherScope; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.token.InsectToken; +import mage.watchers.Watcher; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class IridescentHornbeetle extends CardImpl { + + public IridescentHornbeetle(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}"); + + this.subtype.add(SubType.INSECT); + this.power = new MageInt(3); + this.toughness = new MageInt(4); + + // At the beginning of your end step, create a 1/1 green Insect creature token for each +1/+1 counter you've put on creatures under your control this turn. + this.addAbility(new BeginningOfEndStepTriggeredAbility(new CreateTokenEffect( + new InsectToken(), IridescentHornbeetleValue.instance + ), TargetController.YOU, false), new IridescentHornbeetleWatcher()); + } + + private IridescentHornbeetle(final IridescentHornbeetle card) { + super(card); + } + + @Override + public IridescentHornbeetle copy() { + return new IridescentHornbeetle(this); + } +} + +enum IridescentHornbeetleValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + IridescentHornbeetleWatcher watcher = game.getState().getWatcher(IridescentHornbeetleWatcher.class); + if (watcher == null) { + return 0; + } + return watcher.getCounterCount(sourceAbility.getControllerId()); + } + + @Override + public IridescentHornbeetleValue copy() { + return instance; + } + + @Override + public String getMessage() { + return "+1/+1 counter you've put on creatures under your control this turn"; + } + + @Override + public String toString() { + return "1"; + } +} + +class IridescentHornbeetleWatcher extends Watcher { + + private final Map playerMap = new HashMap<>(); + + IridescentHornbeetleWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() != GameEvent.EventType.COUNTER_ADDED + || !event.getData().equals(CounterType.P1P1.getName())) { + return; + } + playerMap.compute(event.getPlayerId(), (u, i) -> i == null ? 1 : Integer.sum(i, 1)); + } + + @Override + public void reset() { + playerMap.clear(); + super.reset(); + } + + int getCounterCount(UUID playerId) { + return playerMap.getOrDefault(playerId, 0); + } +} diff --git a/Mage.Sets/src/mage/sets/ZendikarRising.java b/Mage.Sets/src/mage/sets/ZendikarRising.java index 7c08ccc36c..b22826a47d 100644 --- a/Mage.Sets/src/mage/sets/ZendikarRising.java +++ b/Mage.Sets/src/mage/sets/ZendikarRising.java @@ -133,6 +133,7 @@ public final class ZendikarRising extends ExpansionSet { cards.add(new SetCardInfo("Hagra Constrictor", 105, Rarity.COMMON, mage.cards.h.HagraConstrictor.class)); cards.add(new SetCardInfo("Highborn Vampire", 107, Rarity.COMMON, mage.cards.h.HighbornVampire.class)); cards.add(new SetCardInfo("Into the Roil", 62, Rarity.COMMON, mage.cards.i.IntoTheRoil.class)); + cards.add(new SetCardInfo("Iridescent Hornbeetle", 187, Rarity.UNCOMMON, mage.cards.i.IridescentHornbeetle.class)); cards.add(new SetCardInfo("Island", 269, Rarity.LAND, mage.cards.basiclands.Island.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Jace, Mirror Mage", 63, Rarity.MYTHIC, mage.cards.j.JaceMirrorMage.class)); cards.add(new SetCardInfo("Joraga Visionary", 188, Rarity.COMMON, mage.cards.j.JoragaVisionary.class));