Fix client only launching app on terminal view

This commit is contained in:
Quentin Legot 2021-11-29 18:22:21 +01:00
parent b08139ebca
commit f73dfc8bb9
2 changed files with 16 additions and 4 deletions

View File

@ -35,12 +35,12 @@ public class App extends Application {
}
}
public static void startGame() throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
public static void startGame(ViewLambda lambda) throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
InstantiationException, IllegalAccessException {
List<Player> 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)));
playerList.put(player, new ClientPlayer(player, lambda.createViewLambda(player)));
}
}
@ -51,7 +51,7 @@ public class App extends Application {
@Override
public void start(Stage stage) {
try {
startGame();
startGame(player -> new Window(stage, game, player));
} catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException | InstantiationException
| IllegalAccessException e) {
throw new CrashException(e.getMessage(), e);
@ -62,7 +62,7 @@ public class App extends Application {
public static void launchTerminal() {
try {
startGame();
startGame(player -> new Terminal(game, player));
} catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException | InstantiationException
| IllegalAccessException e) {
throw new CrashException(e.getMessage(), e);
@ -131,6 +131,7 @@ public class App extends Application {
} else {
throw new IllegalArgumentException("No argument given");
}
System.out.println(clazz.getSimpleName());
return clazz;
}
}

View File

@ -0,0 +1,11 @@
package fr.lnl.game.client;
import fr.lnl.game.client.view.View;
import fr.lnl.game.server.games.player.Player;
@FunctionalInterface
public interface ViewLambda {
View createViewLambda(Player player);
}