Fixed NPE on playerList.getNext usage

This commit is contained in:
Oleg Agafonov 2020-08-25 23:38:51 +04:00
parent f1d2d2fb22
commit 6fa4c0b8f2
7 changed files with 19 additions and 11 deletions

View file

@ -1234,25 +1234,28 @@ public class Combat implements Serializable, Copyable<Combat> {
Player attackingPlayer = game.getPlayer(attackingPlayerId);
if (attackingPlayer != null) {
PlayerList players;
Player opponent;
switch (game.getAttackOption()) {
case LEFT:
players = game.getState().getPlayerList(attackingPlayerId);
while (attackingPlayer.isInGame()) {
Player opponent = players.getNext(game, false);
opponent = players.getNext(game, false);
while (opponent != null && attackingPlayer.isInGame()) {
if (attackingPlayer.hasOpponent(opponent.getId(), game)) {
attackablePlayers.add(opponent.getId());
break;
}
opponent = players.getNext(game, false);
}
break;
case RIGHT:
players = game.getState().getPlayerList(attackingPlayerId);
opponent = players.getPrevious(game);
while (attackingPlayer.isInGame()) {
Player opponent = players.getPrevious(game);
if (attackingPlayer.hasOpponent(opponent.getId(), game)) {
attackablePlayers.add(opponent.getId());
break;
}
opponent = players.getPrevious(game);
}
break;
case MULTIPLE: