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 c93c1e5..1d0fc7b 100644 --- a/client/src/main/java/fr/lnl/game/client/App.java +++ b/client/src/main/java/fr/lnl/game/client/App.java @@ -50,6 +50,17 @@ public class App extends Application { } } + /** + * Parse players arguments and create a new instance of Game + * @throws IllegalArgumentException when given argument is unknown + * @throws InvocationTargetException when the creation of the player throw an exception + * @throws NoSuchMethodException when constructor with given parameter in {@link Class#getConstructor(Class[])} + * doesn't exist + * @throws InstantiationException when the instanciation of the player is impossible (like when class is abstract), + * is probably never called + * @throws IllegalAccessException when the instanciation of thr player is impossible (like a private constructor), + * is probably never called + */ public static void startGame() throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { List players = parsePlayers(); @@ -80,6 +91,17 @@ public class App extends Application { viewManager.run(); } + /** + * Parse players arguments and create instances for each player + * @throws IllegalArgumentException when given argument is unknown + * @throws InvocationTargetException when the creation of the player throw an exception + * @throws NoSuchMethodException when constructor with given parameter in {@link Class#getConstructor(Class[])} + * doesn't exist + * @throws InstantiationException when the instanciation of the player is impossible (like when class is abstract), + * is probably never called + * @throws IllegalAccessException when the instanciation of thr player is impossible (like a private constructor), + * is probably never called + */ public static List parsePlayers() throws IllegalArgumentException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { List playerList = new ArrayList<>(); @@ -129,6 +151,17 @@ public class App extends Application { return playerList; } + /** + * create a new instance of the player + * @throws IllegalArgumentException when given argument is unknown (probably never called in production) + * @throws InvocationTargetException when the creation of the player throw an exception + * @throws NoSuchMethodException when constructor with given parameter in {@link Class#getConstructor(Class[])} + * doesn't exist + * @throws InstantiationException when the instanciation of the player is impossible (like when class is abstract), + * is probably never called + * @throws IllegalAccessException when the instanciation of thr player is impossible (like a private constructor), + * is probably never called + */ private static Player createNewPlayer(Class playerClass, ClassPlayer playerType, int playerListSize) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { @@ -136,7 +169,12 @@ public class App extends Application { .newInstance(playerListSize, null, playerType); } - public static Class parseView() { + /** + * Parse the first argument given by user to know the view to use (Terminal or Window) + * @return The class of the View to use + * @throws IllegalArgumentException when given argument is unknown or no argument is given by user + */ + public static Class parseView() throws IllegalArgumentException { Class clazz; if(!argsList.isEmpty()) { if(argsList.get(0).equals("terminal")) { diff --git a/client/src/main/java/fr/lnl/game/client/ClientPlayer.java b/client/src/main/java/fr/lnl/game/client/ClientPlayer.java index 6206ab5..6195714 100644 --- a/client/src/main/java/fr/lnl/game/client/ClientPlayer.java +++ b/client/src/main/java/fr/lnl/game/client/ClientPlayer.java @@ -3,6 +3,9 @@ package fr.lnl.game.client; import fr.lnl.game.client.view.View; import fr.lnl.game.server.games.player.Player; +/** + * Store a view per player + */ public record ClientPlayer(Player serverPlayer, View view) { public Player getServerPlayer() { diff --git a/client/src/main/java/fr/lnl/game/client/ViewLambda.java b/client/src/main/java/fr/lnl/game/client/ViewLambda.java index df8f544..284bde6 100644 --- a/client/src/main/java/fr/lnl/game/client/ViewLambda.java +++ b/client/src/main/java/fr/lnl/game/client/ViewLambda.java @@ -3,9 +3,17 @@ package fr.lnl.game.client; import fr.lnl.game.client.view.View; import fr.lnl.game.server.games.player.Player; +/** + * Used as Lambda expression to instantiate a {@link View} per {@link Player} stored in {@link ClientPlayer} + */ @FunctionalInterface public interface ViewLambda { + /** + * A lambda create an anonymous class which implements this interface + * @param player an instance of {@link Player} to store in {@link View} + * @return an instance of view (depending on the first argument when launching the program) + */ View createViewLambda(Player player); } diff --git a/client/src/main/java/fr/lnl/game/client/package-info.java b/client/src/main/java/fr/lnl/game/client/package-info.java new file mode 100644 index 0000000..3ade71c --- /dev/null +++ b/client/src/main/java/fr/lnl/game/client/package-info.java @@ -0,0 +1,4 @@ +/** + * Client package + */ +package fr.lnl.game.client; \ No newline at end of file diff --git a/server/src/main/java/fr/lnl/game/server/package-info.java b/server/src/main/java/fr/lnl/game/server/package-info.java new file mode 100644 index 0000000..2a0d095 --- /dev/null +++ b/server/src/main/java/fr/lnl/game/server/package-info.java @@ -0,0 +1,4 @@ +/** + * Server package + */ +package fr.lnl.game.server; \ No newline at end of file