Game: fixed empty range error on game startup

This commit is contained in:
Oleg Agafonov 2021-07-24 05:36:56 +04:00
parent 18687fe197
commit d41ccd11bc
2 changed files with 6 additions and 0 deletions

View file

@ -313,6 +313,11 @@ public class GameController implements GameCallback {
private synchronized void startGame() { private synchronized void startGame() {
if (gameFuture == null) { if (gameFuture == null) {
// workaround to fill range info (cause real range fills after game start, but users must get start event with game data already)
for (Player player : game.getPlayers().values()) {
player.updateRange(game);
}
for (GameSessionPlayer gameSessionPlayer : getGameSessions()) { for (GameSessionPlayer gameSessionPlayer : getGameSessions()) {
gameSessionPlayer.init(); gameSessionPlayer.init();
} }

View file

@ -495,6 +495,7 @@ public abstract class PlayerImpl implements Player, Serializable {
public void updateRange(Game game) { public void updateRange(Game game) {
// 20100423 - 801.2c // 20100423 - 801.2c
// 801.2c The particular players within each players range of influence are determined as each turn begins. // 801.2c The particular players within each players range of influence are determined as each turn begins.
// BUT it also uses before game start to fill game and card data in starting game events
inRange.clear(); inRange.clear();
inRange.add(this.playerId); inRange.add(this.playerId);
inRange.addAll(getAllNearPlayers(game, true)); inRange.addAll(getAllNearPlayers(game, true));