diff --git a/Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java b/Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java index f3c21cbf941..4964fb93945 100644 --- a/Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java +++ b/Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java @@ -4,20 +4,16 @@ package mage.cards.s; import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; +import mage.abilities.dynamicvalue.common.CreaturesDiedThisTurnCount; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CreateTokenEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.WatcherScope; -import mage.constants.Zone; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.ZoneChangeEvent; import mage.game.permanent.token.SpoilsOfBloodHorrorToken; import mage.players.Player; -import mage.watchers.Watcher; /** * @@ -26,11 +22,10 @@ import mage.watchers.Watcher; public final class SpoilsOfBlood extends CardImpl { public SpoilsOfBlood(UUID ownerId, CardSetInfo setInfo) { - super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{B}"); + super(ownerId, setInfo, new CardType[] { CardType.INSTANT }, "{B}"); // Create an X/X black Horror creature token, where X is the number of creatures that died this turn. this.getSpellAbility().addEffect(new SpoilsOfBloodEffect()); - this.getSpellAbility().addWatcher(new CreaturesDiedThisTurnWatcher()); } private SpoilsOfBlood(final SpoilsOfBlood card) { @@ -58,10 +53,9 @@ class SpoilsOfBloodEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - CreaturesDiedThisTurnWatcher watcher = game.getState().getWatcher(CreaturesDiedThisTurnWatcher.class); - if (watcher != null) { - new CreateTokenEffect(new SpoilsOfBloodHorrorToken(watcher.getCreaturesDiedThisTurn())).apply(game, source); - } + new CreateTokenEffect( + new SpoilsOfBloodHorrorToken(CreaturesDiedThisTurnCount.instance.calculate(game, source, this))) + .apply(game, source); return true; } return false; @@ -72,34 +66,4 @@ class SpoilsOfBloodEffect extends OneShotEffect { return new SpoilsOfBloodEffect(this); } -} - -class CreaturesDiedThisTurnWatcher extends Watcher { - - public int getCreaturesDiedThisTurn() { - return creaturesDiedThisTurn; - } - - private int creaturesDiedThisTurn = 0; - - public CreaturesDiedThisTurnWatcher() { - super(WatcherScope.GAME); - } - - @Override - public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) { - MageObject mageObject = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); - if (mageObject != null && mageObject.isCreature(game)) { - creaturesDiedThisTurn++; - } - } - } - - @Override - public void reset() { - super.reset(); - creaturesDiedThisTurn = 0; - } - -} +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/s/SpymastersVault.java b/Mage.Sets/src/mage/cards/s/SpymastersVault.java new file mode 100644 index 00000000000..b3ea8ded696 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SpymastersVault.java @@ -0,0 +1,95 @@ +package mage.cards.s; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.condition.Condition; +import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.dynamicvalue.common.CreaturesDiedThisTurnCount; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.TapSourceEffect; +import mage.abilities.effects.keyword.ConniveSourceEffect; +import mage.abilities.mana.BlackManaAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.ComparisonType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledPermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.common.TargetControlledCreaturePermanent; + +/** + * + * @author grimreap124 + */ +public final class SpymastersVault extends CardImpl { + + private static final FilterPermanent filter = new FilterControlledPermanent(SubType.SWAMP); + private static final Condition condition = new PermanentsOnTheBattlefieldCondition(filter, ComparisonType.EQUAL_TO, + 0); + + public SpymastersVault(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[] { CardType.LAND }, ""); + + // Spymaster's Vault enters the battlefield tapped unless you control a Swamp. + this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect( + new TapSourceEffect(), condition), "tapped unless you control a Swamp")); + + // {T}: Add {B}. + this.addAbility(new BlackManaAbility()); + // {B}, {T}: Target creature you control connives X, where X is the number of creatures that died this turn. + Ability ability = new SimpleActivatedAbility(new SpymastersVaultEffect(), new ManaCostsImpl<>("{B}")); + ability.addCost(new TapSourceCost()); + ability.addTarget(new TargetControlledCreaturePermanent()); + this.addAbility(ability.addHint(CreaturesDiedThisTurnCount.getHint())); + + } + + private SpymastersVault(final SpymastersVault card) { + super(card); + } + + @Override + public SpymastersVault copy() { + return new SpymastersVault(this); + } +} + +class SpymastersVaultEffect extends OneShotEffect { + + SpymastersVaultEffect() { + super(Outcome.Benefit); + staticText = "Target creature you control connives X, where X is the number of creatures that died this turn"; + } + + private SpymastersVaultEffect(final SpymastersVaultEffect effect) { + super(effect); + } + + @Override + public SpymastersVaultEffect copy() { + return new SpymastersVaultEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + int deaths = CreaturesDiedThisTurnCount.instance.calculate(game, source, this); + + if (deaths < 1) { + return false; + } + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (permanent == null) { + return false; + } + return ConniveSourceEffect.connive(permanent, deaths, source, game); + } +} diff --git a/Mage.Sets/src/mage/sets/ModernHorizons3.java b/Mage.Sets/src/mage/sets/ModernHorizons3.java index d0330eecf67..b954035deed 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons3.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons3.java @@ -221,6 +221,7 @@ public final class ModernHorizons3 extends ExpansionSet { cards.add(new SetCardInfo("Sowing Mycospawn", 170, Rarity.RARE, mage.cards.s.SowingMycospawn.class)); cards.add(new SetCardInfo("Spawn-Gang Commander", 140, Rarity.UNCOMMON, mage.cards.s.SpawnGangCommander.class)); cards.add(new SetCardInfo("Springheart Nantuko", 171, Rarity.RARE, mage.cards.s.SpringheartNantuko.class)); + cards.add(new SetCardInfo("Spymaster's Vault", 230, Rarity.RARE, mage.cards.s.SpymastersVault.class)); cards.add(new SetCardInfo("Static Prison", 44, Rarity.UNCOMMON, mage.cards.s.StaticPrison.class)); cards.add(new SetCardInfo("Strength of the Harvest", 258, Rarity.UNCOMMON, mage.cards.s.StrengthOfTheHarvest.class)); cards.add(new SetCardInfo("Strix Serenade", 71, Rarity.RARE, mage.cards.s.StrixSerenade.class)); diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesDiedThisTurnCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesDiedThisTurnCount.java index d5b3fb0b137..016b5eb9f01 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesDiedThisTurnCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesDiedThisTurnCount.java @@ -4,6 +4,8 @@ package mage.abilities.dynamicvalue.common; import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.Effect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; import mage.game.Game; import mage.watchers.common.CreaturesDiedWatcher; @@ -13,6 +15,12 @@ import mage.watchers.common.CreaturesDiedWatcher; public enum CreaturesDiedThisTurnCount implements DynamicValue { instance; + private static final Hint hint = new ValueHint("Number of creatures that died this turn", instance); + + public static Hint getHint() { + return hint; + } + @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { CreaturesDiedWatcher watcher = game.getState().getWatcher(CreaturesDiedWatcher.class);