diff --git a/Mage.Sets/src/mage/cards/d/DetentionSphere.java b/Mage.Sets/src/mage/cards/d/DetentionSphere.java index aabef80c95..835f494d8c 100644 --- a/Mage.Sets/src/mage/cards/d/DetentionSphere.java +++ b/Mage.Sets/src/mage/cards/d/DetentionSphere.java @@ -33,7 +33,7 @@ import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.LeavesBattlefieldTriggeredAbility; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; +import mage.abilities.effects.common.ReturnFromExileForSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -48,8 +48,8 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPermanent; - - +import mage.util.CardUtil; +import org.apache.log4j.Logger; /** * @@ -58,13 +58,13 @@ import mage.target.TargetPermanent; public class DetentionSphere extends CardImpl { static final protected FilterPermanent filter = new FilterNonlandPermanent("nonland permanent not named Detention Sphere"); + static { filter.add(Predicates.not(new NamePredicate("Detention Sphere"))); } public DetentionSphere(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{W}{U}"); - + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}{U}"); // When Detention Sphere enters the battlefield, you may exile // target nonland permanent not named Detention Sphere and all @@ -73,7 +73,6 @@ public class DetentionSphere extends CardImpl { ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); - // When Detention Sphere leaves the battlefield, return the exiled // cards to the battlefield under their owner's control. this.addAbility(new LeavesBattlefieldTriggeredAbility(new DetentionSphereLeavesEffect(), false)); @@ -91,7 +90,6 @@ public class DetentionSphere extends CardImpl { class DetentionSphereEntersEffect extends OneShotEffect { - public DetentionSphereEntersEffect() { super(Outcome.Exile); staticText = "you may exile target nonland permanent not named Detention Sphere and all other permanents with the same name as that permanent"; @@ -103,7 +101,7 @@ class DetentionSphereEntersEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - UUID exileId = source.getSourceId(); + UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); @@ -143,15 +141,18 @@ class DetentionSphereLeavesEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - UUID exileId = source.getSourceId(); - ExileZone exile = game.getExile().getExileZone(exileId); - if (exile != null) { - exile = exile.copy(); - for (UUID cardId : exile) { - Card card = game.getCard(cardId); - card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), card.getOwnerId()); + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (sourceObject != null && controller != null) { + Permanent permanentLeftBattlefield = (Permanent) getValue("permanentLeftBattlefield"); + if (permanentLeftBattlefield == null) { + Logger.getLogger(ReturnFromExileForSourceEffect.class).error("Permanent not found: " + sourceObject.getName()); + return false; + } + ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), permanentLeftBattlefield.getZoneChangeCounter(game))); + if (exile != null) { + controller.moveCards(exile.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null); } - game.getExile().getExileZone(exileId).clear(); return true; } return false; @@ -161,4 +162,4 @@ class DetentionSphereLeavesEffect extends OneShotEffect { public DetentionSphereLeavesEffect copy() { return new DetentionSphereLeavesEffect(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/p/PortalMage.java b/Mage.Sets/src/mage/cards/p/PortalMage.java index 0d311349b8..7fa82ce8f2 100644 --- a/Mage.Sets/src/mage/cards/p/PortalMage.java +++ b/Mage.Sets/src/mage/cards/p/PortalMage.java @@ -68,11 +68,11 @@ public class PortalMage extends CardImpl { // Flash this.addAbility(FlashAbility.getInstance()); - // If Portal Mage enters the battlefield during the declare attackers step, you may reselect the player or planeswalker that the target attacking creature attacks. + // When Portal Mage enters the battlefield during the declare attackers step, you may reselect which player or planeswalker target attacking creature is attacking. Ability ability = new ConditionalTriggeredAbility( new EntersBattlefieldTriggeredAbility(new PortalMageEffect(), true), new IsStepCondition(PhaseStep.DECLARE_ATTACKERS, false), - "If {this} enters the battlefield during the declare attackers step, you may reselect the player or planeswalker that the target attacking creature attacks. " + "When {this} enters the battlefield during the declare attackers step, you may reselect which player or planeswalker target attacking creature is attacking. " + "(It can't attack its controller or its controller's planeswalkers.)"); ability.addTarget(new TargetCreaturePermanent(new FilterAttackingCreature())); this.addAbility(ability); @@ -92,7 +92,7 @@ class PortalMageEffect extends OneShotEffect { public PortalMageEffect() { super(Outcome.Benefit); - this.staticText = "you may reselect the player or planeswalker that the target attacking creature attacks"; + this.staticText = "you may reselect which player or planeswalker target attacking creature is attacking"; } public PortalMageEffect(final PortalMageEffect effect) { @@ -147,7 +147,7 @@ class PortalMageEffect extends OneShotEffect { attacked = permanent.getLogName(); } } - game.informPlayers(attackingCreature.getLogName() + " attacks now " + attacked); + game.informPlayers(attackingCreature.getLogName() + " now attacks " + attacked); return true; } }