From ec4fe1cf441a5a71042849800b910233142b9cd5 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Sat, 2 May 2026 18:36:26 +0200 Subject: [PATCH] Add: JavaDOC to all NetworkEvent --- .../ingsw/gc14/Network/NetworkEvent.java | 47 ++++++++++++++----- .../gc14/Network/NetworkEvents/AddPlayer.java | 22 +++++++-- .../NetworkEvents/DrawLowerBuildingCard.java | 18 +++++-- .../NetworkEvents/DrawLowerTribeCard.java | 18 +++++-- .../NetworkEvents/DrawUpperBuildingCard.java | 19 ++++++-- .../NetworkEvents/DrawUpperTribeCard.java | 19 ++++++-- .../Network/NetworkEvents/NoOptionalCard.java | 16 +++++-- .../PickOptionalBuildingCard.java | 19 ++++++-- .../NetworkEvents/PickOptionalTribeCard.java | 20 ++++++-- .../gc14/Network/NetworkEvents/SkipLower.java | 16 +++++-- .../gc14/Network/NetworkEvents/SkipUpper.java | 15 ++++-- .../Network/NetworkEvents/SlotChoice.java | 19 ++++++-- .../gc14/Network/RMI/Client/RMIClient.java | 1 + 13 files changed, 196 insertions(+), 53 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvent.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvent.java index e38e7a3..6d6a159 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvent.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvent.java @@ -4,39 +4,60 @@ import it.polimi.ingsw.gc14.Controller.GameController; import java.io.Serializable; -//TODO javadoc +/** + * Represents an event sent over the network + */ public abstract class NetworkEvent implements Serializable { - //TODO javadoc + /** Username of the player requesting the event */ protected String username; - //TODO javadoc + /** + * @return the username of the player requesting the event + */ public String getUsername() { return username; } - //TODO javadoc + /** EventType of the event */ protected EventType eventType; - //TODO javadoc + /** + * @return the type of the event + */ public EventType getEventType() {return eventType;} - //TODO javadoc + /** Flag signaling whether the event could not be applied to the server model */ protected boolean isError; - //TODO javadoc + /** + * @return the flag signaling whether the event could be applied to the server model + */ public boolean getIsError() {return isError;} - //TODO javadoc + /** + * Set the isError flag. + * @param isError the value to set + */ public void setIsError(boolean isError) {this.isError = isError;} - //TODO javadoc + + /** + * Class constructor. + * Initializes all attributes. + * @param username the username of the player requesting the event + * @param eventType the type of the event + * @param isError the flag signaling if the event could be applied to the server model + */ protected NetworkEvent(String username, EventType eventType, boolean isError) { this.username = username; this.eventType = eventType; this.isError = isError; } - //TODO javadoc + + /** + * @return a string describing the name of the event and whether it is an error or not + */ @Override public String toString() { if(isError) { @@ -46,6 +67,10 @@ public abstract class NetworkEvent implements Serializable { } } - //TODO javadoc + /** + * The method to apply the current event to the specified Game Controller. + * @param gameController the Game Controller on which to apply the event + * @return true if the event could be applied; false otherwise + */ public abstract boolean apply(GameController gameController); } diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/AddPlayer.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/AddPlayer.java index 14acd88..607d3e9 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/AddPlayer.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/AddPlayer.java @@ -7,23 +7,35 @@ import it.polimi.ingsw.gc14.View.IView; import java.io.Serializable; -//TODO javadoc +/** + * NetworkEvent to add a player. + */ public class AddPlayer extends NetworkEvent implements Serializable { - //TODO javadoc + /** Number of proposed players to add to the match */ private int proposedNPlayer; - //TODO javadoc + /** + * @return the number of proposed players to add to the match + */ public int getProposedNPlayer() { return proposedNPlayer; } - //TODO javadoc + /** + * Class constructor. + * Initializes all the attributes. + * @param username the name of the player requesting the event + * @param proposedNPlayer the number of proposed players to add to the match + */ public AddPlayer(String username, int proposedNPlayer) { super(username, EventType.ADD_PLAYER, false); this.proposedNPlayer = proposedNPlayer; } - //TODO javadoc + /** + * @param gameController the Game Controller on which to apply the event + * @return true if the player could be added to the match, false otherwise + */ @Override public boolean apply(GameController gameController) { diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerBuildingCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerBuildingCard.java index 91b67af..b2499cf 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerBuildingCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerBuildingCard.java @@ -7,18 +7,28 @@ import it.polimi.ingsw.gc14.View.IView; import java.io.Serializable; -//TODO javadoc +/** + * NetworkEvent to draw a building card from the lower card list. + */ public class DrawLowerBuildingCard extends NetworkEvent implements Serializable{ - //TODO javadoc + /** Index of the card to draw */ private int pos; - //TODO javadoc + /** + * Class constructor. + * Initialized all the attributes. + * @param username the name of the player requesting the event + * @param pos the index of the card to draw + */ public DrawLowerBuildingCard(String username, int pos){ super(username, EventType.DRAW_LOWER_BUILD, false); this.pos = pos; } - //TODO javadoc + /** + * @param gameController the Game Controller on which to apply the event + * @return true if the player could draw the card, false otherwise + */ @Override public boolean apply(GameController gameController){ return gameController.drawLowerBuildingCard(username, pos); diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerTribeCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerTribeCard.java index 0dda4d1..d06c34e 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerTribeCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerTribeCard.java @@ -7,17 +7,29 @@ import it.polimi.ingsw.gc14.View.IView; import java.io.Serializable; +/** + * NetworkEvent to draw a tribe card from the lower card list. + */ public class DrawLowerTribeCard extends NetworkEvent implements Serializable{ - //TODO javadoc + + /** Index of the card to draw */ private int pos; - //TODO javadoc + /** + * Class constructor. + * Initialized all the attributes. + * @param username the name of the player requesting the event + * @param pos the index of the card to draw + */ public DrawLowerTribeCard(String username, int pos){ super(username, EventType.DRAW_LOWER_TRIBE, false); this.pos = pos; } - //TODO javadoc + /** + * @param gameController the Game Controller on which to apply the event + * @return true if the player could draw the card, false otherwise + */ @Override public boolean apply(GameController gameController){ return gameController.drawLowerTribeCard(username, pos); diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperBuildingCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperBuildingCard.java index 077bc74..1da744e 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperBuildingCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperBuildingCard.java @@ -7,18 +7,29 @@ import it.polimi.ingsw.gc14.View.IView; import java.io.Serializable; -//TODO javadoc +/** + * NetworkEvent to draw a building card from the upper card list. + */ public class DrawUpperBuildingCard extends NetworkEvent implements Serializable{ - //TODO javadoc + + /** Index of the card to draw */ private int pos; - //TODO javadoc + /** + * Class constructor. + * Initialized all the attributes. + * @param username the name of the player requesting the event + * @param pos the index of the card to draw + */ public DrawUpperBuildingCard(String username, int pos){ super(username, EventType.DRAW_UPPER_BUILD, false); this.pos = pos; } - //TODO javadoc + /** + * @param gameController the Game Controller on which to apply the event + * @return true if the player could draw the card, false otherwise + */ @Override public boolean apply(GameController gameController){ return gameController.drawUpperBuildingCard(username, pos); diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperTribeCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperTribeCard.java index 8fcb004..7794b10 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperTribeCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperTribeCard.java @@ -7,18 +7,29 @@ import it.polimi.ingsw.gc14.View.IView; import java.io.Serializable; -//TODO javadoc +/** + * NetworkEvent to draw a tribe card from the upper card list. + */ public class DrawUpperTribeCard extends NetworkEvent implements Serializable{ - //TODO javadoc + + /** Index of the card to draw */ private int pos; - //TODO javadoc + /** + * Class constructor. + * Initialized all the attributes. + * @param username the name of the player requesting the event + * @param pos the index of the card to draw + */ public DrawUpperTribeCard(String username, int pos){ super(username, EventType.DRAW_UPPER_TRIBE, false); this.pos = pos; } - //TODO javadoc + /** + * @param gameController the Game Controller on which to apply the event + * @return true if the player could draw the card, false otherwise + */ @Override public boolean apply(GameController gameController){ return gameController.drawUpperTribeCard(username, pos); diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/NoOptionalCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/NoOptionalCard.java index 9791962..6e5e328 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/NoOptionalCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/NoOptionalCard.java @@ -7,14 +7,24 @@ import it.polimi.ingsw.gc14.View.IView; import java.io.Serializable; -//TODO javadoc +/** + * NetworkEvent to avoid drawing a card from the upper list (see the effect of Building 12) + */ public class NoOptionalCard extends NetworkEvent implements Serializable{ - //TODO javadoc + + /** + * Class constructor. + * Initialized all the attributes. + * @param username the name of the player requesting the event + */ public NoOptionalCard(String username){ super(username, EventType.NO_OPTIONAL_CARD, false); } - //TODO javadoc + /** + * @param gameController the Game Controller on which to apply the event + * @return true if the player could draw the card, false otherwise + */ @Override public boolean apply(GameController gameController){ return gameController.noOptionalCard(username); diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/PickOptionalBuildingCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/PickOptionalBuildingCard.java index 1704082..dc3a420 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/PickOptionalBuildingCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/PickOptionalBuildingCard.java @@ -7,18 +7,29 @@ import it.polimi.ingsw.gc14.View.IView; import java.io.Serializable; -//TODO javadoc +/** + * NetworkEvent to draw a building card from the upper list (see the effect of Building 12) + */ public class PickOptionalBuildingCard extends NetworkEvent implements Serializable{ - //TODO javadoc + + /** Index of the card to draw */ private int pos; - //TODO javadoc + /** + * Class constructor. + * Initialized all the attributes. + * @param username the name of the player requesting the event + * @param pos the index of the card to draw + */ public PickOptionalBuildingCard(String username, int pos){ super(username, EventType.PICK_OPTIONAL_BUILD, false); this.pos = pos; } - //TODO javadoc + /** + * @param gameController the Game Controller on which to apply the event + * @return true if the player could draw the card, false otherwise + */ @Override public boolean apply(GameController gameController){ return gameController.pickOptionalBuildingCard(username, pos); diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/PickOptionalTribeCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/PickOptionalTribeCard.java index 0262b7f..8da74be 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/PickOptionalTribeCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/PickOptionalTribeCard.java @@ -7,19 +7,29 @@ import it.polimi.ingsw.gc14.View.IView; import java.io.Serializable; -//TODO javadoc - +/** + * NetworkEvent to draw a tribe card from the upper list (see the effect of Building 12) + */ public class PickOptionalTribeCard extends NetworkEvent implements Serializable{ - //TODO javadoc + + /** Index of the card to draw */ private int pos; - //TODO javadoc + /** + * Class constructor. + * Initialized all the attributes. + * @param username the name of the player requesting the event + * @param pos the index of the card to draw + */ public PickOptionalTribeCard(String username, int pos){ super(username, EventType.PICK_OPTIONAL_TRIBE, false); this.pos = pos; } - //TODO javadoc + /** + * @param gameController the Game Controller on which to apply the event + * @return true if the player could draw the card, false otherwise + */ @Override public boolean apply(GameController gameController){ return gameController.pickOptionalTribeCard(username, pos); diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SkipLower.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SkipLower.java index e962398..8001cb3 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SkipLower.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SkipLower.java @@ -7,14 +7,24 @@ import it.polimi.ingsw.gc14.View.IView; import java.io.Serializable; -//TODO javadoc +/** + * NetworkEvent to avoid drawing a card from the lower card list + */ public class SkipLower extends NetworkEvent implements Serializable{ - //TODO javadoc + + /** + * Class constructor. + * Initializes all the attributes. + * @param username the name of the player requesting the event + */ public SkipLower(String username){ super(username, EventType.SKIP_LOWER, false); } - //TODO javadoc + /** + * @param gameController the Game Controller on which to apply the event + * @return true if the player could draw the card, false otherwise + */ @Override public boolean apply(GameController gameController){ return gameController.SkipLowerDrawing(username); diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SkipUpper.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SkipUpper.java index 3faee82..2dccaba 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SkipUpper.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SkipUpper.java @@ -7,15 +7,24 @@ import it.polimi.ingsw.gc14.View.IView; import java.io.Serializable; -//TODO javadoc +/** + * NetworkEvent to avoid drawing a card from the upper card list + */ public class SkipUpper extends NetworkEvent implements Serializable{ - //TODO javadoc + /** + * Class constructor. + * Initializes all the attributes. + * @param username the name of the player requesting the event + */ public SkipUpper(String username){ super(username, EventType.SKIP_UPPER, false); } - //TODO javadoc + /** + * @param gameController the Game Controller on which to apply the event + * @return true if the player could draw the card, false otherwise + */ @Override public boolean apply(GameController gameController){ return gameController.SkipUpperDrawing(username); diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SlotChoice.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SlotChoice.java index 189e3ab..6de4ea0 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SlotChoice.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SlotChoice.java @@ -7,18 +7,29 @@ import it.polimi.ingsw.gc14.View.IView; import java.io.Serializable; -//TODO javadoc +/** + * NetworkEvent to select a slot where to place the player totem. + */ public class SlotChoice extends NetworkEvent implements Serializable { - //TODO javadoc + + /** Index of the card to draw */ private int pos; - //TODO javadoc + /** + * Class constructor. + * Initializes all the attributes. + * @param username the name of the player requesting the event + * @param pos the index of the card to draw + */ public SlotChoice(String username, int pos) { super(username, EventType.SLOT_CHOICE, false); this.pos = pos; } - //TODO javadoc + /** + * @param gameController the Game Controller on which to apply the event + * @return true if the player could draw the card, false otherwise + */ @Override public boolean apply(GameController gameController) { return gameController.slotChoice(username, pos); diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/RMIClient.java b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/RMIClient.java index 2d4c348..5cdbf37 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/RMIClient.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/RMIClient.java @@ -8,6 +8,7 @@ import it.polimi.ingsw.gc14.Network.IClient; import it.polimi.ingsw.gc14.Network.NetworkEvent; import it.polimi.ingsw.gc14.Network.RMI.Common.IClientCallback; import it.polimi.ingsw.gc14.Network.RMI.Common.IGameServer; +import it.polimi.ingsw.gc14.Network.RMI.Server.RMIServer; /** * Client RMI. Uses the methods exposed by the server RMI.