From 1b556e5ac8bf5da6c784c3549756a84b2df0eed6 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Thu, 9 Dec 2021 16:30:11 +0100 Subject: [PATCH] add javadoc to client.listener --- .../client/listener/ClientEventHandler.java | 10 ++++++++-- .../client/listener/DisplayWinnerEvent.java | 7 +++++++ .../listener/NextPlayerButtonListener.java | 20 ++++++++----------- .../client/listener/SelectActionButton.java | 10 +++++++--- .../listener/SelectDirectionListener.java | 7 +++++++ .../game/client/listener/package-info.java | 4 ++++ 6 files changed, 41 insertions(+), 17 deletions(-) create mode 100644 client/src/main/java/fr/lnl/game/client/listener/package-info.java 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