Fixed added searching for exile zone with change zone counter (that's true for tokens from graveyard)
@@ -106,15 +106,29 @@ class ReturnExiledPermanentsEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null) {
+ ExileZone exile = getExileIfPossible(game, source);
+ if (exile != null) {
+ return controller.moveCards(new LinkedHashSet<>(exile.getCards(game)), Zone.BATTLEFIELD, source, game, false, false, true, null);
+ }
+ }
+ return false;
+ }
+
+ private ExileZone getExileIfPossible(final Game game, final Ability source) {
UUID exileZone = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
+
if (exileZone != null) {
ExileZone exile = game.getExile().getExileZone(exileZone);
- if (exile != null) {
- controller.moveCards(new LinkedHashSet<>(exile.getCards(game)), Zone.BATTLEFIELD, source, game, false, false, true, null);
+ if (exile == null) {
+ // try without ZoneChangeCounter - that is useful for tokens
+ exileZone = CardUtil.getCardExileZoneId(game, source);
+ if (exileZone != null) {
+ return game.getExile().getExileZone(exileZone);
}
- return true;
}
+ return exile;
}
- return false;
+
+ return null;
}
}
