diff --git a/Mage/src/mage/abilities/common/delayed/OnLeaveReturnExiledToBattlefieldAbility.java b/Mage/src/mage/abilities/common/delayed/OnLeaveReturnExiledToBattlefieldAbility.java index 62e9404457..e632bc96f7 100644 --- a/Mage/src/mage/abilities/common/delayed/OnLeaveReturnExiledToBattlefieldAbility.java +++ b/Mage/src/mage/abilities/common/delayed/OnLeaveReturnExiledToBattlefieldAbility.java @@ -27,13 +27,12 @@ */ package mage.abilities.common.delayed; -import java.util.LinkedList; +import java.util.LinkedHashSet; import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.Zone; @@ -50,9 +49,9 @@ import mage.util.CardUtil; * Returns the exiled cards/permanents as source leaves battlefield * * Uses no stack + * * @author LevelX2 */ - public class OnLeaveReturnExiledToBattlefieldAbility extends DelayedTriggeredAbility { public OnLeaveReturnExiledToBattlefieldAbility() { @@ -108,22 +107,12 @@ class ReturnExiledPermanentsEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (sourceObject != null && controller != null) { - int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() -1; + int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1; UUID exileZone = CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter); if (exileZone != null) { ExileZone exile = game.getExile().getExileZone(exileZone); if (exile != null) { - LinkedList cards = new LinkedList<>(exile); - for (UUID cardId : cards) { - Card card = game.getCard(cardId); - if (card != null) { - Player owner = game.getPlayer(card.getOwnerId()); - if (owner != null && owner.isInGame()) { - owner.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); - } - } - } - exile.clear(); + controller.moveCards(new LinkedHashSet<>(exile.getCards(game)), Zone.EXILED, source, game, false, false, true, null); } return true; } diff --git a/Mage/src/mage/abilities/effects/common/ReturnFromExileForSourceEffect.java b/Mage/src/mage/abilities/effects/common/ReturnFromExileForSourceEffect.java index 181bb35f94..8d7b8a7c2b 100644 --- a/Mage/src/mage/abilities/effects/common/ReturnFromExileForSourceEffect.java +++ b/Mage/src/mage/abilities/effects/common/ReturnFromExileForSourceEffect.java @@ -30,7 +30,6 @@ package mage.abilities.effects.common; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.constants.Outcome; import mage.constants.Zone; import static mage.constants.Zone.BATTLEFIELD; @@ -102,16 +101,7 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect { } ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter)); if (exile != null) { // null is valid if source left battlefield before enters the battlefield effect resolved - if (returnToZone.equals(Zone.BATTLEFIELD)) { - for (Card card : exile.getCards(game)) { - Player owner = game.getPlayer(card.getOwnerId()); - if (owner != null) { - owner.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); - } - } - } else { - controller.moveCards(exile, Zone.EXILED, returnToZone, source, game); - } + controller.moveCards(exile, null, returnToZone, source, game); } return true; } diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index fe56815b05..d00471867c 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -644,7 +644,8 @@ public interface Player extends MageItem, Copyable { * @param tapped tha cards are tapped on the battlefield * @param faceDown the cards are face down in the to zone * @param byOwner the card is moved (or put onto battlefield) by the owner - * of the card (instead of the controller of the source) + * of the card and if target zone is battlefield controlls the permanent + * (instead of the controller of the source) * @return */ boolean moveCards(Set cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, ArrayList appliedEffects); diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index f1efe5d330..49e8ffb656 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -3015,13 +3015,7 @@ public abstract class PlayerImpl implements Player, Serializable { } break; case BATTLEFIELD: - for (Card card : cards) { - fromZone = game.getState().getZone(card.getId()); - if (putOntoBattlefieldWithInfo(card, game, fromZone, source == null ? null : source.getSourceId(), false, card.isFaceDown(game))) { - successfulMovedCards.add(card); - } - } - break; + return moveCards(cards, toZone, source, game, false, false, false, null); case LIBRARY: for (Card card : cards) { fromZone = game.getState().getZone(card.getId());