diff --git a/Mage.Sets/src/mage/cards/l/LightPawsEmperorsVoice.java b/Mage.Sets/src/mage/cards/l/LightPawsEmperorsVoice.java index 07cfe7d7ddd..f477729d9bc 100644 --- a/Mage.Sets/src/mage/cards/l/LightPawsEmperorsVoice.java +++ b/Mage.Sets/src/mage/cards/l/LightPawsEmperorsVoice.java @@ -74,7 +74,7 @@ enum LightPawsEmperorsVoicePredicate implements Predicate { class LightPawsEmperorsVoiceEffect extends OneShotEffect { - private static enum LightPawsEmperorsVoiceEffectPredicate implements ObjectSourcePlayerPredicate { + private enum LightPawsEmperorsVoiceEffectPredicate implements ObjectSourcePlayerPredicate { instance; private static final FilterPermanent filter = new FilterControlledPermanent(SubType.AURA); diff --git a/Mage.Sets/src/mage/cards/m/MirrorOfLifeTrapping.java b/Mage.Sets/src/mage/cards/m/MirrorOfLifeTrapping.java new file mode 100644 index 00000000000..8e6e36841d4 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MirrorOfLifeTrapping.java @@ -0,0 +1,112 @@ +package mage.cards.m; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SetTargetPointer; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicate; +import mage.game.ExileZone; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.stack.Spell; +import mage.players.Player; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author xenohedron + */ +public final class MirrorOfLifeTrapping extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("a creature"); + static { + filter.add(MirrorOfLifeTrappingCastPredicate.instance); + } + + public MirrorOfLifeTrapping(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); + + // Whenever a creature enters, if it was cast, exile it, then return all other permanent cards exiled with Mirror of Life Trapping to the battlefield under their owners' control. + this.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new MirrorOfLifeTrappingEffect(), + filter, false, SetTargetPointer.PERMANENT)); + } + + private MirrorOfLifeTrapping(final MirrorOfLifeTrapping card) { + super(card); + } + + @Override + public MirrorOfLifeTrapping copy() { + return new MirrorOfLifeTrapping(this); + } +} + +enum MirrorOfLifeTrappingCastPredicate implements Predicate { + instance; + + @Override + public boolean apply(Permanent input, Game game) { + int zcc = input.getZoneChangeCounter(game); + Spell spell = game.getStack().getSpell(input.getId()); + return (spell != null && spell.getZoneChangeCounter(game) == zcc - 1) + || game.getLastKnownInformation(input.getId(), Zone.STACK, zcc - 1) != null; + } +} + +class MirrorOfLifeTrappingEffect extends OneShotEffect { + + MirrorOfLifeTrappingEffect() { + super(Outcome.Benefit); + this.staticText = "exile it, then return all other permanent cards exiled with {this} to the battlefield under their owners' control"; + } + + private MirrorOfLifeTrappingEffect(final MirrorOfLifeTrappingEffect effect) { + super(effect); + } + + @Override + public MirrorOfLifeTrappingEffect copy() { + return new MirrorOfLifeTrappingEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller == null || sourceObject == null) { + return false; + } + + UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); + ExileZone exileZone = game.getExile().getExileZone(exileZoneId); + + Cards toBattlefield = null; + if (exileZone != null && !exileZone.isEmpty()) { + toBattlefield = new CardsImpl(exileZone); + } + + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (permanent != null) { + controller.moveCardsToExile(permanent, source, game, true, exileZoneId, sourceObject.getIdName()); + } + + if (toBattlefield != null) { + game.processAction(); + controller.moveCards(toBattlefield.getCards(StaticFilters.FILTER_CARD_PERMANENT, game), + Zone.BATTLEFIELD, source, game, false, true, true, null); + } + + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index 504c284a888..da21969f229 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -404,6 +404,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Minsc & Boo, Timeless Heroes", 285, Rarity.MYTHIC, mage.cards.m.MinscBooTimelessHeroes.class)); cards.add(new SetCardInfo("Minthara, Merciless Soul", 286, Rarity.UNCOMMON, mage.cards.m.MintharaMercilessSoul.class)); cards.add(new SetCardInfo("Mirror Entity", 701, Rarity.RARE, mage.cards.m.MirrorEntity.class)); + cards.add(new SetCardInfo("Mirror of Life Trapping", 326, Rarity.RARE, mage.cards.m.MirrorOfLifeTrapping.class)); cards.add(new SetCardInfo("Mizzium Mortars", 803, Rarity.RARE, mage.cards.m.MizziumMortars.class)); cards.add(new SetCardInfo("Mocking Doppelganger", 667, Rarity.RARE, mage.cards.m.MockingDoppelganger.class)); cards.add(new SetCardInfo("Modify Memory", 83, Rarity.UNCOMMON, mage.cards.m.ModifyMemory.class));