diff --git a/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java b/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java index 4045b5f7ef..1daa693699 100644 --- a/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java +++ b/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java @@ -97,10 +97,10 @@ class PyxisOfPandemoniumExileEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); + MageObject sourceObject = source.getSourceObject(game); if (sourceObject != null && controller != null) { Map exileIds; - String valueKey = CardUtil.getCardZoneString("exileIds", source.getSourceId(), game); + String valueKey = CardUtil.getObjectZoneString("exileIds", sourceObject, game); Object object = game.getState().getValue(valueKey); if (object != null && object instanceof Map) { exileIds = (Map) object; @@ -114,9 +114,8 @@ class PyxisOfPandemoniumExileEffect extends OneShotEffect { Player player = game.getPlayer(playerId); if (player != null) { if (player.getLibrary().size() > 0) { - Card card = player.getLibrary().removeFromTop(game); - - String exileKey = new StringBuilder(playerId.toString()).append(CardUtil.getCardExileZoneId(game, source)).toString(); + Card card = player.getLibrary().getFromTop(game); + String exileKey = playerId.toString() + CardUtil.getObjectExileZoneId(game, sourceObject).toString(); UUID exileId = exileIds.get(exileKey); if (exileId == null) { exileId = UUID.randomUUID(); @@ -154,9 +153,10 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null) { Map exileIds; - String valueKey = CardUtil.getCardZoneString("exileIds", source.getSourceId(), game); + String valueKey = CardUtil.getObjectZoneString("exileIds", sourceObject, game); Object object = game.getState().getValue(valueKey); if (object != null && object instanceof Map) { exileIds = (Map) object; @@ -167,13 +167,13 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect { for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); if (player != null) { - String exileKey = new StringBuilder(playerId.toString()).append(CardUtil.getCardExileZoneId(game, source)).toString(); + String exileKey = playerId.toString() + CardUtil.getObjectExileZoneId(game, sourceObject).toString(); UUID exileId = exileIds.get(exileKey); if (exileId != null) { ExileZone exileZone = game.getState().getExile().getExileZone(exileId); if (exileZone != null) { for(Card card: exileZone.getCards(game)) { -// card.setFaceDown(false, game); + card.setFaceDown(false, game); if (CardUtil.isPermanentCard(card)) { player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); } diff --git a/Mage/src/mage/util/CardUtil.java b/Mage/src/mage/util/CardUtil.java index 2343f1fe1b..34e65f7980 100644 --- a/Mage/src/mage/util/CardUtil.java +++ b/Mage/src/mage/util/CardUtil.java @@ -531,6 +531,16 @@ public class CardUtil { return getObjectZoneString(text,cardId, game, zoneChangeCounter, previous); } + public static String getObjectZoneString(String text, MageObject mageObject, Game game) { + int zoneChangeCounter = 0; + if (mageObject instanceof Permanent) { + zoneChangeCounter = ((Permanent) mageObject).getZoneChangeCounter(); + } else if (mageObject instanceof Card) { + zoneChangeCounter = ((Card) mageObject).getZoneChangeCounter(); + } + return getObjectZoneString(text, mageObject.getId(), game, zoneChangeCounter, false); + } + public static String getObjectZoneString(String text, UUID objectId, Game game, int zoneChangeCounter, boolean previous) { StringBuilder uniqueString = new StringBuilder(); if (text != null) {