Fix client only launching app on terminal view
This commit is contained in:
parent
b08139ebca
commit
f73dfc8bb9
@ -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 {
|
InstantiationException, IllegalAccessException {
|
||||||
List<Player> players = parsePlayers();
|
List<Player> players = parsePlayers();
|
||||||
game = new Game(new Grid(12, 12, players), players);
|
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, lambda.createViewLambda(player)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ public class App extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) {
|
public void start(Stage stage) {
|
||||||
try {
|
try {
|
||||||
startGame();
|
startGame(player -> new Window(stage, game, player));
|
||||||
} catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException | InstantiationException
|
} catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException | InstantiationException
|
||||||
| IllegalAccessException e) {
|
| IllegalAccessException e) {
|
||||||
throw new CrashException(e.getMessage(), e);
|
throw new CrashException(e.getMessage(), e);
|
||||||
@ -62,7 +62,7 @@ public class App extends Application {
|
|||||||
|
|
||||||
public static void launchTerminal() {
|
public static void launchTerminal() {
|
||||||
try {
|
try {
|
||||||
startGame();
|
startGame(player -> new Terminal(game, player));
|
||||||
} catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException | InstantiationException
|
} catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException | InstantiationException
|
||||||
| IllegalAccessException e) {
|
| IllegalAccessException e) {
|
||||||
throw new CrashException(e.getMessage(), e);
|
throw new CrashException(e.getMessage(), e);
|
||||||
@ -131,6 +131,7 @@ public class App extends Application {
|
|||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("No argument given");
|
throw new IllegalArgumentException("No argument given");
|
||||||
}
|
}
|
||||||
|
System.out.println(clazz.getSimpleName());
|
||||||
return clazz;
|
return clazz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
client/src/main/java/fr/lnl/game/client/ViewLambda.java
Normal file
11
client/src/main/java/fr/lnl/game/client/ViewLambda.java
Normal 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);
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user