Fix Karn Liberated leaving emblems + phased out

This commit is contained in:
tool4EvEr
2021-01-12 20:28:41 +01:00
parent bce2c3da24
commit 3d53311663
2 changed files with 16 additions and 3 deletions

View File

@@ -33,20 +33,30 @@ public class RestartGameEffect extends SpellAbilityEffect {
// Don't grab Ante Zones
List<ZoneType> 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<Card> 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);
}

View File

@@ -1512,9 +1512,12 @@ public class Player extends GameEntity implements Comparable<Player> {
* gets a list of all cards in a given player's requested zones.
*/
public final CardCollectionView getCardsIn(final Iterable<ZoneType> zones) {
return getCardsIn(zones, true);
}
public final CardCollectionView getCardsIn(final Iterable<ZoneType> zones, boolean filterOutPhasedOut) {
final CardCollection result = new CardCollection();
for (final ZoneType z : zones) {
result.addAll(getCardsIn(z));
result.addAll(getCardsIn(z, filterOutPhasedOut));
}
return result;
}