mirror of
https://github.com/correl/mage.git
synced 2025-02-18 03:00:15 +00:00
Fixed NPE on playerList.getNext usage
This commit is contained in:
parent
f1d2d2fb22
commit
6fa4c0b8f2
7 changed files with 19 additions and 11 deletions
|
@ -95,7 +95,7 @@ class EyeOfDoomEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
player = playerList.getNext(game, false);
|
||||
} while (!player.getId().equals(game.getActivePlayerId()));
|
||||
} while (player != null && !player.getId().equals(game.getActivePlayerId()));
|
||||
|
||||
for (Permanent permanent : permanents) {
|
||||
permanent.addCounters(CounterType.DOOM.createInstance(), source, game);
|
||||
|
|
|
@ -71,7 +71,7 @@ class TariffEffect extends OneShotEffect {
|
|||
do {
|
||||
processPlayer(game, source, player);
|
||||
player = playerList.getNext(game, false);
|
||||
} while (!player.getId().equals(game.getActivePlayerId()));
|
||||
} while (player != null && !player.getId().equals(game.getActivePlayerId()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class TemptWithReflectionsEffect extends OneShotEffect {
|
|||
game.informPlayers((player.getLogName() + decision + permanent.getName()));
|
||||
}
|
||||
player = playerList.getNext(game, false);
|
||||
} while (!player.getId().equals(game.getActivePlayerId()));
|
||||
} while (player != null && !player.getId().equals(game.getActivePlayerId()));
|
||||
|
||||
for (UUID playerId : playersSaidYes) {
|
||||
effect = new CreateTokenCopyTargetEffect(playerId);
|
||||
|
|
|
@ -77,8 +77,8 @@ class ThievesAuctionEffect extends OneShotEffect {
|
|||
// Starting with you, each player
|
||||
PlayerList playerList = game.getState().getPlayersInRange(controller.getId(), game);
|
||||
Player player = playerList.getCurrent(game);
|
||||
while (!exiledCards.isEmpty() && !game.hasEnded()) {
|
||||
if (player != null && player.canRespond()) {
|
||||
while (player != null && !exiledCards.isEmpty() && !game.hasEnded()) {
|
||||
if (player.canRespond()) {
|
||||
// chooses one of the exiled cards
|
||||
TargetCard target = new TargetCardInExile(new FilterCard());
|
||||
if (player.choose(Outcome.PutCardInPlay, exiledCards, target, game)) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class MtgJsonCard {
|
|||
if ("transform".equals(layout)
|
||||
|| "flip".equals(layout)
|
||||
|| "adventure".equals(layout)
|
||||
|| "meld".equals(layout)) { // TODO: remove or keep after mtgjson's meld bug resolve https://github.com/mtgjson/mtgjson/issues/661
|
||||
|| "meld".equals(layout)) { // mtgjson uses composite names for meld cards, but scryfall uses simple face names
|
||||
return faceName;
|
||||
}
|
||||
return asciiName != null ? asciiName : name;
|
||||
|
|
|
@ -796,7 +796,9 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
break;
|
||||
}
|
||||
playerByOrder = playerList.getNext(this, true);
|
||||
state.setPlayerByOrderId(playerByOrder.getId());
|
||||
if (playerByOrder != null) {
|
||||
state.setPlayerByOrderId(playerByOrder.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (checkIfGameIsOver() && !isSimulation()) {
|
||||
|
@ -902,7 +904,10 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
state.getTurn().resumePlay(this, wasPaused);
|
||||
if (!isPaused() && !checkIfGameIsOver()) {
|
||||
endOfTurn();
|
||||
player = playerList.getNext(this, true);
|
||||
Player nextPlayer = playerList.getNext(this, true);
|
||||
if (nextPlayer != null) {
|
||||
player = nextPlayer;
|
||||
}
|
||||
state.setTurnNum(state.getTurnNum() + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue