From b08139ebcae0f581bfef4144d6cc46d91f43034c Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Sat, 27 Nov 2021 19:20:27 +0100 Subject: [PATCH] Fix NullPointerException in App.java --- client/src/main/java/fr/lnl/game/client/App.java | 2 +- server/src/main/java/fr/lnl/game/server/games/Game.java | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/client/src/main/java/fr/lnl/game/client/App.java b/client/src/main/java/fr/lnl/game/client/App.java index 598f4ef..63edc84 100644 --- a/client/src/main/java/fr/lnl/game/client/App.java +++ b/client/src/main/java/fr/lnl/game/client/App.java @@ -38,10 +38,10 @@ public class App extends Application { public static void startGame() throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { List players = parsePlayers(); + game = new Game(new Grid(12, 12, players), players); for (Player player : game.getPlayers()) { playerList.put(player, new ClientPlayer(player, new Terminal(game, player))); } - game = new Game(new Grid(12, 12, players), players); } public static void updateView() { diff --git a/server/src/main/java/fr/lnl/game/server/games/Game.java b/server/src/main/java/fr/lnl/game/server/games/Game.java index 8fae549..706c439 100644 --- a/server/src/main/java/fr/lnl/game/server/games/Game.java +++ b/server/src/main/java/fr/lnl/game/server/games/Game.java @@ -27,12 +27,8 @@ public class Game { this.currentPlayer = players.get(0); this.grid = grid; } - - /** - * - * @return game winner - */ - public Player play() { + + public void play() { while(!isOver()) { ModelListener awakeEvent = new AwakeGame(this); generateAndGetPlayerActions(currentPlayer); @@ -41,7 +37,6 @@ public class Game { selectedAction.doAction(); nextCurrentPlayer(); } - return getWinner(); } private void waitForInterfaceEvent() {