* Pyxis of Pandemonium - Fixed that the exiled permanents were not put to battlefield.

This commit is contained in:
LevelX2 2015-03-24 16:55:53 +01:00
parent 2a9af5ad99
commit 7f3ffbb7ed
2 changed files with 19 additions and 9 deletions

View file

@ -97,10 +97,10 @@ class PyxisOfPandemoniumExileEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
Map<String, UUID> exileIds; Map<String, UUID> exileIds;
String valueKey = CardUtil.getCardZoneString("exileIds", source.getSourceId(), game); String valueKey = CardUtil.getObjectZoneString("exileIds", sourceObject, game);
Object object = game.getState().getValue(valueKey); Object object = game.getState().getValue(valueKey);
if (object != null && object instanceof Map) { if (object != null && object instanceof Map) {
exileIds = (Map<String, UUID>) object; exileIds = (Map<String, UUID>) object;
@ -114,9 +114,8 @@ class PyxisOfPandemoniumExileEffect extends OneShotEffect {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
if (player.getLibrary().size() > 0) { if (player.getLibrary().size() > 0) {
Card card = player.getLibrary().removeFromTop(game); Card card = player.getLibrary().getFromTop(game);
String exileKey = playerId.toString() + CardUtil.getObjectExileZoneId(game, sourceObject).toString();
String exileKey = new StringBuilder(playerId.toString()).append(CardUtil.getCardExileZoneId(game, source)).toString();
UUID exileId = exileIds.get(exileKey); UUID exileId = exileIds.get(exileKey);
if (exileId == null) { if (exileId == null) {
exileId = UUID.randomUUID(); exileId = UUID.randomUUID();
@ -154,9 +153,10 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
Map<String, UUID> exileIds; Map<String, UUID> exileIds;
String valueKey = CardUtil.getCardZoneString("exileIds", source.getSourceId(), game); String valueKey = CardUtil.getObjectZoneString("exileIds", sourceObject, game);
Object object = game.getState().getValue(valueKey); Object object = game.getState().getValue(valueKey);
if (object != null && object instanceof Map) { if (object != null && object instanceof Map) {
exileIds = (Map<String, UUID>) object; exileIds = (Map<String, UUID>) object;
@ -167,13 +167,13 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect {
for (UUID playerId : controller.getInRange()) { for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { 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); UUID exileId = exileIds.get(exileKey);
if (exileId != null) { if (exileId != null) {
ExileZone exileZone = game.getState().getExile().getExileZone(exileId); ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
if (exileZone != null) { if (exileZone != null) {
for(Card card: exileZone.getCards(game)) { for(Card card: exileZone.getCards(game)) {
// card.setFaceDown(false, game); card.setFaceDown(false, game);
if (CardUtil.isPermanentCard(card)) { if (CardUtil.isPermanentCard(card)) {
player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId());
} }

View file

@ -531,6 +531,16 @@ public class CardUtil {
return getObjectZoneString(text,cardId, game, zoneChangeCounter, previous); 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) { public static String getObjectZoneString(String text, UUID objectId, Game game, int zoneChangeCounter, boolean previous) {
StringBuilder uniqueString = new StringBuilder(); StringBuilder uniqueString = new StringBuilder();
if (text != null) { if (text != null) {