mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Fixed miss code for reversed turn order (see Aeon Engine, #8804)
This commit is contained in:
parent
182f9ae2c7
commit
94dc91d8e1
2 changed files with 14 additions and 8 deletions
|
@ -200,6 +200,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
this.commandersToStay.addAll(state.commandersToStay);
|
||||
this.hasDayNight = state.hasDayNight;
|
||||
this.isDaytime = state.isDaytime;
|
||||
this.reverseTurnOrder = state.reverseTurnOrder;
|
||||
}
|
||||
|
||||
public void clearOnGameRestart() {
|
||||
|
@ -290,6 +291,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
this.commandersToStay = state.commandersToStay;
|
||||
this.hasDayNight = state.hasDayNight;
|
||||
this.isDaytime = state.isDaytime;
|
||||
this.reverseTurnOrder = state.reverseTurnOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,12 +25,12 @@ public class PlayerList extends CircularList<UUID> {
|
|||
|
||||
public Player getNextInRange(Player basePlayer, Game game) {
|
||||
UUID currentPlayerBefore = this.get();
|
||||
UUID nextPlayerId = super.getNext();
|
||||
UUID nextPlayerId = game.isTurnOrderReversed() ? super.getPrevious() : super.getNext();
|
||||
do {
|
||||
if (basePlayer.getInRange().contains(nextPlayerId)) {
|
||||
return game.getPlayer(nextPlayerId);
|
||||
}
|
||||
nextPlayerId = super.getNext();
|
||||
nextPlayerId = game.isTurnOrderReversed() ? super.getPrevious() : super.getNext();
|
||||
} while (!nextPlayerId.equals(currentPlayerBefore));
|
||||
return null;
|
||||
}
|
||||
|
@ -47,11 +47,7 @@ public class PlayerList extends CircularList<UUID> {
|
|||
}
|
||||
Player player;
|
||||
while (true) {
|
||||
if(game.isTurnOrderReversed()){
|
||||
player = game.getPlayer(super.getPrevious());
|
||||
} else{
|
||||
player = game.getPlayer(super.getNext());
|
||||
}
|
||||
player = getAffectedNext(game);
|
||||
if (player.isInGame()) {
|
||||
break;
|
||||
}
|
||||
|
@ -76,7 +72,7 @@ public class PlayerList extends CircularList<UUID> {
|
|||
return null;
|
||||
}
|
||||
while (true) {
|
||||
player = game.getPlayer(super.getPrevious());
|
||||
player = getAffectedPrevious(game);
|
||||
if (player.isInGame()) {
|
||||
break;
|
||||
}
|
||||
|
@ -88,6 +84,14 @@ public class PlayerList extends CircularList<UUID> {
|
|||
return player;
|
||||
}
|
||||
|
||||
private Player getAffectedNext(Game game) {
|
||||
return game.isTurnOrderReversed() ? game.getPlayer(super.getPrevious()) : game.getPlayer(super.getNext());
|
||||
}
|
||||
|
||||
private Player getAffectedPrevious(Game game) {
|
||||
return game.isTurnOrderReversed() ? game.getPlayer(super.getNext()) : game.getPlayer(super.getPrevious());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerList copy() {
|
||||
return new PlayerList(this);
|
||||
|
|
Loading…
Reference in a new issue