From 137df7ce276aa634b3e6a09799be70b96977337e Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Mon, 1 Apr 2024 16:50:22 +0200 Subject: [PATCH] [OTJ] Implement Stubborn Burrowfiend --- .../src/mage/cards/s/StubbornBurrowfiend.java | 121 ++++++++++++++++++ .../mage/sets/OutlawsOfThunderJunction.java | 1 + 2 files changed, 122 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/StubbornBurrowfiend.java diff --git a/Mage.Sets/src/mage/cards/s/StubbornBurrowfiend.java b/Mage.Sets/src/mage/cards/s/StubbornBurrowfiend.java new file mode 100644 index 00000000000..649ae3b9bc4 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/StubbornBurrowfiend.java @@ -0,0 +1,121 @@ +package mage.cards.s; + +import mage.MageInt; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.MillCardsControllerEffect; +import mage.abilities.effects.common.continuous.BoostSourceEffect; +import mage.abilities.hint.ValueHint; +import mage.abilities.keyword.SaddleAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.util.CardUtil; +import mage.watchers.Watcher; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * @author Susucr + */ +public final class StubbornBurrowfiend extends CardImpl { + + private static final CardsInControllerGraveyardCount xValue = new CardsInControllerGraveyardCount(StaticFilters.FILTER_CARD_CREATURE); + private static final ValueHint hint = new ValueHint("Creature cards in your graveyard", xValue); + + public StubbornBurrowfiend(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); + + this.subtype.add(SubType.BADGER); + this.subtype.add(SubType.BEAST); + this.subtype.add(SubType.MOUNT); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Whenever Stubborn Burrowfiend becomes saddled for the first time each turn, mill two cards, then Stubborn Burrowfiend gets +X/+X until end of turn, where X is the number of creature cards in your graveyard. + Ability ability = new StubbornBurrowfiendTriggeredAbility(new MillCardsControllerEffect(2)); + ability.addEffect(new BoostSourceEffect(xValue, xValue, Duration.EndOfTurn)); + ability.addHint(hint); + this.addAbility(ability, new StubbornBurrowFiendWatcher()); + + // Saddle 2 + this.addAbility(new SaddleAbility(2)); + + } + + private StubbornBurrowfiend(final StubbornBurrowfiend card) { + super(card); + } + + @Override + public StubbornBurrowfiend copy() { + return new StubbornBurrowfiend(this); + } +} + +class StubbornBurrowFiendWatcher extends Watcher { + + // MOR -> number of times saddled this turn. + // Since Watcher are updated before triggers, we want to find 1 for the trigger. + private final Map saddledCount = new HashMap<>(); + + StubbornBurrowFiendWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() != GameEvent.EventType.MOUNT_SADDLED) { + return; + } + saddledCount.compute(new MageObjectReference(event.getTargetId(), game), CardUtil::setOrIncrementValue); + } + + public Integer timesSaddledThisTurn(MageObjectReference mor) { + return saddledCount.getOrDefault(mor, 0); + } + + @Override + public void reset() { + super.reset(); + saddledCount.clear(); + } +} + +class StubbornBurrowfiendTriggeredAbility extends TriggeredAbilityImpl { + + StubbornBurrowfiendTriggeredAbility(Effect effect) { + super(Zone.BATTLEFIELD, effect, false); + setTriggerPhrase("When {this} becomes saddled for the first time this turn, "); + } + + private StubbornBurrowfiendTriggeredAbility(final StubbornBurrowfiendTriggeredAbility ability) { + super(ability); + } + + @Override + public StubbornBurrowfiendTriggeredAbility copy() { + return new StubbornBurrowfiendTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.MOUNT_SADDLED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + StubbornBurrowFiendWatcher watcher = game.getState().getWatcher(StubbornBurrowFiendWatcher.class); + return watcher != null + && event.getSourceId().equals(this.getSourceId()) + && 1 == watcher.timesSaddledThisTurn(new MageObjectReference(event.getTargetId(), game)); + } +} diff --git a/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java b/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java index 93e91dd9076..d7db3c974bc 100644 --- a/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java +++ b/Mage.Sets/src/mage/sets/OutlawsOfThunderJunction.java @@ -207,6 +207,7 @@ public final class OutlawsOfThunderJunction extends ExpansionSet { cards.add(new SetCardInfo("Sterling Keykeeper", 32, Rarity.COMMON, mage.cards.s.SterlingKeykeeper.class)); cards.add(new SetCardInfo("Stingerback Terror", 147, Rarity.RARE, mage.cards.s.StingerbackTerror.class)); cards.add(new SetCardInfo("Stoic Sphinx", 71, Rarity.RARE, mage.cards.s.StoicSphinx.class)); + cards.add(new SetCardInfo("Stubborn Burrowfiend", 184, Rarity.UNCOMMON, mage.cards.s.StubbornBurrowfiend.class)); cards.add(new SetCardInfo("Swamp", 274, Rarity.LAND, mage.cards.basiclands.Swamp.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Terror of the Peaks", 149, Rarity.MYTHIC, mage.cards.t.TerrorOfThePeaks.class)); cards.add(new SetCardInfo("The Key to the Vault", 54, Rarity.RARE, mage.cards.t.TheKeyToTheVault.class));