diff --git a/Mage.Sets/src/mage/cards/v/VisionsOfRuin.java b/Mage.Sets/src/mage/cards/v/VisionsOfRuin.java new file mode 100644 index 00000000000..de41c1c2d23 --- /dev/null +++ b/Mage.Sets/src/mage/cards/v/VisionsOfRuin.java @@ -0,0 +1,94 @@ +package mage.cards.v; + +import mage.abilities.Ability; +import mage.abilities.costs.costadjusters.CommanderManaValueAdjuster; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.FlashbackAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.TreasureToken; +import mage.players.Player; +import mage.target.TargetPermanent; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class VisionsOfRuin extends CardImpl { + + public VisionsOfRuin(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{R}"); + + // Each opponent sacrifices an artifact. For each artifact sacrificed this way, you create a Treasure token. + this.getSpellAbility().addEffect(new VisionsOfRuinEffect()); + + // Flashback {8}{R}{R}. This spell costs {X} less to cast this way, where X is the greatest mana value of a commander you own on the battlefield or in the command zone. + this.addAbility(new FlashbackAbility(this, new ManaCostsImpl<>("{8}{R}{R}")) + .setAbilityName("This spell costs {X} less to cast this way, where X is the greatest mana value " + + "of a commander you own on the battlefield or in the command zone.") + .setCostAdjuster(CommanderManaValueAdjuster.instance)); + } + + private VisionsOfRuin(final VisionsOfRuin card) { + super(card); + } + + @Override + public VisionsOfRuin copy() { + return new VisionsOfRuin(this); + } +} + +class VisionsOfRuinEffect extends OneShotEffect { + + VisionsOfRuinEffect() { + super(Outcome.Benefit); + staticText = "each opponent sacrifices an artifact. For each artifact sacrificed this way, you create a Treasure token"; + } + + private VisionsOfRuinEffect(final VisionsOfRuinEffect effect) { + super(effect); + } + + @Override + public VisionsOfRuinEffect copy() { + return new VisionsOfRuinEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Set permanents = new HashSet<>(); + for (UUID playerId : game.getOpponents(source.getControllerId())) { + Player opponent = game.getPlayer(playerId); + if (opponent == null || game.getBattlefield().count( + StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, + source.getSourceId(), playerId, game + ) < 1) { + continue; + } + TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT); + target.setNotTarget(true); + opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + permanents.add(game.getPermanent(target.getFirstTarget())); + } + int sacrificed = 0; + for (Permanent permanent : permanents) { + if (permanent != null && permanent.sacrifice(source, game)) { + sacrificed++; + } + } + if (sacrificed > 0) { + new TreasureToken().putOntoBattlefield(sacrificed, game, source, source.getControllerId()); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/MidnightHuntCommander.java b/Mage.Sets/src/mage/sets/MidnightHuntCommander.java index 0ca1d956f09..a6590be0891 100644 --- a/Mage.Sets/src/mage/sets/MidnightHuntCommander.java +++ b/Mage.Sets/src/mage/sets/MidnightHuntCommander.java @@ -145,6 +145,7 @@ public final class MidnightHuntCommander extends ExpansionSet { cards.add(new SetCardInfo("Visions of Dominance", 37, Rarity.RARE, mage.cards.v.VisionsOfDominance.class)); cards.add(new SetCardInfo("Visions of Duplicity", 33, Rarity.RARE, mage.cards.v.VisionsOfDuplicity.class)); cards.add(new SetCardInfo("Visions of Glory", 32, Rarity.RARE, mage.cards.v.VisionsOfGlory.class)); + cards.add(new SetCardInfo("Visions of Ruin", 36, Rarity.RARE, mage.cards.v.VisionsOfRuin.class)); cards.add(new SetCardInfo("Wild Beastmaster", 146, Rarity.RARE, mage.cards.w.WildBeastmaster.class)); cards.add(new SetCardInfo("Wilhelt, the Rotcleaver", 2, Rarity.MYTHIC, mage.cards.w.WilheltTheRotcleaver.class)); cards.add(new SetCardInfo("Yavimaya Elder", 147, Rarity.COMMON, mage.cards.y.YavimayaElder.class));