diff --git a/client/src/main/java/fr/lnl/game/client/listener/ClientEventHandler.java b/client/src/main/java/fr/lnl/game/client/listener/ClientEventHandler.java index 4407ea9..a0f39d2 100644 --- a/client/src/main/java/fr/lnl/game/client/listener/ClientEventHandler.java +++ b/client/src/main/java/fr/lnl/game/client/listener/ClientEventHandler.java @@ -4,9 +4,15 @@ import fr.lnl.game.server.listener.ModelListener; import javafx.event.ActionEvent; import javafx.event.EventHandler; -public record ClientEventHandler( - ModelListener listener) implements EventHandler { +/** + * implementation of a listener from JavaFX {@link EventHandler} + */ +public record ClientEventHandler(ModelListener listener) implements EventHandler { + /** + * This method is call by JavaFX when we click to the button + * @param event event class created when clicking on the element + */ @Override public void handle(ActionEvent event) { listener.updateModel(event); diff --git a/client/src/main/java/fr/lnl/game/client/listener/DisplayWinnerEvent.java b/client/src/main/java/fr/lnl/game/client/listener/DisplayWinnerEvent.java index 0b6dff5..d7a698b 100644 --- a/client/src/main/java/fr/lnl/game/client/listener/DisplayWinnerEvent.java +++ b/client/src/main/java/fr/lnl/game/client/listener/DisplayWinnerEvent.java @@ -4,8 +4,15 @@ import fr.lnl.game.client.App; import fr.lnl.game.server.games.player.Player; import fr.lnl.game.server.listener.AbstractModelListening; +/** + * Used to display the winner of the game + */ public class DisplayWinnerEvent extends AbstractModelListening { + /** + * This method is call when the game is over + * @param obj contains the winner of the game, can be null + */ @Override public void updateModel(Object obj) { Player winner = (Player) obj; diff --git a/client/src/main/java/fr/lnl/game/client/listener/NextPlayerButtonListener.java b/client/src/main/java/fr/lnl/game/client/listener/NextPlayerButtonListener.java index 3bd230c..5c28445 100644 --- a/client/src/main/java/fr/lnl/game/client/listener/NextPlayerButtonListener.java +++ b/client/src/main/java/fr/lnl/game/client/listener/NextPlayerButtonListener.java @@ -7,9 +7,12 @@ import fr.lnl.game.server.listener.AbstractModelListening; import fr.lnl.game.server.listener.ModelListener; import javafx.scene.control.Alert; +/** + * This method is call when the current player have selected an action to play (or if it's a computer player, will + * select it), then we call {@link Game#play()} and we update the view + */ public class NextPlayerButtonListener extends AbstractModelListening { - private final Game game; private final DisplayWinnerEvent displayWinnerEvent; @@ -18,17 +21,10 @@ public class NextPlayerButtonListener extends AbstractModelListening { this.displayWinnerEvent = new DisplayWinnerEvent(); } - @Override - public void addListener(ModelListener e) { - this.listeners.add(e); - } - - @Override - public void removalListener(ModelListener e) { - this.listeners.remove(e); - } - - + /** + * Call when clicking on "SUIVANT" button if current player is a computer player or after the human player selected + * action it want to play + */ @Override public void updateModel(Object event) { // Player player = game.getCurrentPlayer(); diff --git a/client/src/main/java/fr/lnl/game/client/listener/SelectActionButton.java b/client/src/main/java/fr/lnl/game/client/listener/SelectActionButton.java index a4341e2..7e3711d 100644 --- a/client/src/main/java/fr/lnl/game/client/listener/SelectActionButton.java +++ b/client/src/main/java/fr/lnl/game/client/listener/SelectActionButton.java @@ -6,6 +6,9 @@ import fr.lnl.game.server.games.Game; import fr.lnl.game.server.games.action.ReunionSameAction; import fr.lnl.game.server.listener.AbstractModelListening; +/** + * Used when the human player select type of action it want to play + */ public class SelectActionButton extends AbstractModelListening { private final Window window; @@ -18,6 +21,10 @@ public class SelectActionButton extends AbstractModelListening { this.reunionSameAction = reunionSameAction; } + /** + * This method is call when the player select the type of action it want to play + * @param obj contain information about the event like the button where the player clicked + */ @Override public void updateModel(Object obj) { if(reunionSameAction.getActions().size() == 1){ @@ -27,8 +34,5 @@ public class SelectActionButton extends AbstractModelListening { window.setSelectedReunionAction(reunionSameAction); App.getViewManager().updateView(); // update screen } - - - } } diff --git a/client/src/main/java/fr/lnl/game/client/listener/SelectDirectionListener.java b/client/src/main/java/fr/lnl/game/client/listener/SelectDirectionListener.java index e967037..07a3557 100644 --- a/client/src/main/java/fr/lnl/game/client/listener/SelectDirectionListener.java +++ b/client/src/main/java/fr/lnl/game/client/listener/SelectDirectionListener.java @@ -6,6 +6,9 @@ import fr.lnl.game.server.games.action.Action; import fr.lnl.game.server.listener.AbstractModelListening; import fr.lnl.game.server.listener.ModelListener; +/** + * Call when the player selected the direction where it wants to play it + */ public class SelectDirectionListener extends AbstractModelListening { private final Game game; @@ -18,6 +21,10 @@ public class SelectDirectionListener extends AbstractModelListening { this.action = action; } + /** + * This method is call when the player click on the button to select the direction of the previously selected action + * @param obj contain information about the event like the button where the player clicked + */ @Override public void updateModel(Object obj) { game.setSelectedAction(action); diff --git a/client/src/main/java/fr/lnl/game/client/listener/package-info.java b/client/src/main/java/fr/lnl/game/client/listener/package-info.java new file mode 100644 index 0000000..0e9f04f --- /dev/null +++ b/client/src/main/java/fr/lnl/game/client/listener/package-info.java @@ -0,0 +1,4 @@ +/** + * Package that contains every view listeners + */ +package fr.lnl.game.client.listener; \ No newline at end of file