add javadoc to client.listener
This commit is contained in:
parent
fb408a3f78
commit
1b556e5ac8
@ -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<ActionEvent> {
|
||||
/**
|
||||
* implementation of a listener from JavaFX {@link EventHandler}
|
||||
*/
|
||||
public record ClientEventHandler(ModelListener listener) implements EventHandler<ActionEvent> {
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Package that contains every view listeners
|
||||
*/
|
||||
package fr.lnl.game.client.listener;
|
Loading…
Reference in New Issue
Block a user