throw new IllegalArgumentException("'client' was null");
}
Game game = findGame(gameId);
if (game == null) {
sender.send(new JoinGameResponseMessage(ResponseType.failed));
return null;
}
synchronized (game) {
int clientElopoints = AuthenticationService.getPlayer(
sender.getUserName()).getElopoints() - 500;
if ((clientElopoints < game.getMinEloPoints() && game.getMinEloPoints() != 0)
|| (clientElopoints > game.getMaxEloPoints() && game.getMaxEloPoints() != 0)) {
sender.send(new JoinGameResponseMessage(ResponseType.failed));
return null;
}
if (game.getPasswort().length() > 0) {
if (!game.getPasswort().equals(Passwort)) {
sender
.send(new JoinGameResponseMessage(
ResponseType.failed));
return null;
}
}
if ((game.canClientJoin()) && (game.check4Multi(sender.getIPAddress(), sender.getMACAddress()))) {
sender.send(new JoinGameResponseMessage(ResponseType.ok));
this.clients.remove(sender);
game.newClient(sender);
} else {
sender.send(new JoinGameResponseMessage(ResponseType.failed));
return null;
}
}
sendAll(playersMessage());