Fixed freeze and npe error while disconnects on choose target dialog;

This commit is contained in:
Oleg Agafonov 2019-03-10 15:53:53 +04:00
parent 188de12592
commit b432b4b431

View file

@ -269,14 +269,20 @@ public abstract class TargetImpl implements Target {
@Override @Override
public boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Game game) { public boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Game game) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
while (!isChosen() && !doneChosing()) { if (player != null) {
chosen = targets.size() >= getNumberOfTargets(); while (!isChosen() && !doneChosing()) {
if (!player.choose(outcome, this, sourceId, game)) { if (!player.canRespond()) {
return chosen; return chosen = targets.size() >= getNumberOfTargets();
}
chosen = targets.size() >= getNumberOfTargets();
if (!player.choose(outcome, this, sourceId, game)) {
return chosen;
}
chosen = targets.size() >= getNumberOfTargets();
} }
chosen = targets.size() >= getNumberOfTargets(); return chosen = true;
} }
return chosen = true; return false;
} }
@Override @Override