From d8de407f4c11e574e28e0ff01add45da03e6b848 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Sat, 15 Apr 2023 10:20:40 -0400 Subject: [PATCH] [MOM] Implement Sandstalker Moloch --- .../src/mage/cards/s/SandstalkerMoloch.java | 97 +++++++++++++++++++ .../src/mage/sets/MarchOfTheMachine.java | 1 + 2 files changed, 98 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/SandstalkerMoloch.java diff --git a/Mage.Sets/src/mage/cards/s/SandstalkerMoloch.java b/Mage.Sets/src/mage/cards/s/SandstalkerMoloch.java new file mode 100644 index 0000000000..a888b2c54e --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SandstalkerMoloch.java @@ -0,0 +1,97 @@ +package mage.cards.s; + +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.effects.common.LookLibraryAndPickControllerEffect; +import mage.abilities.keyword.FlashAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.PutCards; +import mage.constants.SubType; +import mage.constants.WatcherScope; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.stack.Spell; +import mage.watchers.Watcher; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class SandstalkerMoloch extends CardImpl { + + public SandstalkerMoloch(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{G}"); + + this.subtype.add(SubType.LIZARD); + this.power = new MageInt(4); + this.toughness = new MageInt(2); + + // Flash + this.addAbility(FlashAbility.getInstance()); + + // When Sandstalker Moloch enters the battlefield, if an opponent cast a blue and/or black spell this turn, look at the top four cards of your library. You may reveal a permanent card from among them and put it into your hand. Put the rest on the bottom of your library in a random order. + this.addAbility(new ConditionalInterveningIfTriggeredAbility( + new EntersBattlefieldTriggeredAbility( + new LookLibraryAndPickControllerEffect( + 4, 1, StaticFilters.FILTER_CARD_A_PERMANENT, + PutCards.HAND, PutCards.BOTTOM_RANDOM + ) + ), SandstalkerMolochWatcher::checkPlayer, "When {this} enters the battlefield, " + + "if an opponent cast a blue and/or black spell this turn, look at the top four cards " + + "of your library. You may reveal a permanent card from among them and put it into your hand. " + + "Put the rest on the bottom of your library in a random order." + )); + } + + private SandstalkerMoloch(final SandstalkerMoloch card) { + super(card); + } + + @Override + public SandstalkerMoloch copy() { + return new SandstalkerMoloch(this); + } +} + +class SandstalkerMolochWatcher extends Watcher { + + private final Set players = new HashSet<>(); + private static final ObjectColor color = new ObjectColor("UB"); + + SandstalkerMolochWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() != GameEvent.EventType.SPELL_CAST) { + return; + } + Spell spell = game.getSpell(event.getTargetId()); + if (spell != null && spell.getColor(game).shares(color)) { + players.addAll(game.getOpponents(spell.getControllerId())); + } + } + + @Override + public void reset() { + super.reset(); + } + + static boolean checkPlayer(Game game, Ability source) { + return game + .getState() + .getWatcher(SandstalkerMolochWatcher.class) + .players + .contains(source.getControllerId()); + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index 6aaf01361b..7aab4654b6 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -255,6 +255,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Rugged Highlands", 271, Rarity.COMMON, mage.cards.r.RuggedHighlands.class)); cards.add(new SetCardInfo("Ruins Recluse", 336, Rarity.UNCOMMON, mage.cards.r.RuinsRecluse.class)); cards.add(new SetCardInfo("Saiba Cryptomancer", 76, Rarity.COMMON, mage.cards.s.SaibaCryptomancer.class)); + cards.add(new SetCardInfo("Sandstalker Moloch", 203, Rarity.UNCOMMON, mage.cards.s.SandstalkerMoloch.class)); cards.add(new SetCardInfo("Scorn-Blade Berserker", 124, Rarity.UNCOMMON, mage.cards.s.ScornBladeBerserker.class)); cards.add(new SetCardInfo("Scoured Barrens", 272, Rarity.COMMON, mage.cards.s.ScouredBarrens.class)); cards.add(new SetCardInfo("Scrappy Bruiser", 162, Rarity.UNCOMMON, mage.cards.s.ScrappyBruiser.class));