From 3d53311663b59e7936c376fd8653aad0d3d01452 Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Tue, 12 Jan 2021 20:28:41 +0100 Subject: [PATCH] Fix Karn Liberated leaving emblems + phased out --- .../game/ability/effects/RestartGameEffect.java | 14 ++++++++++++-- .../src/main/java/forge/game/player/Player.java | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/effects/RestartGameEffect.java b/forge-game/src/main/java/forge/game/ability/effects/RestartGameEffect.java index 38275f3f961..46e74baceb2 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/RestartGameEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/RestartGameEffect.java @@ -33,20 +33,30 @@ public class RestartGameEffect extends SpellAbilityEffect { // Don't grab Ante Zones List restartZones = new ArrayList<>(Arrays.asList(ZoneType.Battlefield, - ZoneType.Library, ZoneType.Graveyard, ZoneType.Hand, ZoneType.Exile, ZoneType.Command)); + ZoneType.Library, ZoneType.Graveyard, ZoneType.Hand, ZoneType.Exile)); ZoneType leaveZone = ZoneType.smartValueOf(sa.hasParam("RestrictFromZone") ? sa.getParam("RestrictFromZone") : null); restartZones.remove(leaveZone); String leaveRestriction = sa.hasParam("RestrictFromValid") ? sa.getParam("RestrictFromValid") : "Card"; for (Player p : players) { - CardCollection newLibrary = new CardCollection(p.getCardsIn(restartZones)); + CardCollection newLibrary = new CardCollection(p.getCardsIn(restartZones, false)); List filteredCards = null; if (leaveZone != null) { filteredCards = CardLists.filter(p.getCardsIn(leaveZone), CardPredicates.restriction(leaveRestriction.split(","), p, sa.getHostCard(), null)); newLibrary.addAll(filteredCards); } + + // special handling for Karn to filter out non-cards + CardCollection cmdCards = new CardCollection(p.getCardsIn(ZoneType.Command)); + for (Card c : cmdCards) { + if (c.isCommander()) { + newLibrary.add(c); + } + } + p.getZone(ZoneType.Command).removeAllCards(true); + playerLibraries.put(p, newLibrary); } diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index f7a202d4702..acf40a3489e 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -1512,9 +1512,12 @@ public class Player extends GameEntity implements Comparable { * gets a list of all cards in a given player's requested zones. */ public final CardCollectionView getCardsIn(final Iterable zones) { + return getCardsIn(zones, true); + } + public final CardCollectionView getCardsIn(final Iterable zones, boolean filterOutPhasedOut) { final CardCollection result = new CardCollection(); for (final ZoneType z : zones) { - result.addAll(getCardsIn(z)); + result.addAll(getCardsIn(z, filterOutPhasedOut)); } return result; }