Fixed a bug in FFA games if player has lost and had cards in exile zones causing NPE.

This commit is contained in:
LevelX2 2013-05-22 01:29:53 +02:00
parent c2aa574ea6
commit d6d9420e6e

View file

@ -1536,6 +1536,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
it.remove();
}
}
// Then, if that player controlled any objects on the stack not represented by cards, those objects cease to exist.
this.getState().getContinuousEffects().removeInactiveEffects(this);
for (Iterator<StackObject> it = getStack().iterator(); it.hasNext();) {
StackObject object = it.next();
@ -1543,13 +1544,24 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
it.remove();
}
}
// Then, if there are any objects still controlled by that player, those objects are exiled.
for (Iterator<Permanent> it = getBattlefield().getAllPermanents().iterator(); it.hasNext();) {
Permanent perm = it.next();
if (perm.getControllerId().equals(playerId)) {
perm.moveToExile(null, "", null, this);
}
}
// Remove cards from the player in all exile zones
for (ExileZone exile: this.getExile().getExileZones()) {
for (Iterator<UUID> it = exile.iterator(); it.hasNext();) {
Card card = this.getCard(it.next());
if (card != null && card.getOwnerId().equals(playerId)) {
it.remove();
}
}
}
Iterator it = gameCards.entrySet().iterator();
while(it.hasNext()) {
Entry<UUID,Card> entry = (Entry<UUID,Card>) it.next();