From 2592fed6efbcae926e1c93815e02195bf5923887 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 19 Sep 2022 08:48:10 -0400 Subject: [PATCH] [DMC] Implemented Tobias, Doomed Conqueror --- .../mage/cards/t/TobiasDoomedConqueror.java | 127 ++++++++++++++++++ .../mage/sets/DominariaUnitedCommander.java | 1 + 2 files changed, 128 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TobiasDoomedConqueror.java diff --git a/Mage.Sets/src/mage/cards/t/TobiasDoomedConqueror.java b/Mage.Sets/src/mage/cards/t/TobiasDoomedConqueror.java new file mode 100644 index 0000000000..0c7a636c89 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TobiasDoomedConqueror.java @@ -0,0 +1,127 @@ +package mage.cards.t; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.DiesSourceTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.abilities.keyword.FlashAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.constants.WatcherScope; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.PermanentToken; +import mage.game.permanent.token.ZombieToken; +import mage.util.CardUtil; +import mage.watchers.Watcher; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TobiasDoomedConqueror extends CardImpl { + + private static final Hint hint = new ValueHint( + "Nontoken creatures that died under your control", TobiasDoomedConquerorValue.instance + ); + + public TobiasDoomedConqueror(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{U}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.SOLDIER); + this.power = new MageInt(3); + this.toughness = new MageInt(2); + + // Flash + this.addAbility(FlashAbility.getInstance()); + + // When Tobias, Doomed Conqueror dies, create a 2/2 black Zombie creature token for each nontoken creature that died under your control this turn. + this.addAbility(new DiesSourceTriggeredAbility(new CreateTokenEffect( + new ZombieToken(), TobiasDoomedConquerorValue.instance + )).addHint(hint), new TobiasDoomedConquerorWatcher()); + } + + private TobiasDoomedConqueror(final TobiasDoomedConqueror card) { + super(card); + } + + @Override + public TobiasDoomedConqueror copy() { + return new TobiasDoomedConqueror(this); + } +} + +enum TobiasDoomedConquerorValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + return TobiasDoomedConquerorWatcher.getCount(sourceAbility, game); + } + + @Override + public TobiasDoomedConquerorValue copy() { + return this; + } + + @Override + public String getMessage() { + return "nontoken creature that died under your control this turn"; + } + + @Override + public String toString() { + return "1"; + } +} + +class TobiasDoomedConquerorWatcher extends Watcher { + + private final Map playerMap = new HashMap<>(); + + TobiasDoomedConquerorWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() != GameEvent.EventType.ZONE_CHANGE) { + return; + } + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + if (!zEvent.isDiesEvent() + || zEvent.getTarget() == null + || !zEvent.getTarget().isCreature(game) + || zEvent.getTarget() instanceof PermanentToken) { + return; + } + playerMap.compute(zEvent.getTarget().getControllerId(), CardUtil::setOrIncrementValue); + } + + @Override + public void reset() { + super.reset(); + playerMap.clear(); + } + + static int getCount(Ability source, Game game) { + return game + .getState() + .getWatcher(TobiasDoomedConquerorWatcher.class) + .playerMap + .getOrDefault(source.getControllerId(), 0); + } +} diff --git a/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java b/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java index 224ee79c3b..ee759b1185 100644 --- a/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java +++ b/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java @@ -192,6 +192,7 @@ public final class DominariaUnitedCommander extends ExpansionSet { cards.add(new SetCardInfo("The Reaver Cleaver", 84, Rarity.RARE, mage.cards.t.TheReaverCleaver.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Thrill of Possibility", 127, Rarity.COMMON, mage.cards.t.ThrillOfPossibility.class)); cards.add(new SetCardInfo("Time Wipe", 173, Rarity.RARE, mage.cards.t.TimeWipe.class)); + cards.add(new SetCardInfo("Tobias, Doomed Conqueror", 45, Rarity.UNCOMMON, mage.cards.t.TobiasDoomedConqueror.class)); cards.add(new SetCardInfo("Transguild Courier", 194, Rarity.UNCOMMON, mage.cards.t.TransguildCourier.class)); cards.add(new SetCardInfo("Traxos, Scourge of Kroog", 195, Rarity.RARE, mage.cards.t.TraxosScourgeOfKroog.class)); cards.add(new SetCardInfo("Two-Headed Hellkite", 14, Rarity.RARE, mage.cards.t.TwoHeadedHellkite.class));