diff --git a/Projekte/jme-common/src/main/java/pp/dialog/DialogManager.java b/Projekte/jme-common/src/main/java/pp/dialog/DialogManager.java index ab4ea16..44364aa 100644 --- a/Projekte/jme-common/src/main/java/pp/dialog/DialogManager.java +++ b/Projekte/jme-common/src/main/java/pp/dialog/DialogManager.java @@ -192,6 +192,11 @@ public class DialogManager { dialogStack.peek().escape(); } + /** + * Updates all dialogs in the dialog stack. + * + * @param delta the time since the last update + */ public void update(float delta) { for (Dialog dialog : dialogStack) dialog.update(delta); diff --git a/Projekte/jme-common/src/main/java/pp/dialog/PopupDialog.java b/Projekte/jme-common/src/main/java/pp/dialog/PopupDialog.java index 7bc3d63..82bbae0 100644 --- a/Projekte/jme-common/src/main/java/pp/dialog/PopupDialog.java +++ b/Projekte/jme-common/src/main/java/pp/dialog/PopupDialog.java @@ -1,5 +1,10 @@ package pp.dialog; +/** An interface for tagging Dialogs as PopUps for handling in the DialogManager */ public interface PopupDialog { + + /** + * Shows the popup. + */ void show(); } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/BoardAppState.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/BoardAppState.java index e970544..98760ae 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/BoardAppState.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/BoardAppState.java @@ -69,8 +69,14 @@ public class BoardAppState extends MonopolyAppState { */ private PopUpManager popUpManager; + /** + * The camera controller for managing the camera's position and orientation. + */ private CameraController cameraController; + /** + * The input handler for controlling the camera's movement and rotation. + */ private CameraInputHandler cameraInputHandler; @@ -251,7 +257,7 @@ public class BoardAppState extends MonopolyAppState { rotation.fromAngleAxis(FastMath.HALF_PI, Vector3f.UNIT_Y); seaGeo.setLocalRotation(rotation); final Material seaMat = new Material(getApp().getAssetManager(), "Common/MatDefs/Light/Lighting.j3md"); - Texture texture = getApp().getAssetManager().loadTexture("Pictures/board2.png"); + Texture texture = getApp().getAssetManager().loadTexture(BoardTexture); seaMat.setTexture("DiffuseMap", texture); seaGeo.setMaterial(seaMat); seaGeo.setShadowMode(ShadowMode.CastAndReceive); @@ -261,9 +267,13 @@ public class BoardAppState extends MonopolyAppState { sceneNode.attachChild(seaGeo); // Schneefall hinzufügen - // addSnowEffect(sceneNode); + addSnowEffect(sceneNode); } + /** + * Creates a card deck with six event and six community cards. + * @return the node containing the card deck + */ private Node createCardDeck() { Node cardDeck = new Node("cardDeck"); @@ -304,6 +314,10 @@ public class BoardAppState extends MonopolyAppState { return cardDeck; } + /** + * Adds a snow effect to the scene by creating a particle emitter with snowflakes. + * @param parentNode the parent node to attach the snow effect to + */ private void addSnowEffect(Node parentNode) { // ParticleEmitter für Schnee ParticleEmitter snowEmitter = new ParticleEmitter("Snow", ParticleMesh.Type.Triangle, 5000); @@ -332,7 +346,12 @@ public class BoardAppState extends MonopolyAppState { // Emitter zur Szene hinzufügen parentNode.attachChild(snowEmitter); } - + + /** + * Updates the state by moving the camera and updating the visual elements. + * + * @param tpf the time per frame + */ @Override public void update(float tpf) { super.update(tpf); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameSound.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameSound.java index 55175df..91d907f 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameSound.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/GameSound.java @@ -48,16 +48,27 @@ public class GameSound extends AbstractAppState implements GameEventListener { */ private static final String VOLUME_PREF = "volume"; //NON-NLS + /** The sound effect for passing the start field. */ private AudioNode passStartSound; + /** The sound effect for drawing an event card. */ private AudioNode eventCardSound; + /** The sound effect for going to the gulag. */ private AudioNode gulagSound; + /** The sound effect for rolling the dice. */ private AudioNode diceRollSound; + /** The sound effect for collecting money. */ private AudioNode moneyCollectSound; + /** The sound effect for losing money. */ private AudioNode moneyLostSound; + /** The sound effect for accepting a trade. */ private AudioNode tradeAcceptedSound; + /** The sound effect for rejecting a trade. */ private AudioNode tradeRejectedSound; + /** The sound effect for winning the game. */ private AudioNode winnerSound; + /** The sound effect for loosing the game. */ private AudioNode looserSound; + /** The sound effect for pressing a button. */ private AudioNode buttonSound; /** diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java index 056d71b..0391804 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java @@ -172,16 +172,19 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga private AppSettings makeSettings() { final AppSettings settings = new AppSettings(true); settings.setTitle(lookup("monopoly.name")); - try { - // Prüfen, ob das Betriebssystem ein Mac-System ist - if (!System.getProperty("os.name").toLowerCase().contains("mac")) { - settings.setIcons(new Image[]{ImageIO.read(new File("src/main/resources/icons/Uniman.png"))}); - } else { - LOGGER.log(Level.INFO, "Icon setting skipped on macOS due to system restrictions."); - } - } catch (IOException e) { - LOGGER.log(Level.ERROR, e.getMessage()); - } + + // Set the icon for the application window + + // try { + // // Prüfen, ob das Betriebssystem ein Mac-System ist + // if (!System.getProperty("os.name").toLowerCase().contains("mac")) { + // settings.setIcons(new Image[]{ImageIO.read(new File("src/main/resources/icons/Uniman.png"))}); + // } else { + // LOGGER.log(Level.INFO, "Icon setting skipped on macOS due to system restrictions."); + // } + // } catch (IOException e) { + // LOGGER.log(Level.ERROR, e.getMessage()); + // } settings.setResolution(config.getResolutionWidth(), config.getResolutionHeight()); settings.setFullscreen(config.fullScreen()); settings.setUseRetinaFrameBuffer(config.useRetinaFrameBuffer()); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/PopUpManager.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/PopUpManager.java index d16ac1e..20a9912 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/PopUpManager.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/PopUpManager.java @@ -27,15 +27,32 @@ import pp.monopoly.notification.EventCardEvent; import pp.monopoly.notification.GameEventListener; import pp.monopoly.notification.PopUpEvent; +/** + * This class is responsible for managing the popups that are shown to the user. + * It listens for events that require a popup to be shown and then shows the + * appropriate popup. + */ public class PopUpManager implements GameEventListener { + /** The MonopolyApp instance */ private final MonopolyApp app; + /** + * Constructor for the PopUpManager. + * + * @param app The MonopolyApp instance + */ public PopUpManager(MonopolyApp app) { this.app = app; app.getGameLogic().addListener(this); } + /** + * This method is called when a PopUpEvent is received. + * It checks the message of the event and shows the appropriate popup. + * + * @param event The PopUpEvent + */ @Override public void receivedEvent(PopUpEvent event) { if (event.msg().equals("Buy")) { @@ -84,6 +101,12 @@ public class PopUpManager implements GameEventListener { } } + /** + * This method is called when an EventCardEvent is received. + * It shows the EventCardPopup. + * + * @param event The EventCardEvent + */ @Override public void receivedEvent(EventCardEvent event) { Timer timer = new Timer(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BobTheBuilder.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BobTheBuilder.java index 7dd6106..7977596 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BobTheBuilder.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BobTheBuilder.java @@ -17,18 +17,35 @@ import pp.monopoly.model.Figure; import pp.monopoly.model.Hotel; import pp.monopoly.model.House; import pp.monopoly.model.Item; -import pp.monopoly.notification.UpdatePlayerView; +/** + * The {@code BobTheBuilder} class is responsible for synchronizing the graphical + * representation of the figures and buildings on the board with the underlying data model. + * It extends the {@link GameBoardSynchronizer} to provide specific synchronization + * logic for the board. + */ public class BobTheBuilder extends GameBoardSynchronizer { + /** The String representing the path to the unshaded material*/ private static final String UNSHADED = "Common/MatDefs/Misc/Unshaded.j3md"; //NON-NLS + /** The String representing the color parameter in the material*/ private static final String COLOR = "Color"; //NON-NLS + /** The String representing the figure node*/ private static final String FIGURE = "figure"; //NON-NLS + /** The String representing the house node*/ private static final String HOUSE = "house"; //NON-NLS + /** The String representing the hotel node*/ private static final String HOTEL = "hotel"; //NON-NLS + /** The {@link MonopolyApp} instance*/ private final MonopolyApp app; + /** + * Creates a new {@code BobTheBuilder} instance with the specified {@link MonopolyApp} and root node. + * + * @param app the {@link MonopolyApp} instance + * @param root the root node of the scene graph + */ public BobTheBuilder(MonopolyApp app, Node root) { super(app.getGameLogic().getBoard(), root); this.app = app; @@ -83,16 +100,33 @@ public class BobTheBuilder extends GameBoardSynchronizer { return node; } + /** + * Creates a new spatial to represent the specified figure. + * + * @param figure the figure to be represented + * @return the geometry representing the figure + */ private Spatial createFigure(Figure figure) { - // Lade das Modell - Spatial model = app.getAssetManager().loadModel("models/" + "Spielfiguren/" + figure.getType() + "/" + figure.getType() + ".j3o"); + Spatial model; - // Skaliere und positioniere das Modell - model.scale(0.5f); + try { + // Lade das Modell + model = app.getAssetManager().loadModel("models/" + "Spielfiguren/" + figure.getType() + "/" + figure.getType() + ".j3o"); + + // Skaliere und positioniere das Modell + model.scale(0.5f); + } catch (Exception e) { + model = createBox(figure); + } return model; } + /** + * Creates a new spatial to represent the specified hotel. + * @param hotel the hotel to be represented + * @return the geometry representing the hotel + */ private Spatial createHotel(Hotel hotel) { Spatial model = app.getAssetManager().loadModel("models/Hotel/Hotel.j3o"); model.scale(0.2f); @@ -100,7 +134,11 @@ public class BobTheBuilder extends GameBoardSynchronizer { return model; } - + /** + * Creates a new spatial to represent the specified house. + * @param house the house to be represented + * @return the geometry representing the house + */ private Spatial createHouse(House house) { Spatial model = app.getAssetManager().loadModel("models/Haus/"+house.getStage()+"Haus.j3o"); model.scale(0.5f); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java index 3e6d134..5e85581 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/BuildingAdminMenu.java @@ -191,9 +191,6 @@ public class BuildingAdminMenu extends Dialog { app.getGuiNode().attachChild(background); } - /** - * Closes the building administration menu and detaches its elements from the GUI. - */ @Override public void close() { app.getGuiNode().detachChild(mainContainer); @@ -201,21 +198,8 @@ public class BuildingAdminMenu extends Dialog { super.close(); } - /** - * Opens the settings menu when the escape key is pressed. - */ @Override public void escape() { new SettingsMenu(app).open(); } - - /** - * Periodic updates for the menu, if required. - * - * @param delta Time since the last update in seconds. - */ - @Override - public void update(float delta) { - // Periodic updates if necessary - } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraController.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraController.java index c4154c8..722169b 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraController.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraController.java @@ -3,25 +3,39 @@ package pp.monopoly.client.gui; import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; -import pp.monopoly.client.MonopolyApp; // Import MonopolyApp +import pp.monopoly.client.MonopolyApp; import pp.monopoly.game.server.PlayerHandler; import pp.monopoly.notification.GameEventListener; import pp.monopoly.notification.UpdatePlayerView; +/** + * Represents a camera controller for the Monopoly application. + */ public class CameraController implements GameEventListener{ + /** + * Enum representing the camera mode for the CameraController. + */ public enum CameraMode { FOCUS_CURRENT_PLAYER, FOCUS_SELF, FREECAM } + /** The camera to control */ private final Camera camera; + /** The current camera mode */ private CameraMode currentMode; + /** The player handler instance */ + private PlayerHandler playerHandler; + /** The {@link MonopolyApp} instance*/ + private final MonopolyApp app; - private PlayerHandler playerHandler; // Reference to PlayerHandler for player data - private final MonopolyApp app; // Reference to MonopolyApp for self ID - + /** + * Constructs a new CameraController instance. + * @param camera The camera to control + * @param app The MonopolyApp instance + */ public CameraController(Camera camera, MonopolyApp app) { this.camera = camera; this.playerHandler = app.getGameLogic().getPlayerHandler(); @@ -30,10 +44,28 @@ public class CameraController implements GameEventListener{ setMode(CameraMode.FOCUS_SELF); // Initialize the camera mode } + /** + * Sets the camera mode to the specified mode. + * @param mode The camera mode to set + */ public void setMode(CameraMode mode) { this.currentMode = mode; } + /** + * Updates the camera behavior based on the current mode and the time-per-frame (tpf). + *

+ * This method checks the current mode of the camera and updates its position or behavior accordingly. + * Supported modes include: + *

+ * + * @param tpf The time-per-frame value, typically provided by the game engine, + * which represents the elapsed time since the last frame. + */ public void update(float tpf) { switch (currentMode) { @@ -53,6 +85,9 @@ public class CameraController implements GameEventListener{ } } + /** + * Updates the camera position depending on the current mode. + */ public void updatePosition() { Vector3f newPosition = getPos(); camera.setLocation(newPosition); @@ -61,6 +96,10 @@ public class CameraController implements GameEventListener{ camera.update(); } + /** + * Returns the position for the camera depending on the current mode. + * @return The position for the camera + */ private Vector3f getPos() { Vector3f pos = new Vector3f(); switch (currentMode) { @@ -83,6 +122,10 @@ public class CameraController implements GameEventListener{ } + /** + * Calculates the offset for the camera depending on the field the player is on. + * @return The offset for the camera + */ private Vector3f getOffset() { Vector3f offset = new Vector3f(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraInputHandler.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraInputHandler.java index db53128..7d71218 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraInputHandler.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraInputHandler.java @@ -5,9 +5,19 @@ import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.KeyTrigger; +/** + * Class to handle the input for the camera. + */ public class CameraInputHandler { + + /**The camera controller */ private CameraController cameraController; + /** + * Constructor for the CameraInputHandler. + * @param cameraController The camera controller. + * @param inputManager The input manager. + */ public CameraInputHandler(CameraController cameraController, InputManager inputManager) { this.cameraController = cameraController; @@ -19,6 +29,9 @@ public class CameraInputHandler { inputManager.addListener(actionListener, "FocusCurrentPlayer", "FocusSelf", "FreeCam"); } + /** + * ActionListener for the camera. + */ private final ActionListener actionListener = (name, isPressed, tpf) -> { if (!isPressed) return; diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ChoosePartner.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ChoosePartner.java index 452770f..025dc91 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ChoosePartner.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ChoosePartner.java @@ -22,21 +22,34 @@ import pp.monopoly.message.client.ViewAssetsRequest; import pp.monopoly.model.TradeHandler; import pp.monopoly.notification.Sound; +/** + * Dialog for choosing a trade partner. + */ public class ChoosePartner extends Dialog { + /** The {@link MonopolyApp} instance*/ private final MonopolyApp app; + /** Selector for selecting the player */ private Selector playerSelector; + /** Button for cancel*/ private final Button cancelButton = new Button("Abbrechen"); + /** Button for confirm*/ private final Button confirmButton = new Button("Bestätigen"); + /** Main container for the UI components */ private final Container mainContainer; + /** Container for the lower left menu */ private Container lowerLeftMenu; + /** Container for the lower right menu */ private Container lowerRightMenu; + /** The background image */ private Geometry background; + /** The trade handler */ private TradeHandler tradeHandler; - private VersionedReference> selectionRef; // Reference to track selector changes - private String lastSelected = ""; // To keep track of the last selected value - - QuadBackgroundComponent translucentWhiteBackground = - new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f)); + /** Reference to track selector changes */ + private VersionedReference> selectionRef; + /** The last selected value */ + private String lastSelected = ""; + /** The translucent white background */ + private QuadBackgroundComponent translucentWhiteBackground = new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f)); /** * Constructs the ChoosePartner dialog. @@ -169,9 +182,6 @@ public class ChoosePartner extends Dialog { app.getGuiNode().attachChild(background); } - /** - * Handles the escape action for the dialog. - */ @Override public void escape() { new SettingsMenu(app).open(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java index 1b08622..c7d1f9a 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java @@ -38,18 +38,31 @@ import pp.dialog.DialogBuilder; * Allows users to specify the host and port for connecting to a game server. */ public class CreateGameMenu extends Dialog { + /** The Logger for this class */ private static final Logger LOGGER = System.getLogger(CreateGameMenu.class.getName()); + /** A string represing the localhost default */ private static final String LOCALHOST = "localhost"; //NON-NLS + /** A string representing the default port number */ private static final String DEFAULT_PORT = "42069"; //NON-NLS + /** The NetworkSupport instance to be used for network operations */ private final NetworkSupport network; + /** The text field for the host name */ private final TextField host = new TextField(LOCALHOST); + /** The text field for the port number */ private final TextField port = new TextField(DEFAULT_PORT); + /** The button for starting the server */ private final Button serverButton = new Button("Selber hosten"); + /** The button for canceling the connection */ private final Button cancelButton = new Button("Abbrechen"); + /** The button for joining a game */ private final Button joinButton = new Button("Beitreten"); + /** The hostname of the server */ private String hostname; + /** The port number of the server */ private int portNumber; + /** The future representing the connection to the server */ private Future connectionFuture; + /** The dialog for indicating that the connection is in progress */ private Dialog progressDialog; /** diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/FigureControl.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/FigureControl.java index ee028b6..c8b1ba8 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/FigureControl.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/FigureControl.java @@ -9,31 +9,49 @@ import com.jme3.scene.Node; import com.jme3.scene.control.AbstractControl; import pp.monopoly.client.MonopolyApp; -import pp.monopoly.game.client.ClientGameLogic; import pp.monopoly.model.Figure; import pp.monopoly.notification.GameEventListener; import pp.monopoly.notification.UpdatePlayerView; -// import java.lang.System.Logger; -// import java.lang.System.Logger.Level; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; import java.util.LinkedList; import java.util.Queue; - +/** + * Control class for the figure objects. + * + * Handles the movement of the figure along a path. + * + */ public class FigureControl extends AbstractControl implements GameEventListener { - - // // // private static final Logger LOGGER = System.getLogger(FigureControl.class.getName()); + /** The Logger for this class */ + private static final Logger LOGGER = System.getLogger(FigureControl.class.getName()); + /** The Figure object to control */ private final Figure figure; + /** The spatial object of the figure*/ private final Node spatial; + /** The MonopolyApp instance */ private final MonopolyApp app; - private Queue path; // Path to follow + /** The path to follow */ + private Queue path; + /** The current target position */ private Vector3f currentTarget; - private float animationTime = 0f; // Time elapsed for the current movement - private final float durationPerField = 0.5f; // Time to move between fields - private float delayTime = 3f; // Verzögerung in Sekunden - private float delayElapsed = 0f; // Zeit, die seit dem Start der Verzögerung vergangen ist - + /** The time elapsed for the current movement */ + private float animationTime = 0f; + /** The duration per field */ + private final float durationPerField = 0.5f; + /** The delay time */ + private float delayTime = 3f; + /** The delay elapsed time */ + private float delayElapsed = 0f; + /** + * Constructor for the FigureControl class + * @param spatial The spatial object of the figure + * @param figure The figure object + * @param app The MonopolyApp object + */ public FigureControl(Node spatial, Figure figure, MonopolyApp app) { super(); this.figure = figure; @@ -43,6 +61,14 @@ public class FigureControl extends AbstractControl implements GameEventListener app.getGameLogic().addListener(this); } + /** + * Updates the figure's movement along a path. + * + * Handles movement delays, rotates at specific fields (0, 10, 20, 30), + * and moves the figure with a hop effect toward the next target. + * + * @param tpf Time-per-frame since the last update. + */ @Override protected void controlUpdate(float tpf) { if (delayTime > 0) { @@ -61,7 +87,6 @@ public class FigureControl extends AbstractControl implements GameEventListener // Prüfe, ob eine Drehung erforderlich ist (Felder 0, 10, 20, 30) int currentField = figure.getCurrentFieldID(); - int nextField = nextField(currentField); if ((nextField(currentField) == 10) || (nextField(currentField) == 20) || @@ -100,8 +125,11 @@ public class FigureControl extends AbstractControl implements GameEventListener } } - - + /** + * Calculate the next field on the board + * @param currentField The current field id + * @return The next field id + */ private int nextField(int currentField) { return (currentField + 1) % 40; } @@ -113,35 +141,40 @@ public class FigureControl extends AbstractControl implements GameEventListener // No rendering logic required } + /** + * Set the path for the figure to follow + * @param startField The field the figure is currently on + * @param endField The field the figure should move to + */ public void setPath(int startField, int endField) { - // LOGGER.log(Level.TRACE, "setPath called with startField: {0} to endField {1}", startField, endField); + LOGGER.log(Level.TRACE, "setPath called with startField: {0} to endField {1}", startField, endField); path.clear(); for (int fieldId = startField; fieldId != endField; fieldId = (fieldId + 1) % 40) { Vector3f position = figure.calculateFieldPosition(fieldId); - // LOGGER.log(Level.DEBUG, "Adding postition to path: {0}", position); + LOGGER.log(Level.DEBUG, "Adding postition to path: {0}", position); path.add(position); } Vector3f finalPosition = figure.calculateFieldPosition(endField); path.add(finalPosition); - // LOGGER.log(Level.DEBUG, "Final position added to path: {0}", finalPosition); + LOGGER.log(Level.DEBUG, "Final position added to path: {0}", finalPosition); - // LOGGER.log(Level.TRACE, "Path size: {0}", path.size()); + LOGGER.log(Level.TRACE, "Path size: {0}", path.size()); } @Override public void receivedEvent(UpdatePlayerView event) { - // LOGGER.log(Level.TRACE, "receivedEvent called with event: {0}", event); + LOGGER.log(Level.TRACE, "receivedEvent called with event: {0}", event); int newPos = app.getGameLogic().getPlayerHandler().getPlayerById(figure.getId()).getFieldID(); int currentField = figure.getCurrentFieldID(); if (currentField == newPos) { - // LOGGER.log(Level.DEBUG, "No movement required. Current field: {0}, New field: {1}", currentField, newPos); + LOGGER.log(Level.DEBUG, "No movement required. Current field: {0}, New field: {1}", currentField, newPos); return; } - // LOGGER.log(Level.DEBUG, "Movement required. Current field: {0}, New field: {1}", currentField, newPos); + LOGGER.log(Level.DEBUG, "Movement required. Current field: {0}, New field: {1}", currentField, newPos); setPath(currentField, newPos); @@ -150,9 +183,4 @@ public class FigureControl extends AbstractControl implements GameEventListener } - - - - - } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/GameBoardSynchronizer.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/GameBoardSynchronizer.java index dde8954..07a943d 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/GameBoardSynchronizer.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/GameBoardSynchronizer.java @@ -4,26 +4,23 @@ import com.jme3.scene.Node; import com.jme3.scene.Spatial; import pp.monopoly.model.Item; import pp.monopoly.model.Visitor; -import pp.monopoly.notification.DiceRollEvent; import pp.monopoly.notification.GameEventListener; import pp.monopoly.notification.ItemAddedEvent; import pp.monopoly.notification.ItemRemovedEvent; -import pp.monopoly.notification.UpdatePlayerView; import pp.monopoly.model.Board; -import pp.monopoly.model.Figure; import pp.view.ModelViewSynchronizer; /** * Abstract base class for synchronizing the visual representation of a {@link Board} with its model state. * This class handles the addition and removal of items from the board, ensuring that changes in the model * are accurately reflected in the view. - *

+ * * Subclasses are responsible for providing the specific implementation of how each item in the map * is represented visually by implementing the {@link Visitor} interface. - *

+ * */ abstract class GameBoardSynchronizer extends ModelViewSynchronizer implements Visitor, GameEventListener { - // The board that this synchronizer is responsible for + /** The board that this synchronizer is responsible for*/ protected final Board board; /** diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ImageButton.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ImageButton.java index 8078cdc..8a2fedb 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ImageButton.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ImageButton.java @@ -9,12 +9,24 @@ import pp.monopoly.game.server.Player; import pp.monopoly.game.server.PlayerColor; import pp.monopoly.notification.Sound; +/** + * A custom button class that uses images for its appearance. The button's appearance changes based on its state (enabled, + */ public class ImageButton extends Button { + /** The MonopolyApp instance */ private final MonopolyApp app; + /** The button's functionality (e.g., "end_turn", "roll_dice") */ private final String functionality; + /** The player's color */ private final PlayerColor playerColor; + /** + * Creates a new ImageButton with the given functionality and MonopolyApp instance. + * + * @param functionality the button's functionality (e.g., "end_turn", "roll_dice") + * @param app the MonopolyApp instance + */ public ImageButton(String functionality, MonopolyApp app) { super("", "button-clear"); this.app = app; @@ -82,10 +94,12 @@ public class ImageButton extends Button { ENABLED, DISABLED, HOVER } + @Override public void addClickCommands( Command command ) { super.addCommands(ButtonAction.Down, command); } + @Override @SuppressWarnings("unchecked") // because Java doesn't like var-arg generics public void addClickCommands( Command... commands ) { super.addCommands(ButtonAction.Down, commands); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java index 8fa904c..77e044f 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java @@ -32,10 +32,10 @@ import java.util.Set; /** * Represents the lobby menu in the Monopoly application. - *

+ * * Provides functionality for player configuration, including input for starting capital, * player name, and figure selection, as well as options to ready up or exit the game. - *

+ * */ public class LobbyMenu extends Dialog { @@ -270,9 +270,6 @@ public class LobbyMenu extends Dialog { app.getGameLogic().send(new PlayerReady(true, playerInputField.getText(), figure, Integer.parseInt(startingCapital.getText()))); } - /** - * Opens the settings menu when the escape key is pressed. - */ @Override public void escape() { new SettingsMenu(app).open(); @@ -291,11 +288,6 @@ public class LobbyMenu extends Dialog { } } - /** - * Closes the current menu and transitions music playback. - * Stops the secondary music (if playing) and resumes the main background music - * if music is enabled in the preferences. Ensures smooth transitions in audio. - */ @Override public void close() { GameMusic music = app.getStateManager().getState(GameMusic.class); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java index 40c7eef..28ca04c 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/PropertyOverviewMenu.java @@ -28,10 +28,15 @@ import java.util.stream.Collectors; * PropertyOverviewMenu is a dialog for displaying the player's properties in the game. */ public class PropertyOverviewMenu extends Dialog { + /** The MonopolyApp instance */ private final MonopolyApp app; + /** The main container for the menu layout */ private final Container mainContainer; + /** The container for displaying the "Gebäude" cards */ private final Container displayContainer; + /** The horizontal slider for scrolling through cards */ private final Slider horizontalSlider; + /** The list of cards to display */ private final List cards; /** @@ -124,6 +129,9 @@ public class PropertyOverviewMenu extends Dialog { /** * Creates a card for BuildingProperty with detailed rent and cost information. + * + * @param field The BuildingProperty to create a card for. + * @return The created card container. */ private Container createBuildingCard(BuildingProperty field) { Container card = new Container(); @@ -156,6 +164,9 @@ public class PropertyOverviewMenu extends Dialog { /** * Creates a card for FoodField with dynamic pricing and rent details. + * + * @param field The FoodField to create a card for. + * @return The created card container. */ private Container createFoodFieldCard(FoodField field) { Container card = new Container(); @@ -188,6 +199,9 @@ public class PropertyOverviewMenu extends Dialog { /** * Creates a card for GateField with rent details for owning multiple gates. + * + * @param field The GateField to create a card for. + * @return The created card container. */ private Container createGateFieldCard(GateField field) { Container card = new Container(); @@ -260,9 +274,6 @@ public class PropertyOverviewMenu extends Dialog { } - /** - * Closes the dialog and detaches it from the GUI node. - */ @Override public void close() { app.getGuiNode().detachChild(mainContainer); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java index 3f3b9a7..592448a 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java @@ -136,9 +136,6 @@ public class SettingsMenu extends Dialog { update(); } - /** - * As an escape action, this method closes the menu if it is the top dialog. - */ @Override public void escape() { close(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SoundSlider.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SoundSlider.java index 5a07704..2745159 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SoundSlider.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SoundSlider.java @@ -3,12 +3,15 @@ package pp.monopoly.client.gui; import com.simsilica.lemur.Slider; import pp.monopoly.client.GameSound; +/** + * A slider for the sound effects volume. + */ public class SoundSlider extends Slider { /** * Manages sound effects for the game. */ - private final pp.monopoly.client.GameSound sound; + private final GameSound sound; /** * Volume level for the game sounds. diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java index 997a603..f970471 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java @@ -20,6 +20,9 @@ import pp.monopoly.notification.Sound; * Constructs the startup menu dialog for the Monopoly application. */ public class StartMenu extends Dialog { + /** + * The Monopoly application instance. + */ private final MonopolyApp app; /** @@ -105,17 +108,11 @@ public class StartMenu extends Dialog { app.getGuiNode().attachChild(unibwContainer); } - /** - * Opens the settings menu when the escape key is pressed. - */ @Override public void escape() { new SettingsMenu(app).open(); } - /** - * Closes the startup menu and detaches all GUI elements. - */ @Override public void close() { app.getGuiNode().detachAllChildren(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java index 6d4e543..ce884f6 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java @@ -273,17 +273,21 @@ public class Toolbar extends Dialog implements GameEventListener { * Handles the dice roll event. */ private void handleDiceRoll() { - ifTopDialog(() -> { - if (!canRollDice) return; - canRollDice = false; - if (endTurnButton != null) endTurnButton.setEnabled(true); - startDiceAnimation(); - app.getGameLogic().send(new RollDice()); - app.getGameLogic().playSound(Sound.BUTTON); - }); -} - + ifTopDialog(() -> { + if (!canRollDice) return; + canRollDice = false; + if (endTurnButton != null) endTurnButton.setEnabled(true); + startDiceAnimation(); + app.getGameLogic().send(new RollDice()); + app.getGameLogic().playSound(Sound.BUTTON); + }); + } + /** + * Creates the trade button. + * + * @return The trade button. + */ private Button createTradeButton() { String iconPath = "icons/icon-handeln.png"; // createActionButton(playerColor, "icons/icon-handeln.png", 100, () -> new ChoosePartner(app).open()); @@ -304,7 +308,11 @@ public class Toolbar extends Dialog implements GameEventListener { return tradeButton; } - + /** + * Creates the property menu button. + * + * @return The property menu button. + */ private Button createPropertyMenuButton() { String iconPath = "icons/icon-gebaude.png"; @@ -324,6 +332,11 @@ public class Toolbar extends Dialog implements GameEventListener { return propertyMenuButton; } + /** + * Creates the end turn button. + * + * @return The end turn button. + */ private Button createEndTurnButton() { // return createActionButton(playerColor, "icons/icon-zugbeenden.png", 75, () -> handleEndTurn()); @@ -525,18 +538,11 @@ public class Toolbar extends Dialog implements GameEventListener { endTurnButton.setEnabled(false); } - /** - * Closes the toolbar, detaching it from the GUI. - */ @Override public void close() { app.getGuiNode().detachChild(toolbarContainer); super.close(); } - - /** - * Opens the settings menu when the escape key is pressed. - */ @Override public void escape() { new SettingsMenu(app).open(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java index 4abf116..422c8e9 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/TradeMenu.java @@ -30,10 +30,10 @@ import java.util.stream.Collectors; /** * Represents the trade menu dialog in the Monopoly application. - *

+ * * Facilitates trade interactions between players, including selection of properties, * currency, and special cards for offers and requests. - *

+ * */ public class TradeMenu extends Dialog { @@ -48,17 +48,26 @@ public class TradeMenu extends Dialog { /** Background geometry for the menu. */ private Geometry background; + /** The building and card selector for the left column. */ private Selector leftBuildingSelector, leftSpecialCardSelector; + /** The building and card selector for the right column. */ private Selector rightBuildingSelector, rightSpecialCardSelector; + /** The labels for displaying selected properties. */ private Label leftSelectionsLabel, rightSelectionsLabel; + /** The text fields for currency input. */ private TextField leftCurrencyInput, rightCurrencyInput; + /** References for tracking UI changes. */ private VersionedReference> leftBuildingRef, rightBuildingRef; + /** References for tracking UI changes. */ private VersionedReference> leftCardRef, rightCardRef; + /** The selected buildings for the trade. */ private Set rightselBuildings = new HashSet<>(); + /** The selected buildings for the trade. */ private Set leftselBuildings = new HashSet<>(); + /** The color for the trade menu background. */ private static final ColorRGBA TRANSLUCENT_WHITE = new ColorRGBA(1, 1, 1, 0.5f); /** @@ -80,7 +89,11 @@ public class TradeMenu extends Dialog { initializeReferences(); } - /** Creates the main container for the trade menu UI. */ + + /** + * Creates the main container for the trade menu. + * @return the created main container + */ private Container createMainContainer() { Container container = new Container(new SpringGridLayout(Axis.Y, Axis.X)); container.setPreferredSize(new Vector3f(1200, 800, 0)); @@ -90,7 +103,11 @@ public class TradeMenu extends Dialog { container.addChild(createMainContent()); return container; } - /** Creates the header label for the trade menu. */ + + /** + * Creates the header label for the trade menu. + * @return the created header label + */ private Label createHeader() { Label header = new Label("Handelsmenü", new ElementId("label-Bold")); header.setFontSize(50); @@ -98,7 +115,11 @@ public class TradeMenu extends Dialog { header.setBackground(new QuadBackgroundComponent(TRANSLUCENT_WHITE)); return header; } - /** Creates the main content section of the trade menu. */ + + /** + * Creates the main content for the trade menu. + * @return the created main content container + */ private Container createMainContent() { Container mainContent = new Container(new SpringGridLayout(Axis.X, Axis.Y)); mainContent.setPreferredSize(new Vector3f(1200, 700, 0)); @@ -110,7 +131,9 @@ public class TradeMenu extends Dialog { return mainContent; } - /** Sets the trade data based on the current selections. */ + /** + * Sets the trade values based on the user input. + */ private void setTrades() { String leftCurreny = leftCurrencyInput.getText().equals("")? "0" : leftCurrencyInput.getText(); String rightCurreny = rightCurrencyInput.getText().equals("")? "0" : rightCurrencyInput.getText(); @@ -232,13 +255,21 @@ public class TradeMenu extends Dialog { combinedProperties = combinedProperties.stream().sorted(Comparator.comparingInt(PropertyField::getId)).collect(Collectors.toList()); return combinedProperties; } - /** Creates a text field for currency input. */ + + /** + * Creates a currency input field for the trade menu. + * @return the created currency input field + */ private TextField createCurrencyInput() { TextField currencyInput = new TextField("0"); styleTextField(currencyInput); return currencyInput; } - /** Creates the middle section containing buttons and summary fields. */ + + /** + * Creates the middle section of the trade menu. + * @return the created middle section container + */ private Container createMiddleSection() { Container middleSection = new Container(new SpringGridLayout(Axis.Y, Axis.X)); middleSection.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8f, 0.8f, 0.8f, 1.0f))); @@ -281,13 +312,19 @@ public class TradeMenu extends Dialog { return middleSection; } - /** Styles the given selector with insets and background color. */ + /** + * Styles the given selector with insets and background color. + * @param selector the selector to style + */ private void styleSelector(Selector selector) { selector.setInsets(new Insets3f(5, 10, 5, 10)); selector.setBackground(new QuadBackgroundComponent(ColorRGBA.Black)); } - /** Styles the given text field with insets and background color. */ + /** + * Styles the given text field with insets and background color. + * @param textField the text field to style + */ private void styleTextField(TextField textField) { textField.setInsets(new Insets3f(5, 10, 5, 10)); textField.setBackground(new QuadBackgroundComponent(ColorRGBA.Black)); @@ -314,7 +351,10 @@ public class TradeMenu extends Dialog { rightCurrencyInput = currencyInput; } } - /** Positions the main container at the center of the screen. */ + + /** + * Positions the main container in the center of the screen. + */ private void positionMainContainer() { mainContainer.setLocalTranslation( (app.getCamera().getWidth() - mainContainer.getPreferredSize().x) / 2, @@ -322,7 +362,10 @@ public class TradeMenu extends Dialog { 7 ); } - /** Adds a background image to the trade menu. */ + + /** + * Adds a background image to the trade menu. + */ private void addBackgroundImage() { Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png"); Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); @@ -333,6 +376,7 @@ public class TradeMenu extends Dialog { background.setLocalTranslation(0, 0, 6); app.getGuiNode().attachChild(background); } + /** Initializes references for tracking UI changes. */ private void initializeReferences() { leftBuildingRef = leftBuildingSelector.getSelectionModel().createReference(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/VolumeSlider.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/VolumeSlider.java index b2e9410..65cbf77 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/VolumeSlider.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/VolumeSlider.java @@ -10,7 +10,9 @@ import pp.monopoly.client.GameMusic; */ public class VolumeSlider extends Slider { - private final pp.monopoly.client.GameMusic music; + /** The GameMusic instance to handel */ + private final GameMusic music; + /** The volume of the music */ private double vol; /** diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java index 7900b05..2992441 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Bankrupt.java @@ -117,9 +117,6 @@ public class Bankrupt extends Dialog implements PopupDialog { ); } - /** - * Displays the popup by attaching it to the GUI. - */ @Override public void show() { app.getGuiNode().attachChild(overlayBackground); @@ -128,9 +125,6 @@ public class Bankrupt extends Dialog implements PopupDialog { centerContainers(); } - /** - * Closes the popup and removes the associated GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(overlayBackground); @@ -139,9 +133,6 @@ public class Bankrupt extends Dialog implements PopupDialog { super.close(); } - /** - * Handles the escape key action by closing the popup. - */ @Override public void escape() { close(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuildingPropertyCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuildingPropertyCard.java index 7b6b7de..1f52b47 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuildingPropertyCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuildingPropertyCard.java @@ -22,8 +22,11 @@ import pp.monopoly.notification.Sound; */ public class BuildingPropertyCard extends Dialog implements PopupDialog { + /**The Monopoly application instance*/ private final MonopolyApp app; + /**The main container for the popup*/ private final Container buildingPropertyContainer; + /**The background container for the popup*/ private final Container backgroundContainer; /** @@ -136,18 +139,12 @@ public class BuildingPropertyCard extends Dialog implements PopupDialog { ); } - /** - * Attaches the popup to the GUI through the DialogManager. - */ @Override public void show() { app.getGuiNode().attachChild(backgroundContainer); app.getGuiNode().attachChild(buildingPropertyContainer); } - /** - * Closes the popup and removes associated GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(buildingPropertyContainer); @@ -155,9 +152,6 @@ public class BuildingPropertyCard extends Dialog implements PopupDialog { super.close(); } - /** - * Opens the settings menu when the escape key is pressed. - */ @Override public void escape() { new SettingsMenu(app).open(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java index fdd4277..30d56a9 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/BuyHouse.java @@ -227,9 +227,6 @@ public class BuyHouse extends Dialog { this.cost.setText(cost+""); } - /** - * Closes the popup and removes its GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(buyHouseContainer); @@ -237,9 +234,6 @@ public class BuyHouse extends Dialog { super.close(); } - /** - * Opens the settings menu when the escape key is pressed. - */ @Override public void escape() { new SettingsMenu(app).open(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java index c8241a5..0eb0c32 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ConfirmTrade.java @@ -124,9 +124,6 @@ public class ConfirmTrade extends Dialog implements PopupDialog { })); } - /** - * Displays the popup by attaching it to the GUI. - */ @Override public void show() { float padding = 10; @@ -149,9 +146,6 @@ public class ConfirmTrade extends Dialog implements PopupDialog { app.getGuiNode().attachChild(confirmTradeContainer); } - /** - * Closes the popup and removes its GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(confirmTradeContainer); @@ -159,9 +153,6 @@ public class ConfirmTrade extends Dialog implements PopupDialog { super.close(); } - /** - * Opens the settings menu when the escape key is pressed. - */ @Override public void escape() { new SettingsMenu(app).open(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/EventCardPopup.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/EventCardPopup.java index fdcf9f8..a206a60 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/EventCardPopup.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/EventCardPopup.java @@ -99,9 +99,6 @@ public class EventCardPopup extends Dialog implements PopupDialog { })); } - /** - * Displays the popup by attaching it to the GUI. - */ @Override public void show() { float padding = 10; @@ -125,9 +122,6 @@ public class EventCardPopup extends Dialog implements PopupDialog { app.getGuiNode().attachChild(eventCardContainer); } - /** - * Closes the popup and removes its associated GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(overlayBackground); @@ -136,9 +130,6 @@ public class EventCardPopup extends Dialog implements PopupDialog { super.close(); } - /** - * Handles the escape key action by closing the popup. - */ @Override public void escape() { close(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/FoodFieldCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/FoodFieldCard.java index 668814c..18d9458 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/FoodFieldCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/FoodFieldCard.java @@ -123,9 +123,6 @@ public class FoodFieldCard extends Dialog implements PopupDialog { })); } - /** - * Displays the popup by attaching its elements to the GUI. - */ @Override public void show() { float padding = 10; @@ -149,9 +146,6 @@ public class FoodFieldCard extends Dialog implements PopupDialog { app.getGuiNode().attachChild(foodFieldContainer); } - /** - * Closes the popup and removes its associated GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(overlayBackground); @@ -160,9 +154,6 @@ public class FoodFieldCard extends Dialog implements PopupDialog { super.close(); } - /** - * Handles the escape key action by closing the popup. - */ @Override public void escape() { close(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java index ab8bc13..b352596 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GateFieldCard.java @@ -103,10 +103,7 @@ public class GateFieldCard extends Dialog implements PopupDialog { close(); })); } - - /** - * Displays the popup by attaching its elements to the GUI. - */ + @Override public void show() { float padding = 10; @@ -129,9 +126,6 @@ public class GateFieldCard extends Dialog implements PopupDialog { app.getGuiNode().attachChild(gateFieldContainer); } - /** - * Closes the popup and removes its associated GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(gateFieldContainer); // Remove main container @@ -139,9 +133,6 @@ public class GateFieldCard extends Dialog implements PopupDialog { super.close(); } - /** - * Opens the settings menu when the escape key is pressed. - */ @Override public void escape() { new SettingsMenu(app).open(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Gulag.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Gulag.java index 1326b26..e2c517f 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Gulag.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Gulag.java @@ -19,9 +19,9 @@ import pp.monopoly.notification.Sound; /** * Gulag is a warning popup triggered when a player lands on the "Wache" field in the Monopoly game. - *

+ * * This popup informs the player that they are being sent to the Gulag and includes a confirmation button. - *

+ * */ public class Gulag extends Dialog implements PopupDialog { /** Reference to the Monopoly application instance. */ @@ -94,9 +94,6 @@ public class Gulag extends Dialog implements PopupDialog { })); } - /** - * Displays the popup by attaching its elements to the GUI. - */ @Override public void show() { float padding = 10; @@ -120,9 +117,6 @@ public class Gulag extends Dialog implements PopupDialog { app.getGuiNode().attachChild(gulagContainer); } - /** - * Closes the popup and removes its associated GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(overlayBackground); @@ -131,9 +125,6 @@ public class Gulag extends Dialog implements PopupDialog { super.close(); } - /** - * Handles the escape action by closing the popup. - */ @Override public void escape() { close(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GulagInfo.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GulagInfo.java index 76e33eb..dafb3d9 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GulagInfo.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/GulagInfo.java @@ -115,9 +115,6 @@ public class GulagInfo extends Dialog implements PopupDialog { } } - /** - * Displays the popup by attaching its elements to the GUI. - */ @Override public void show() { float padding = 10; @@ -142,13 +139,15 @@ public class GulagInfo extends Dialog implements PopupDialog { app.getGuiNode().attachChild(gulagInfoContainer); } - /** - * Closes the GulagInfo popup and removes its GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(gulagInfoContainer); // Remove dialog app.getGuiNode().detachChild(backgroundContainer); // Remove background super.close(); } + + @Override + public void escape() { + close(); + } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/LooserPopUp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/LooserPopUp.java index a4fa023..1d33ab6 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/LooserPopUp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/LooserPopUp.java @@ -18,9 +18,9 @@ import pp.monopoly.notification.Sound; /** * LooserPopUp is a dialog that appears when a player loses the game. - *

+ * * This popup provides a message of encouragement and an option to quit the game. - *

+ * */ public class LooserPopUp extends Dialog { /** Reference to the Monopoly application instance. */ @@ -123,9 +123,6 @@ public class LooserPopUp extends Dialog { return overlay; } - /** - * Closes the LooserPopUp dialog and removes its GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(LooserContainer); // Entferne das Menü @@ -134,9 +131,6 @@ public class LooserPopUp extends Dialog { super.close(); } - /** - * Handles the escape action to close the dialog. - */ @Override public void escape() { close(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/NoMoneyWarning.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/NoMoneyWarning.java index 1c1547c..9685b4c 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/NoMoneyWarning.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/NoMoneyWarning.java @@ -127,9 +127,6 @@ public class NoMoneyWarning extends Dialog implements PopupDialog { ); } - /** - * Displays the dialog by attaching its components to the GUI node. - */ @Override public void show() { app.getGuiNode().attachChild(overlayBackground); @@ -137,9 +134,6 @@ public class NoMoneyWarning extends Dialog implements PopupDialog { app.getGuiNode().attachChild(noMoneyWarningContainer); } - /** - * Closes the dialog and removes its components from the GUI node. - */ @Override public void close() { app.getGuiNode().detachChild(overlayBackground); @@ -148,9 +142,6 @@ public class NoMoneyWarning extends Dialog implements PopupDialog { super.close(); } - /** - * Handles the escape action to close the dialog. - */ @Override public void escape() { close(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ReceivedRent.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ReceivedRent.java index 5553c8c..bf244e4 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ReceivedRent.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/ReceivedRent.java @@ -125,9 +125,6 @@ public class ReceivedRent extends Dialog implements PopupDialog { ); } - /** - * Displays the popup by attaching it to the GUI through the DialogManager. - */ @Override public void show() { app.getGuiNode().attachChild(overlayBackground); @@ -136,9 +133,6 @@ public class ReceivedRent extends Dialog implements PopupDialog { centerContainers(); } - /** - * Closes the popup and removes GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(overlayBackground); @@ -147,9 +141,6 @@ public class ReceivedRent extends Dialog implements PopupDialog { super.close(); } - /** - * Handles the escape action to close the dialog. - */ @Override public void escape() { close(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java index 073990e..b85a452 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RejectTrade.java @@ -134,9 +134,6 @@ public class RejectTrade extends Dialog implements PopupDialog { ); } - /** - * Displays the popup by attaching its elements to the GUI node. - */ @Override public void show() { app.getGuiNode().attachChild(overlayBackground); @@ -144,9 +141,6 @@ public class RejectTrade extends Dialog implements PopupDialog { app.getGuiNode().attachChild(rejectTradeContainer); } - /** - * Closes the menu and removes the GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(overlayBackground); @@ -155,9 +149,6 @@ public class RejectTrade extends Dialog implements PopupDialog { super.close(); } - /** - * Handles the escape key action by closing the popup. - */ @Override public void escape() { close(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Rent.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Rent.java index e559f96..6e4a4fb 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Rent.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/Rent.java @@ -19,17 +19,28 @@ import pp.monopoly.notification.Sound; /** * Rent is a popup that is triggered when a player lands on a property owned by another player * and needs to pay rent in the Monopoly application. - *

+ * * Displays the rent amount and the recipient player's name, with an option to confirm the payment. - *

+ * */ public class Rent extends Dialog implements PopupDialog { - private final MonopolyApp app; + /** Reference to the Monopoly application instance. */ + private final MonopolyApp app; + /** Semi-transparent overlay background for the popup. */ private final Geometry overlayBackground; + /** Main container for the rent information and action. */ private final Container rentContainer; + /** Background container providing a border for the rent popup. */ private final Container backgroundContainer; + /** + * Constructs the Rent popup displaying the rent amount and recipient player's name. + * + * @param app the Monopoly application instance + * @param playerName the name of the player to pay rent to + * @param amount the amount of rent to pay + */ public Rent(MonopolyApp app, String playerName, int amount) { super(app.getDialogManager()); this.app = app; @@ -43,6 +54,11 @@ public class Rent extends Dialog implements PopupDialog { centerContainers(); } + /** + * Creates the semi-transparent overlay background for the popup. + * + * @return the geometry of the overlay + */ private Geometry createOverlayBackground() { Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); Geometry overlay = new Geometry("Overlay", quad); @@ -54,12 +70,24 @@ public class Rent extends Dialog implements PopupDialog { return overlay; } + /** + * Creates the background container for the rent popup. + * + * @return the background container + */ private Container createBackgroundContainer() { Container container = new Container(); container.setBackground(new QuadBackgroundComponent(new ColorRGBA(0.8657f, 0.8735f, 0.8892f, 1.0f))); return container; } + /** + * Creates the main container for the rent popup. + * + * @param playerName the name of the player to pay rent to + * @param amount the amount of rent to pay + * @return the rent container + */ private Container createRentContainer(String playerName, int amount) { Container container = new Container(); container.setBackground(new QuadBackgroundComponent(ColorRGBA.Gray)); @@ -85,6 +113,9 @@ public class Rent extends Dialog implements PopupDialog { return container; } + /** + * Centers the rent and background containers on the screen. + */ private void centerContainers() { float padding = 10; diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RepayMortage.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RepayMortage.java index e83d672..13fafce 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RepayMortage.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/RepayMortage.java @@ -29,10 +29,10 @@ import java.util.stream.Collectors; /** * RepayMortage is a popup that appears when a player selects the "Repay Mortgage" option * in the Building Administration Menu. - *

+ * * This popup allows the player to select mortgaged properties and repay their mortgages, * showing the total cost of the repayment. Includes options to confirm or cancel the repayment. - *

+ * */ public class RepayMortage extends Dialog { /** Reference to the Monopoly application instance. */ @@ -231,9 +231,6 @@ public class RepayMortage extends Dialog { this.cost.setText(cost+""); } - /** - * Closes the popup and removes its associated GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(repayMortageContainer); // Entferne das Menü @@ -241,9 +238,6 @@ public class RepayMortage extends Dialog { super.close(); } - /** - * Opens the settings menu when the escape key is pressed. - */ @Override public void escape() { new SettingsMenu(app).open(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java index 95ca557..1b3540c 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/SellHouse.java @@ -29,10 +29,10 @@ import java.util.stream.Collectors; /** * SellHouse is a popup that appears when a player clicks on the "Demolish" button * in the BuildingAdminMenu. - *

+ * * This dialog allows players to select their properties and demolish houses or hotels * for a partial refund of their purchase cost. - *

+ * */ public class SellHouse extends Dialog { /** Reference to the Monopoly application instance. */ @@ -230,9 +230,6 @@ public class SellHouse extends Dialog { this.cost.setText(cost+""); } - /** - * Closes the dialog and removes GUI elements from the screen. - */ @Override public void close() { app.getGuiNode().detachChild(sellhouseContainer); // Entferne das Menü @@ -240,9 +237,6 @@ public class SellHouse extends Dialog { super.close(); } - /** - * Handles the escape action to close the dialog. - */ @Override public void escape() { new SettingsMenu(app).open(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TakeMortage.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TakeMortage.java index 6126226..95c62d9 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TakeMortage.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/TakeMortage.java @@ -240,9 +240,6 @@ public class TakeMortage extends Dialog { this.cost.setText(cost+""); } - /** - * Closes the dialog and removes GUI elements from the screen. - */ @Override public void close() { app.getGuiNode().detachChild(takeMortageContainer); // Entferne das Menü @@ -250,9 +247,6 @@ public class TakeMortage extends Dialog { super.close(); } - /** - * Handles the escape action to close the dialog. - */ @Override public void escape() { new SettingsMenu(app).open(); diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/WinnerPopUp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/WinnerPopUp.java index fdcde84..059d977 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/WinnerPopUp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/WinnerPopUp.java @@ -18,9 +18,9 @@ import pp.monopoly.notification.Sound; /** * WinnerPopUp is a dialog displayed when a player wins the Monopoly game. - *

+ * * This popup congratulates the player for their victory and provides an option to quit the game. - *

+ * */ public class WinnerPopUp extends Dialog { /** Reference to the Monopoly application instance. */ @@ -121,9 +121,6 @@ public class WinnerPopUp extends Dialog { return overlay; } - /** - * Closes the WinnerPopUp dialog and removes its GUI elements. - */ @Override public void close() { app.getGuiNode().detachChild(WinnerContainer); // Entferne das Menü @@ -132,9 +129,6 @@ public class WinnerPopUp extends Dialog { super.close(); } - /** - * Handles the escape action to close the dialog. - */ @Override public void escape() { close(); diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java index e5f641a..db09560 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java @@ -69,10 +69,13 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { /** The current state of the client game logic. */ private ClientState state = new LobbyState(this); + /** The player handler containing information about all players in the game. */ private PlayerHandler playerHandler; + /** The board manager containing information about all fields on the board. */ private BoardManager boardManager = new BoardManager(); + /** The trade handler containing information about trades in the game. */ private TradeHandler tradeHandler; diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/Player.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/Player.java index 2ca9153..c42f952 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/Player.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/Player.java @@ -7,6 +7,7 @@ package pp.monopoly.game.server; +import java.lang.System.Logger; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -39,24 +40,35 @@ import pp.monopoly.model.fields.WacheField; * Class representing a player */ @Serializable -public class Player implements FieldVisitor{ +public class Player implements FieldVisitor { + /** The logger for this class */ + private final static Logger LOGGER = System.getLogger(Player.class.getName()); + /** The player id */ private final int id; + /** The player name */ private String name; + /** The player account balance */ private int accountBalance = 15000; + /** The player figure */ private String figure; + /** The player properties */ private Set properties = new HashSet<>(); + /** The number of GetOutOfJailCards owned by the player */ private int getOutOfJailCard; + /** The current field id of the player */ private int fieldID; + /** The result of the last dice roll */ private DiceResult rollResult; + /** The player handler */ private transient final PlayerHandler handler; + /** The current state of the player */ private transient PlayerState state = new WaitForTurnState(); /** * Default constructor for serialization purposes. */ private Player(){ - id = 0; - handler = null; + this(0, null); } /** @@ -69,6 +81,7 @@ public class Player implements FieldVisitor{ this.name = name; this.id = id; this.handler = handler; + LOGGER.log(Logger.Level.INFO, "Player created: " + name); } /** @@ -77,8 +90,7 @@ public class Player implements FieldVisitor{ * @param handler the PlayerHandler this player is a part of */ public Player(int id, PlayerHandler handler) { - this.id = id; - this.handler = handler; + this(id, null, handler); } /** @@ -97,6 +109,10 @@ public class Player implements FieldVisitor{ return figure; } + /** + * Returns the color of the player + * @return the color of the player + */ public static PlayerColor getColor(int id) { switch ((id%6)+1) { case 1: return PlayerColor.CYAN; @@ -143,6 +159,10 @@ public class Player implements FieldVisitor{ return fieldID; } + /** + * Sets the state of the player to active + * If the player is in jail, the player will be asked to pay the bail + */ void setActive() { System.out.println("State: "+state.getClass().getName()); if(!(state instanceof JailState)) { @@ -153,6 +173,11 @@ public class Player implements FieldVisitor{ } } + /** + * Finish the turn of the player + * If the player has a negative account balance, the player will be bankrupted + * @return true if the turn was finished successfully, false if the player is bankrupt + */ boolean finishTurn() { if(canFinishTurn()) { if (state instanceof ActiveState) state = new WaitForTurnState(); @@ -164,14 +189,26 @@ public class Player implements FieldVisitor{ } } + /** + * Checks if the player can finish the turn + * @return true if the player can finish the turn, false if the player is bankrupt + */ boolean canFinishTurn() { return accountBalance >= 0; } + /** + * Returns the current state of the player + * @return the current state of the player + */ public PlayerState getState() { return state; } + /** + * Sets the state of the player + * @param state the new state of the player + */ public void setState(PlayerState state) { this.state = state; } @@ -206,7 +243,7 @@ public class Player implements FieldVisitor{ return fieldID; } - /** + /** * Sets the player to the specified Position on the board * @param position the position to move to * @return the new position @@ -297,7 +334,7 @@ public class Player implements FieldVisitor{ /** * Return the number of GEtOutOfJailCards owned by this player - * @return + * @return the number of GetOutOfJailCards owned by this player */ public int getNumJailCard() { return getOutOfJailCard; @@ -335,7 +372,11 @@ public class Player implements FieldVisitor{ state.useJailCard(); } - private void sendRentNotification(String keyword, Player player, int amount) { + /** + * Sends a notification to the player + * @param keyword the keyword of the notification + */ + private void sendNotification(String keyword, Player player, int amount) { NotificationMessage msg = new NotificationMessage(keyword); msg.setRentAmount(amount); msg.setRentOwnerId(player.getName()); @@ -351,8 +392,8 @@ public class Player implements FieldVisitor{ int rent = field.calcRent(); field.getOwner().earnMoney(rent); pay(rent); - sendRentNotification("ReceivedRent", this, rent); - sendRentNotification("rent", field.getOwner(), rent); + sendNotification("ReceivedRent", this, rent); + sendNotification("rent", field.getOwner(), rent); } return null; } @@ -369,8 +410,8 @@ public class Player implements FieldVisitor{ int rent = rollResult.calcTotal()*factor; field.getOwner().earnMoney(rent); pay(rent); - sendRentNotification("ReceivedRent", this, rent); - sendRentNotification("rent", field.getOwner(), rent); + sendNotification("ReceivedRent", this, rent); + sendNotification("rent", field.getOwner(), rent); } return null; } @@ -384,8 +425,8 @@ public class Player implements FieldVisitor{ field.getOwner().earnMoney(rent); pay(rent); - sendRentNotification("ReceivedRent", this, rent); - sendRentNotification("rent", field.getOwner(), rent); + sendNotification("ReceivedRent", this, rent); + sendNotification("rent", field.getOwner(), rent); } return null; } @@ -450,6 +491,9 @@ public class Player implements FieldVisitor{ handler.getLogic().send(this, new JailEvent(true)); } + /** + * Sends the player to jail by setting position and state. + */ void jail() { state = new JailState(); fieldID = 10; @@ -473,6 +517,10 @@ public class Player implements FieldVisitor{ return count; } + /** + * Return the number of Houses owned by the player + * @return the number of houses owned by the player + */ public int getNumHouses() { int total = 0; for (PropertyField field : getPropertyFields()) { @@ -483,6 +531,10 @@ public class Player implements FieldVisitor{ return total; } + /** + * Return the number of Hotels owned by the player + * @return the number of hotels owned by the player + */ public int getNumHotels() { int total = 0; for (PropertyField field : getPropertyFields()) { @@ -526,7 +578,10 @@ public class Player implements FieldVisitor{ DiceResult rollDice() { return state.rollDice(); } - + + /** + * Bankrupts the player by removing all properties and setting the account balance to 0. + */ private void bankrupt() { for (PropertyField field : getPropertyFields()) { field.setOwner(null); @@ -654,6 +709,10 @@ public class Player implements FieldVisitor{ } } + /** + * A class to represent the WaitForTurn PlayerState + * Set when it is not the players turn + */ private class WaitForTurnState implements PlayerState { @Override @@ -676,10 +735,18 @@ public class Player implements FieldVisitor{ return "Player{name=" + name + ", figure=" + figure + "}"; } + /** + * Adds a property to the player + * @param id the id of the property to be added + */ public void addProperty(Integer id) { properties.add(id); } + /** + * Removes a property from the player + * @param id the id of the property to be removed + */ public void removeProperty(Integer id) { properties.remove(id); } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/PlayerHandler.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/PlayerHandler.java index 4590e98..985cd6b 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/PlayerHandler.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/PlayerHandler.java @@ -172,12 +172,20 @@ public class PlayerHandler { players.get(0).setActive(); } + /** + * Sets the starting balance for all players + * @param amount the amount to be set + */ public void setStartBalance(int amount) { for (Player player : players) { player.setAccountBalance(amount); } } + /** + * Sets a player to have an extra turn + * @param player the player to have an extra turn + */ public void extraTurn(Player player) { if (players.contains(player)) extra = player; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java index ea33b69..53ba03f 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/ServerGameLogic.java @@ -38,15 +38,26 @@ import pp.monopoly.model.fields.PropertyField; * Manages game states, player interactions, and message handling. */ public class ServerGameLogic implements ClientInterpreter { + /** + * The logger for the ServerGameLogic class. + */ private static final Logger LOGGER = System.getLogger(ServerGameLogic.class.getName()); + /** The game configuration. */ private final MonopolyConfig config; + /** The player handler for managing players. */ private final PlayerHandler playerHandler = new PlayerHandler(this); + /** The sender used to send messages to clients. */ private final ServerSender serverSender; + /** The current state of the game. */ private ServerState state = ServerState.LOBBY; + /** The maximum number of players allowed in the game. */ private static final int MAX_PLAYERS = 6; + /** The board manager for managing the game board. */ private BoardManager boardManager = new BoardManager(); + /** The deck helper for managing card decks. */ private final DeckHelper deckHelper = new DeckHelper(); + /** The amount of money each player starts with. */ private int startMoney; /** @@ -383,10 +394,21 @@ public class ServerGameLogic implements ClientInterpreter { return boardManager; } + /** + * Retrieves the player handler, which manages player actions and turns. + * + * @param id the id of the player to retrieve + * @return the PlayerHandler instance managing players + */ public Player getPlayerById(int id) { return playerHandler.getPlayerById(id); } + /** + * Retrieves the deck helper, which manages decks of cards. + * + * @return the deck helper + */ public DeckHelper getDeckHelper() { return deckHelper; } @@ -452,6 +474,9 @@ public class ServerGameLogic implements ClientInterpreter { updateAllPlayers(); } + /** + * Generates a predefined game state for testing and demo purposes. + */ private void generatePredefinedGameState() { if(playerHandler.getPlayerCount() < 2) { diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/AlterProperty.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/AlterProperty.java index 1330e8d..85298e7 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/AlterProperty.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/AlterProperty.java @@ -4,14 +4,24 @@ import java.util.Set; import com.jme3.network.serializing.Serializable; +/** + * Sent by the client to the server to alter the properties of a field. + */ @Serializable public class AlterProperty extends ClientMessage{ + /** The keyword to indicate what action should be performed */ private String keyword; + /** The properties that should be altered */ private Set properties; + /** No-Args Construcotr for serilization */ private AlterProperty() {} + /** + * Create a new AlterProperty message. + * @param keyword The keyword to indicate what action should be performed + */ public AlterProperty(String keyword) { this.keyword = keyword; } @@ -21,14 +31,26 @@ public class AlterProperty extends ClientMessage{ interpreter.received(this, from); } + /** + * Returns the keyword to indicate what action should be performed. + * @return keyword The keyword to indicate what action should be performed + */ public String getKeyword() { return keyword; } + /** + * Sets the properties that should be altered. + * @param properties The properties that should be altered + */ public void setProperties(Set properties) { this.properties = properties; } + /** + * Returns the properties that should be altered. + * @return properties The properties that should be altered + */ public Set getProperties() { return properties; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/NotificationAnswer.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/NotificationAnswer.java index a48033f..e6eb12d 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/NotificationAnswer.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/NotificationAnswer.java @@ -2,17 +2,30 @@ package pp.monopoly.message.client; import com.jme3.network.serializing.Serializable; +/** + * Sent by the client to answer a notification. + */ @Serializable public class NotificationAnswer extends ClientMessage{ + /** The keyword to indicate the awnser */ private String keyword; + /** No-Args constructor for serilization */ private NotificationAnswer() {} + /** + * Create a new NotificationAnswer + * @param keyword the keyword to indicate the awnser + */ public NotificationAnswer(String keyword) { this.keyword = keyword; } + /** + * Get the keyword to indicate the awnser + * @return the keyword to indicate the awnser + */ public String getKeyword() { return keyword; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/PlayerReady.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/PlayerReady.java index b77ad27..9d710fb 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/PlayerReady.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/PlayerReady.java @@ -31,18 +31,34 @@ public class PlayerReady extends ClientMessage { this.startMoney = startMoney; } + /** + * Returns the name of the player. + * @return the name of the player + */ public String getName() { return name; } + /** + * Returns the figure of the player. + * @return the figure of the player + */ public String getFigure() { return figure; } + /** + * Returns whether the player is ready. + * @return whether the player is ready + */ public boolean isReady() { return isReady; } + /** + * Returns the initial capital of the game. + * @return the initial capital of the game + */ public int getStartMoney() { return startMoney; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/TradeOffer.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/TradeOffer.java index 3ae8aa7..aba6898 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/TradeOffer.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/TradeOffer.java @@ -25,6 +25,11 @@ public class TradeOffer extends ClientMessage{ this.tradehandler = tradehandler; } + /** + * Returns the tradehandler. + * + * @return the tradehandler + */ public TradeHandler getTradeHandler() { return tradehandler; } @Override diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/ViewAssetsRequest.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/ViewAssetsRequest.java index cae016e..39d903a 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/ViewAssetsRequest.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/client/ViewAssetsRequest.java @@ -8,8 +8,10 @@ import com.jme3.network.serializing.Serializable; @Serializable public class ViewAssetsRequest extends ClientMessage{ - public ViewAssetsRequest() { - } + /** + * Constructor needed for the serialization. + */ + public ViewAssetsRequest() {} @Override public void accept(ClientInterpreter interpreter, int from) { diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/BuildInfo.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/BuildInfo.java index 72a3a9c..c18ac65 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/BuildInfo.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/BuildInfo.java @@ -2,26 +2,44 @@ package pp.monopoly.message.server; import com.jme3.network.serializing.Serializable; - +/** + * Sent from server to client to inform about a build action. + */ @Serializable public class BuildInfo extends ServerMessage { + /** Id of the field that was altered */ private final int id; + /** True if a house/hotel was added, false if it was removed */ private final boolean added; + /** No-args constructor required for serialization */ private BuildInfo() { this(0, false); } + /** + * Create a new BuildInfo message. + * @param id Id of the field that was altered + * @param added True if a house/hotel was added, false if it was removed + */ public BuildInfo(int id, boolean added) { this.id = id; this.added = added; } + /** + * Get the id of the field that was altered. + * @return Id of the field that was altered + */ public int getId() { return id; } + /** + * Check if a house/hotel was added. + * @return True if a house/hotel was added, false if it was removed + */ public boolean isAdded() { return added; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/BuyPropertyRequest.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/BuyPropertyRequest.java index 5384a93..9e8968d 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/BuyPropertyRequest.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/BuyPropertyRequest.java @@ -2,6 +2,9 @@ package pp.monopoly.message.server; import com.jme3.network.serializing.Serializable; +/** + * Sent by the server to the client to request the client to show a buy property popup. + */ @Serializable public class BuyPropertyRequest extends ServerMessage{ diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/DiceResult.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/DiceResult.java index b958c8c..73f0912 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/DiceResult.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/DiceResult.java @@ -4,10 +4,15 @@ import java.util.List; import com.jme3.network.serializing.Serializable; +/** + * Sent by the server to the client to inform the client about the result of a dice roll. + */ @Serializable public class DiceResult extends ServerMessage{ + /** The first value of the DiceRoll */ private final int a; + /** The second value of the DiceRoll */ private final int b; /** @@ -18,11 +23,20 @@ public class DiceResult extends ServerMessage{ b = 1; } + /** + * Creates a new DiceResult with the given values. + * @param a The first value of the DiceRoll + * @param b The second value of the DiceRoll + */ public DiceResult(int a, int b) { this.a = a; this.b = b; } + /** + * Returns the values of the DiceRoll. + * @return The values of the DiceRoll + */ public List getRollResult() { return List.of(a,b); } @@ -31,11 +45,19 @@ public class DiceResult extends ServerMessage{ public void accept(ServerInterpreter interpreter) { interpreter.received(this); } - + + /** + * Returns whether the DiceRoll is a doublets. + * @return Whether the DiceRoll is a doublets + */ public boolean isDoublets() { return a == b; } + /** + * Returns the total value of the DiceRoll. + * @return The total value of the DiceRoll + */ public int calcTotal() { return a+b; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameOver.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameOver.java index 9fdcb80..631e60c 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameOver.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameOver.java @@ -2,8 +2,14 @@ package pp.monopoly.message.server; import com.jme3.network.serializing.Serializable; +/** + * Message to inform the player that the game is over and if he won or not. + */ @Serializable -public class GameOver extends ServerMessage{ +public class GameOver extends ServerMessage { + /** + * Whether the player is the winner. + */ private boolean isWinner; /** @@ -11,10 +17,20 @@ public class GameOver extends ServerMessage{ */ private GameOver() { /* empty */ } + /** + * Creates a new GameOver message. + * + * @param isWinner true if the player is the winner, false otherwise + */ public GameOver(boolean isWinner) { this.isWinner = isWinner; } + /** + * Returns whether the player is the winner. + * + * @return true if the player is the winner, false otherwise + */ public boolean isWinner() { return isWinner; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameStart.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameStart.java index 7d65ce6..842b87c 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameStart.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/GameStart.java @@ -7,6 +7,9 @@ import pp.monopoly.game.server.PlayerHandler; @Serializable public class GameStart extends ServerMessage{ + /** + * The PlayerHandler. This is the object that contains all the players and their information. + */ private PlayerHandler playerHandler; /** @@ -14,10 +17,20 @@ public class GameStart extends ServerMessage{ */ private GameStart() { /* empty */ } + /** + * Creates a new GameStart message. + * + * @param playerHandler the playerHandler + */ public GameStart(PlayerHandler playerHandler) { this.playerHandler = playerHandler; } + /** + * Returns the PlayerHandler. This is the object that contains all the players and their information. + * + * @return the playerHandler + */ public PlayerHandler getPlayerHandler() { return playerHandler; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/JailEvent.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/JailEvent.java index 4a808a2..365a2a6 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/JailEvent.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/JailEvent.java @@ -2,9 +2,13 @@ package pp.monopoly.message.server; import com.jme3.network.serializing.Serializable; +/** + * Message for the client to inform him that a player is going to jail or leaving jail. + */ @Serializable public class JailEvent extends ServerMessage{ + /** true if the player is going to jail, false if he is leaving jail */ private boolean goingToJail; /** @@ -12,10 +16,20 @@ public class JailEvent extends ServerMessage{ */ private JailEvent() { /* empty */ } + /** + * Creates a new JailEvent. + * + * @param goingToJail true if the player is going to jail, false if he is leaving jail + */ public JailEvent(boolean goingToJail) { this.goingToJail = goingToJail; } + /** + * Returns true if the player is going to jail, false if he is leaving jail. + * + * @return true if the player is going to jail, false if he is leaving jail + */ public boolean isGoingToJail() { return goingToJail; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/NextPlayerTurn.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/NextPlayerTurn.java index 6659e42..5383640 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/NextPlayerTurn.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/NextPlayerTurn.java @@ -2,14 +2,17 @@ package pp.monopoly.message.server; import com.jme3.network.serializing.Serializable; +/** + * Message to inform the clients that the next player's turn has started. + * The client should now enable the buttons for the current player. + */ @Serializable public class NextPlayerTurn extends ServerMessage{ /** * Default constructor for serialization purposes. */ - public NextPlayerTurn() { - } + public NextPlayerTurn() {} @Override public void accept(ServerInterpreter interpreter) { diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/NotificationMessage.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/NotificationMessage.java index 6cbcbb3..29426dc 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/NotificationMessage.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/NotificationMessage.java @@ -2,36 +2,68 @@ package pp.monopoly.message.server; import com.jme3.network.serializing.Serializable; +/** + * This class is used to send notifications to the client. The keyWord is used to identify the type of notification. + * The rentAmount is used to store the amount of rent that has to be paid and the rentOwner is used to store the id of the player that has to be paid. + */ @Serializable public class NotificationMessage extends ServerMessage{ + /** keyWord is used to identify the type of notification */ private final String keyWord; + /** rentAmount is used to store the amount of rent that has to be paid */ private int rentAmount; + /** rentOwner is used to store the id of the player that has to be paid */ private String rentOwner; + /** Default constructor needed for serializiaton */ private NotificationMessage(){ keyWord = null;} + /** + * Constructor for the NotificationMessage + * @param keyWord the keyWord that is used to identify the type of notification + */ public NotificationMessage(String keyWord) { this.keyWord = keyWord; } + /** + * Getter for the rentAmount + * @return the amount of rent that has to be paid + */ public int getRentAmount() { return rentAmount; } + /** + * Setter for the rentAmount + * @param rentAmount the amount of rent that has to be paid + */ public void setRentAmount(int rentAmount) { this.rentAmount = rentAmount; } + /** + * Setter for the rentOwnerId + * @param rentOwnerId the id of the player that has to be paid + */ public void setRentOwnerId(String rentOwnerId) { this.rentOwner = rentOwnerId; } + /** + * Getter for the rentOwnerId + * @return the id of the player that has to be paid + */ public String getRentOwner() { return rentOwner; } + /** + * Getter for the keyWord + * @return the keyWord that is used to identify the type of notification + */ public String getKeyWord() { return keyWord; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/PlayerStatusUpdate.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/PlayerStatusUpdate.java index 78fdda6..c6752d3 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/PlayerStatusUpdate.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/PlayerStatusUpdate.java @@ -4,6 +4,9 @@ import com.jme3.network.serializing.Serializable; import pp.monopoly.game.server.PlayerHandler; +/** + * Message for updating the status of a player. + */ @Serializable public class PlayerStatusUpdate extends ServerMessage{ @@ -14,10 +17,20 @@ public class PlayerStatusUpdate extends ServerMessage{ */ private PlayerStatusUpdate() { /* empty */ } + /** + * Creates a new PlayerStatusUpdate. + * + * @param playerHandler the playerHandler + */ public PlayerStatusUpdate(PlayerHandler playerHandler) { this.playerHandler = playerHandler; } + /** + * Returns the playerHandler. + * + * @return the playerHandler + */ public PlayerHandler getPlayerHandler() { return playerHandler; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TimeOutWarning.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TimeOutWarning.java index 0635640..1a305ec 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TimeOutWarning.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TimeOutWarning.java @@ -2,9 +2,15 @@ package pp.monopoly.message.server; import com.jme3.network.serializing.Serializable; +/** + * Send to the client to inform the player that he has only a certain amount of time left to make his move. + */ @Serializable public class TimeOutWarning extends ServerMessage{ - + + /** + * Remaining time in seconds. + */ private int remainingTime; /** @@ -12,10 +18,18 @@ public class TimeOutWarning extends ServerMessage{ */ private TimeOutWarning() { /* empty */ } + /** + * Create a new TimeOutWarning message. + * @param remainingTime Remaining time in seconds. + */ public TimeOutWarning(int remainingTime) { this.remainingTime = remainingTime; } + /** + * Get the remaining time in seconds. + * @return Remaining time in seconds. + */ public int getRemainingTime() { return remainingTime; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeReply.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeReply.java index c2e33fc..378a44f 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeReply.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeReply.java @@ -28,7 +28,18 @@ public class TradeReply extends ServerMessage{ this.tradeHandler = tradeHandler; } + /** + * Returns whether the trade was accepted. + * + * @return true if the trade was accepted, false otherwise + */ public boolean isAccepted() { return status; } + + /** + * Returns the TradeHandler corresponding to the trade. + * + * @return the TradeHandler corresponding to the trade + */ public TradeHandler getTradeHandler() { return tradeHandler; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeRequest.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeRequest.java index 097f193..bcb4b80 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeRequest.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/TradeRequest.java @@ -26,6 +26,11 @@ public class TradeRequest extends ServerMessage{ this.tradehandler = tradehandler; } + /** + * Returns the tradehandler. + * + * @return the tradehandler + */ public TradeHandler getTradeHandler() { return tradehandler; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/ViewAssetsResponse.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/ViewAssetsResponse.java index 6098351..d3b9dcd 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/ViewAssetsResponse.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/message/server/ViewAssetsResponse.java @@ -32,6 +32,11 @@ public class ViewAssetsResponse extends ServerMessage{ interpreter.received(this); } + /** + * Returns the BoardManager representing the current Status + * + * @return the BoardManager representing the current Status + */ public BoardManager getboard() { return board; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Board.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Board.java index eecc7f5..598cbb0 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Board.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Board.java @@ -11,51 +11,52 @@ import pp.monopoly.notification.ItemAddedEvent; import pp.monopoly.notification.ItemRemovedEvent; /** - * Represents a rectangular map that holds figures and registers houses, hotels + * Represents a rectangular board that holds figures and registers houses, hotels * It also supports event notification for game state changes such as item addition or removal. - * Valid positions on this map have x-coordinates in the range of 0 to width-1 and y-coordinates - * in the range of 0 to height-1. - * - * @see #getWidth() - * @see #getHeight() */ public class Board { /** - * A list of items (figure, house, etc.) placed on the map. + * A list of items (figure, house, etc.) placed on the board. */ private final List items = new ArrayList<>(); /** * The broker responsible for notifying registered listeners of events - * (such as when an item is added or removed from the map). + * (such as when an item is added or removed from the board). * Can be null, in which case no notifications will be sent. */ private final GameEventBroker eventBroker; + /** + * The width (number of columns) of the board. + */ private final int width; + /** + * The height (number of rows) of the board. + */ private final int height; /** - * Constructs an empty map with the given dimensions. The specified event broker - * will handle the notification of changes in the map state, such as adding or removing items. + * Constructs an empty board with the given dimensions. The specified event broker + * will handle the notification of changes in the board state, such as adding or removing items. * Passing null as the event broker is allowed, but in that case, no notifications will occur. * - * @param width the number of columns (width) of the map - * @param height the number of rows (height) of the map + * @param width the number of columns (width) of the board + * @param height the number of rows (height) of the board * @param eventBroker the event broker used for notifying listeners, or null if event distribution is not needed */ public Board(int width, int height, GameEventBroker eventBroker) { if (width < 1 || height < 1) - throw new IllegalArgumentException("Invalid map size"); + throw new IllegalArgumentException("Invalid board size"); this.width = width; this.height = height; this.eventBroker = eventBroker; } /** - * Adds an item (e.g., a figure or a house) to the map and triggers the appropriate event. + * Adds an item (e.g., a figure or a house) to the board and triggers the appropriate event. * - * @param item the item to be added to the map + * @param item the item to be added to the board */ private void addItem(Item item) { items.add(item); @@ -63,36 +64,36 @@ public class Board { } /** - * Adds a figure to the map and triggers an item addition event. + * Adds a figure to the board and triggers an item addition event. * - * @param figure the figure to be added to the map + * @param figure the figure to be added to the board */ public void add(Figure figure) { addItem(figure); } /** - * Adds a house to the map and triggers an item addition event. + * Adds a house to the board and triggers an item addition event. * - * @param house the house to be added to the map + * @param house the house to be added to the board */ public void add(House house) { addItem(house); } /** - * Adds a hotel to the map and triggers an item addition event. + * Adds a hotel to the board and triggers an item addition event. * - * @param hotel the hotel to be added to the map + * @param hotel the hotel to be added to the board */ public void add(Hotel hotel) { addItem(hotel); } /** - * Removes an item from the map and triggers an item removal event. + * Removes an item from the board and triggers an item removal event. * - * @param item the item to be removed from the map + * @param item the item to be removed from the board */ public void remove(Item item) { items.remove(item); @@ -104,7 +105,7 @@ public class Board { } /** - * Removes all items from the map and triggers corresponding removal events for each. + * Removes all items from the board and triggers corresponding removal events for each. */ public void clear() { new ArrayList<>(items).forEach(this::remove); @@ -122,46 +123,62 @@ public class Board { } /** - * Returns a stream of all figures currently on the map. + * Returns a stream of all figures currently on the board. * - * @return a stream of all figures on the map + * @return a stream of all figures on the board */ public Stream
getFigures() { return getItems(Figure.class); } /** - * Returns a stream of all houses currently on the map. + * Returns a stream of all houses currently on the board. * - * @return a stream of all houses on the map + * @return a stream of all houses on the board */ public Stream getHouses() { return getItems(House.class); } + /** + * Returns the house on the specified field and stage. + * @param fieldId the id at which the house is located + * @param stage the stage of the house + * @return the house on the specified field and stage, or null if no such house exists + */ public House getHouse(int fieldId, int stage) { return getHouses().filter(house -> house.getFieldID() == fieldId && house.getStage() == stage).findFirst().orElse(null); } + /** + * Returns the hotel on the specified field. + * @param fieldId the id at which the hotel is located + * @return the hotel on the specified field, or null if no such hotel exists + */ public Hotel getHotel(int fieldId) { return getHotels().filter(hotel -> hotel.getFieldID() == fieldId).findFirst().orElse(null); } + /** + * Returns the figure with the specified id. + * @param playerId the id of the figure + * @return the figure with the specified id, or null if no such figure exists + */ public Figure getFigure(int playerId) { return getFigures().filter(figure -> figure.getId() == playerId).findFirst().orElse(null); } /** - * Returns a stream of all hotels currently on the map. + * Returns a stream of all hotels currently on the board. * - * @return a stream of all hotels on the map + * @return a stream of all hotels on the board */ public Stream getHotels() { return getItems(Hotel.class); } /** - * Returns an unmodifiable list of all items currently on the map. + * Returns an unmodifiable list of all items currently on the board. * * @return an unmodifiable list of all items */ @@ -170,27 +187,27 @@ public class Board { } /** - * Returns the width (number of columns) of the map. + * Returns the width (number of columns) of the board. * - * @return the width of the map + * @return the width of the board */ public int getWidth() { return width; } /** - * Returns the height (number of rows) of the map. + * Returns the height (number of rows) of the board. * - * @return the height of the map + * @return the height of the board */ public int getHeight() { return height; } /** - * Returns a string representation of the map. + * Returns a string representation of the board. * - * @return a string representation of the map + * @return a string representation of the board */ @Override public String toString() { diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/FieldVisitor.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/FieldVisitor.java index 2755ba7..4094b23 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/FieldVisitor.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/FieldVisitor.java @@ -10,14 +10,71 @@ import pp.monopoly.model.fields.GulagField; import pp.monopoly.model.fields.TestStreckeField; import pp.monopoly.model.fields.WacheField; +/** + * Interface for the visitor pattern for the fields. + * @param The return type of the visit methods. + */ public interface FieldVisitor { + /** + * Visit method for the field. + * @param field The BuildingProperty to visit. + * @return The return value of the visit method. + */ T visit(BuildingProperty field); + + /** + * Visit method for the field. + * @param field The FoodField to visit. + * @return The return value of the visit method. + */ T visit(FoodField field); + + /** + * Visit method for the field. + * @param field The GateField to visit. + * @return The return value of the visit method. + */ T visit(GateField field); + + /** + * Visit method for the field. + * @param field The GulagField to visit. + * @return The return value of the visit method. + */ T visit(GulagField field); + + /** + * Visit method for the field. + * @param field The TestStreckeField to visit. + * @return The return value of the visit method. + */ T visit(TestStreckeField field); + + /** + * Visit method for the field. + * @param field The EventField to visit. + * @return The return value of the visit method. + */ T visit(EventField field); + + /** + * Visit method for the field. + * @param field The WacheField to visit. + * @return The return value of the visit method. + */ T visit(WacheField field); + + /** + * Visit method for the field. + * @param field The GoField to visit. + * @return The return value of the visit method. + */ T visit(GoField field); + + /** + * Visit method for the field. + * @param field The FineField to visit. + * @return The return value of the visit method. + */ T visit(FineField field); } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Figure.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Figure.java index 6919997..0d38efc 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Figure.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/Figure.java @@ -5,13 +5,20 @@ import java.util.Random; import com.jme3.math.Vector3f; import com.jme3.network.serializing.Serializable; +/** + * Represents a figure that can be moved on the game board. A figure has a position and a rotation. + */ @Serializable public class Figure implements Item{ + /** The id of the figure, corresponging to the id of the player it represents */ private final int id; + /** The type of the figure */ private final String type; + /** The position of the Figure */ private Vector3f position; - private Rotation rot; // The rotation of the Figure + /** The rotation of the Figure */ + private Rotation rot; /** * Default constructor for serialization. Initializes a Figure with length 0, @@ -98,6 +105,12 @@ public class Figure implements Item{ moveTo(calculateFieldPosition(fieldId)); } + /** + * Calculates the position of a field on the board. + * + * @param fieldID the ID of the field + * @return the position of the field + */ public Vector3f calculateFieldPosition(int fieldID) { float baseX = 0.0f; float baseZ = 0.0f; @@ -153,6 +166,11 @@ public class Figure implements Item{ return new Vector3f(baseX , 0, baseZ ); } + /** + * Returns the ID of the field the Figure is currently on. + * + * @return the ID of the current field + */ public int getCurrentFieldID() { Vector3f pos = getPos(); for (int fieldID = 0; fieldID < 40; fieldID++) { @@ -206,17 +224,15 @@ public class Figure implements Item{ return visitor.visit(this); } - /** - * Accepts a visitor that does not return a value. This method is part of the - * Visitor design pattern. - * - * @param visitor the visitor to accept - */ @Override public void accept(VoidVisitor visitor) { visitor.visit(this); } + /** + * Returns the type of the figure + * @return the type of the figure + */ public String getType() { return type; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/TradeHandler.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/TradeHandler.java index 4161b5f..e03f574 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/TradeHandler.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/TradeHandler.java @@ -15,15 +15,27 @@ import com.jme3.network.serializing.Serializable; @Serializable public class TradeHandler { + /** The player initialing the trade */ private final Player sender; + /** The player receiving the trade offer */ private Player receiver; + /** The amount of money offered by the sender */ private int offeredAmount; + /** The properties offered by the sender */ private Set offeredProperties = new HashSet<>(); + /** The jail cards offered by the sender */ private int offeredJailCards; + /** The amount of money requested from the receiver */ private int requestedAmount; + /** The properties requested from the receiver */ private Set requestedProperties = new HashSet<>(); + /** The jail cards requested from the receiver */ private int requestedJailCards; + /** + * Constructs a TradeHandler with no trade details. + * Used for serialization. + */ private TradeHandler() { sender = null; } @@ -52,7 +64,7 @@ public class TradeHandler { this.requestedJailCards = requestedJailCards; } - /** + /** * Constructs a TradeHandler for a single trade instance. * * @param sender the Player initiating the trade @@ -61,62 +73,122 @@ public class TradeHandler { this.sender = sender; } + /** + * Returns the offered amount of money. + * @return the offered amount of money + */ public int getOfferedAmount() { return offeredAmount; } + /** + * Returns the offered amount of jail cards. + * @return the offered amount of jail cards + */ public int getOfferedJailCards() { return offeredJailCards; } + /** + * Returns the offered properties. + * @return the offered properties + */ public Set getOfferedProperties() { return offeredProperties; } + /** + * Returns the receiving player. + * @return the receiving player + */ public Player getReceiver() { return receiver; } + /** + * Returns the requested amount of money. + * @return the requested amount of money + */ public int getRequestedAmount() { return requestedAmount; } + /** + * Returns the requested amount of jail cards. + * @return the requested amount of jail cards + */ public int getRequestedJailCards() { return requestedJailCards; } + /** + * Returns the requested properties. + * @return the requested properties + */ public Set getRequestedProperties() { return requestedProperties; } + /** + * Returns the sending player. + * @return the sending player + */ public Player getSender() { return sender; } + /** + * Sets the offered amount of money. + * @param offeredAmount the offered amount of money + */ public void setOfferedAmount(int offeredAmount) { this.offeredAmount = offeredAmount; } + /** + * Sets the offered amount of jail cards. + * @param offeredJailCards the offered amount of jail cards + */ public void setOfferedJailCards(int offeredJailCards) { this.offeredJailCards = offeredJailCards; } + /** + * Sets the offered properties. + * @param offeredProperties the offered properties + */ public void setOfferedProperties(Set offeredProperties) { this.offeredProperties = offeredProperties; } + /** + * Sets the receiving player. + * @param receiver the receiving player + */ public void setReceiver(Player receiver) { this.receiver = receiver; } + /** + * Sets the requested amount of money. + * @param requestedAmount the requested amount of money + */ public void setRequestedAmount(int requestedAmount) { this.requestedAmount = requestedAmount; } + /** + * Sets the requested amount of jail cards. + * @param requestedJailCards the requested amount of jail cards + */ public void setRequestedJailCards(int requestedJailCards) { this.requestedJailCards = requestedJailCards; } + /** + * Sets the requested properties. + * @param requestedProperties the requested properties + */ public void setRequestedProperties(Set requestedProperties) { this.requestedProperties = requestedProperties; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/card/Card.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/card/Card.java index efcd55c..1370566 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/card/Card.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/card/Card.java @@ -2,23 +2,50 @@ package pp.monopoly.model.card; import pp.monopoly.game.server.Player; +/** + * Represents a event card in the game. + */ public class Card { + /** Description of the card */ private final String description; + /** Keyword of the card */ private final String keyword; + /** + * Constructs a card with a description and a keyword. + * + * @param description the description of the card + * @param keyword the keyword of the card + */ Card(String description, String keyword) { this.description = description; this.keyword = keyword; } + /** + * Accepts a visitor and calls the visit method of the visitor. + * + * @param visitor the visitor + * @param player the player + */ public void accept(DeckHelper visitor, Player player) { visitor.visit(this, player); } + /** + * Returns the description of the card. + * + * @return the description of the card + */ public String getDescription() { return description; - } // TODO wird gerade in der EventCard zur erstellung des Popup genutzt + } + /** + * Returns the keyword of the card. + * + * @return the keyword of the card + */ public String getKeyword() { return keyword; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/card/DeckHelper.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/card/DeckHelper.java index c2b5f1a..5aa1459 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/card/DeckHelper.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/card/DeckHelper.java @@ -10,11 +10,19 @@ import pp.monopoly.game.server.Player; import pp.monopoly.message.client.EndTurn; import pp.monopoly.message.server.NotificationMessage; +/** + * Helper class for the deck of cards. + */ public class DeckHelper{ + /** The deck of cards */ private Queue cards; + /** The drawn cards */ private List drawn = new ArrayList<>(); + /** + * Constructor for the deck helper. + */ public DeckHelper() { cards = new LinkedList(); cards.add(new Card("Du wurdest mit einem Dienst KFZ geblitzt. Zahle 800 EUR", "dienst-kfz-blitzer")); @@ -53,6 +61,11 @@ public class DeckHelper{ shuffle(); } + /** + * Triggers the specified method for each card action + * @param card the card to be triggered + * @param player the player triggering it + */ public void visit(Card card, Player player) { switch (card.getKeyword()) { case "dienst-kfz-blitzer": @@ -320,6 +333,9 @@ public class DeckHelper{ } + /** + * Shuffles the deck of cards. + */ private void shuffle() { List cardList = new ArrayList<>(cards); Collections.shuffle(cardList); @@ -327,6 +343,10 @@ public class DeckHelper{ cards.addAll(cardList); } + /** + * Draws a card from the deck. + * @return the drawn card + */ public Card drawCard() { if (cards.isEmpty()) { drawn.forEach(cards::add); diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/ButtonStatusEvent.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/ButtonStatusEvent.java index 96a649f..81cb088 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/ButtonStatusEvent.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/ButtonStatusEvent.java @@ -1,11 +1,12 @@ package pp.monopoly.notification; +/** + * Event that is sent when the buttons should be enabled or disabled. + * + * @param buttonsEnabled true if the buttons should be enabled, false if they should be disabled + */ public record ButtonStatusEvent(boolean buttonsEnabled) implements GameEvent{ - /** - * Notifies the game event listener of this event. - * - * @param listener the game event listener - */ + @Override public void notifyListener(GameEventListener listener) { listener.receivedEvent(this); diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/DiceRollEvent.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/DiceRollEvent.java index ad54906..76ccb06 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/DiceRollEvent.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/DiceRollEvent.java @@ -1,5 +1,11 @@ package pp.monopoly.notification; +/** + * Event that is sent when the dice are rolled. + * + * @param a the first number of the dice roll + * @param b the second number of the dice roll + */ public record DiceRollEvent(int a, int b) implements GameEvent{ @Override diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/EventCardEvent.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/EventCardEvent.java index 2f6a16c..13dc89b 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/EventCardEvent.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/EventCardEvent.java @@ -1,5 +1,10 @@ package pp.monopoly.notification; +/** + * EventCardEvent is a class that represents an event that is sent to the GameEventListener when a player draws an event card. + * + * @param description the description of the card that was drawn + */ public record EventCardEvent(String description) implements GameEvent{ @Override diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/InfoTextEvent.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/InfoTextEvent.java index 6084e80..ebdc755 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/InfoTextEvent.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/InfoTextEvent.java @@ -13,11 +13,7 @@ package pp.monopoly.notification; * @param key the bundle key for the message */ public record InfoTextEvent(String key) implements GameEvent { - /** - * Notifies the game event listener of this event. - * - * @param listener the game event listener - */ + @Override public void notifyListener(GameEventListener listener) { listener.receivedEvent(this); diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/ItemAddedEvent.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/ItemAddedEvent.java index 5f1cee7..aeea9b0 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/ItemAddedEvent.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/ItemAddedEvent.java @@ -5,6 +5,9 @@ import pp.monopoly.model.Item; /** * Event that is triggered when an item is added to a board. + * + * @param board the board to which the item was added + * @param item the item that was added */ public record ItemAddedEvent(Board board, Item item) implements GameEvent { diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/ItemRemovedEvent.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/ItemRemovedEvent.java index 29d968e..c0ff252 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/ItemRemovedEvent.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/ItemRemovedEvent.java @@ -5,6 +5,9 @@ import pp.monopoly.model.Item; /** * Event that is triggered when an item is removed from a board. + * + * @param board the board from which the item was removed + * @param item the item that was removed */ public record ItemRemovedEvent(Board board, Item item) implements GameEvent { diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/PopUpEvent.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/PopUpEvent.java index f53474e..849c121 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/PopUpEvent.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/PopUpEvent.java @@ -2,6 +2,12 @@ package pp.monopoly.notification; import pp.monopoly.message.server.ServerMessage; +/** + * Event that is used to show a popup message to the user. + * + * @param msg a keyword to indicate the type of message + * @param message the message that should be shown + */ public record PopUpEvent(String msg, ServerMessage message) implements GameEvent{ @Override diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/SoundEvent.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/SoundEvent.java index 2eaaefe..c830e56 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/SoundEvent.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/SoundEvent.java @@ -14,11 +14,6 @@ package pp.monopoly.notification; */ public record SoundEvent(Sound sound) implements GameEvent { - /** - * Notifies the game event listener of this event. - * - * @param listener the game event listener - */ @Override public void notifyListener(GameEventListener listener) { listener.receivedEvent(this); diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/UpdatePlayerView.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/UpdatePlayerView.java index af3cad1..afaca40 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/UpdatePlayerView.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/notification/UpdatePlayerView.java @@ -1,11 +1,10 @@ package pp.monopoly.notification; +/** + * This class is used to notify the view that the player's information has been updated. + */ public record UpdatePlayerView() implements GameEvent{ - /** - * Notifies the game event listener of this event. - * - * @param listener the game event listener - */ + @Override public void notifyListener(GameEventListener listener) { listener.receivedEvent(this);