From 522ced6a5cb445830ad30d33aa38539da7feb32f Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 1 Jun 2019 09:35:42 -0400 Subject: [PATCH] Implemented Bellowing Elk --- Mage.Sets/src/mage/cards/b/BellowingElk.java | 111 +++++++++++++++++++ Mage.Sets/src/mage/sets/ModernHorizons.java | 1 + 2 files changed, 112 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/b/BellowingElk.java diff --git a/Mage.Sets/src/mage/cards/b/BellowingElk.java b/Mage.Sets/src/mage/cards/b/BellowingElk.java new file mode 100644 index 00000000000..79d1ebc2b54 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BellowingElk.java @@ -0,0 +1,111 @@ +package mage.cards.b; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; +import mage.abilities.keyword.IndestructibleAbility; +import mage.abilities.keyword.TrampleAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.watchers.Watcher; + +import java.util.*; + +/** + * @author TheElk801 + */ +public final class BellowingElk extends CardImpl { + + public BellowingElk(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}"); + + this.subtype.add(SubType.ELK); + this.power = new MageInt(4); + this.toughness = new MageInt(2); + + // As long as you had another creature enter the battlefield under your control this turn, Bellowing Elk has trample and indestructible. + Ability ability = new SimpleStaticAbility(new ConditionalContinuousEffect( + new GainAbilitySourceEffect(TrampleAbility.getInstance(), Duration.WhileOnBattlefield), + BellowingElkCondition.instance, "As long as you had another creature" + + " enter the battlefield under your control this turn, {this} has trample" + )); + ability.addEffect(new ConditionalContinuousEffect( + new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.WhileOnBattlefield), + BellowingElkCondition.instance, "and indestructible" + )); + this.addAbility(ability, new BellowingElkWatcher()); + } + + private BellowingElk(final BellowingElk card) { + super(card); + } + + @Override + public BellowingElk copy() { + return new BellowingElk(this); + } +} + +enum BellowingElkCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + BellowingElkWatcher watcher = game.getState().getWatcher(BellowingElkWatcher.class); + return watcher != null && watcher.enteredCreatureForPlayer(source.getControllerId(), source.getSourceId()); + } + + @Override + public String toString() { + return "you had a creature enter the battlefield under your control this turn"; + } +} + +class BellowingElkWatcher extends Watcher { + + private final Map> playerMap = new HashMap<>(); + + BellowingElkWatcher() { + super(WatcherScope.GAME); + } + + private BellowingElkWatcher(final BellowingElkWatcher watcher) { + super(watcher); + this.playerMap.putAll(watcher.playerMap); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + if (zEvent.getToZone() == Zone.BATTLEFIELD + && zEvent.getTarget().isCreature()) { + playerMap.putIfAbsent(zEvent.getTarget().getControllerId(), new HashSet<>()); + playerMap.get(zEvent.getTarget().getControllerId()).add(zEvent.getTargetId()); + } + } + } + + @Override + public void reset() { + playerMap.clear(); + } + + boolean enteredCreatureForPlayer(UUID playerId, UUID creatureId) { + Set s = playerMap.getOrDefault(playerId, null); + return s != null && s.stream().anyMatch((UUID id) -> (id != creatureId)); + } + + @Override + public BellowingElkWatcher copy() { + return new BellowingElkWatcher(this); + } +} +// I'm not THAT loud... diff --git a/Mage.Sets/src/mage/sets/ModernHorizons.java b/Mage.Sets/src/mage/sets/ModernHorizons.java index 0cd81269f20..58aad71bcf9 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons.java @@ -40,6 +40,7 @@ public final class ModernHorizons extends ExpansionSet { cards.add(new SetCardInfo("Barren Moor", 236, Rarity.UNCOMMON, mage.cards.b.BarrenMoor.class)); cards.add(new SetCardInfo("Battle Screech", 4, Rarity.UNCOMMON, mage.cards.b.BattleScreech.class)); cards.add(new SetCardInfo("Bazaar Trademage", 41, Rarity.RARE, mage.cards.b.BazaarTrademage.class)); + cards.add(new SetCardInfo("Bellowing Elk", 157, Rarity.COMMON, mage.cards.b.BellowingElk.class)); cards.add(new SetCardInfo("Birthing Boughs", 221, Rarity.UNCOMMON, mage.cards.b.BirthingBoughs.class)); cards.add(new SetCardInfo("Bladeback Sliver", 119, Rarity.COMMON, mage.cards.b.BladebackSliver.class)); cards.add(new SetCardInfo("Cabal Therapist", 80, Rarity.RARE, mage.cards.c.CabalTherapist.class));