Fix NullPointerException in App.java

This commit is contained in:
Quentin Legot 2021-11-27 19:20:27 +01:00
parent 9cfa56be8d
commit b08139ebca
2 changed files with 3 additions and 8 deletions

View File

@ -38,10 +38,10 @@ public class App extends Application {
public static void startGame() throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException, public static void startGame() throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
InstantiationException, IllegalAccessException { InstantiationException, IllegalAccessException {
List<Player> players = parsePlayers(); List<Player> players = parsePlayers();
game = new Game(new Grid(12, 12, players), players);
for (Player player : game.getPlayers()) { for (Player player : game.getPlayers()) {
playerList.put(player, new ClientPlayer(player, new Terminal(game, player))); playerList.put(player, new ClientPlayer(player, new Terminal(game, player)));
} }
game = new Game(new Grid(12, 12, players), players);
} }
public static void updateView() { public static void updateView() {

View File

@ -27,12 +27,8 @@ public class Game {
this.currentPlayer = players.get(0); this.currentPlayer = players.get(0);
this.grid = grid; this.grid = grid;
} }
/** public void play() {
*
* @return game winner
*/
public Player play() {
while(!isOver()) { while(!isOver()) {
ModelListener awakeEvent = new AwakeGame(this); ModelListener awakeEvent = new AwakeGame(this);
generateAndGetPlayerActions(currentPlayer); generateAndGetPlayerActions(currentPlayer);
@ -41,7 +37,6 @@ public class Game {
selectedAction.doAction(); selectedAction.doAction();
nextCurrentPlayer(); nextCurrentPlayer();
} }
return getWinner();
} }
private void waitForInterfaceEvent() { private void waitForInterfaceEvent() {