Fixed possible NPE during handling of choosing start player (Fixes #317).

This commit is contained in:
LevelX2 2013-09-12 12:50:14 +02:00
parent 8b67be6e65
commit c6e4df60ba

View file

@ -624,22 +624,21 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
TargetPlayer targetPlayer = new TargetPlayer(); TargetPlayer targetPlayer = new TargetPlayer();
targetPlayer.setRequired(true); targetPlayer.setRequired(true);
targetPlayer.setTargetName("starting player"); targetPlayer.setTargetName("starting player");
Player choosingPlayer; Player choosingPlayer = null;
if (choosingPlayerId == null) { if (choosingPlayerId != null) {
choosingPlayer = getPlayer(pickChoosingPlayer());
}
else {
choosingPlayer = this.getPlayer(choosingPlayerId); choosingPlayer = this.getPlayer(choosingPlayerId);
} }
if (choosingPlayer.choose(Outcome.Benefit, targetPlayer, null, this)) { if (choosingPlayer == null) {
choosingPlayer = getPlayer(pickChoosingPlayer());
}
if (choosingPlayer != null && choosingPlayer.choose(Outcome.Benefit, targetPlayer, null, this)) {
startingPlayerId = ((List<UUID>)targetPlayer.getTargets()).get(0); startingPlayerId = ((List<UUID>)targetPlayer.getTargets()).get(0);
fireInformEvent(state.getPlayer(startingPlayerId).getName() + " will start"); fireInformEvent(state.getPlayer(startingPlayerId).getName() + " will start");
} } else {
else { // not possible to choose starting player, stop here
return; return;
} }
//saveState();
//20091005 - 103.3 //20091005 - 103.3
for (UUID playerId: state.getPlayerList(startingPlayerId)) { for (UUID playerId: state.getPlayerList(startingPlayerId)) {