From e2c48ae59d04709c1cd6f0b4c1b2ec29f0d84546 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Sat, 2 May 2026 17:06:16 +0200 Subject: [PATCH 1/5] Fix: ClientContrioller JavaDOC --- .../gc14/Controller/ClientController.java | 129 +++++++++++------- 1 file changed, 79 insertions(+), 50 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java b/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java index c6b64bf..b3cc2fc 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java +++ b/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java @@ -7,127 +7,156 @@ import it.polimi.ingsw.gc14.Network.NetworkEvents.*; import it.polimi.ingsw.gc14.Network.Observer; import it.polimi.ingsw.gc14.View.IView; -//TODO Javadoc +/** + * Controller class that holds all the components of the client, such as view, network client and Game Controller. + * It provides methods to set the client components and to execute requested actions. + */ public class ClientController { + /** Game Controller of the client */ public GameController localController; - //TODO Javadoc - public IView view=null; + /** View of the client */ + public IView view; + + /** Network client (either TCP or RMI) */ private IClient client; + + /** + * Constructor of the class. Initializes all attributes. + * @param view The client view to set (either TUI or GUI). + */ public ClientController(IView view) { this.view = view; this.localController = new GameController(); + this.client = null; } + + + /** + * Method to set the network client. + * @param client The client to sei (either TCP or RMI) + */ public void setClient(IClient client) { this.client = client; } + + + /** + * Method to set the model in the Game Controller and in the view. + * @param model The model to set + */ public void setModel(Game model) { localController.setModel(model); view.update(localController.getModel()); } + + /** + * Method to show an error in the view. + * @param message The error message to show in the view + */ public void onError(String message) { view.showError(message); } + /** - * Attempts to draw an upper tribe card for the specified player from the specified position. - * - * @param playerUsername the username of the player performing the action. - * @param pos the position of the upper tribe card to draw. - * @return {@code true} if the action succeeds, {@code false} if the player does not exist - * or if the draw operation fails. + * Used to draw a tribe card from the upper list. + * Create a NetworkEvent and then sends it through the network client. + * @param playerUsername The name of the player who requested to perform the action + * @param pos Index of the card to draw */ - public void drawUpperTribeCard(String playerUsername,int pos) { + public void drawUpperTribeCard(String playerUsername, int pos) { client.doEvent(new DrawUpperTribeCard(playerUsername,pos)); } + /** - * Attempts to draw a lower tribe card for the specified player from the specified position. - * - * @param playerUsername the username of the player performing the action. - * @param pos the position of the lower tribe card to draw. - * @return {@code true} if the action succeeds, {@code false} if the player does not exist - * or if the draw operation fails. + * Used to draw a tribe card from the lower list. + * Create a NetworkEvent and then sends it through the network client. + * @param playerUsername The name of the player who requested to perform the action + * @param pos Index of the card to draw */ public void drawLowerTribeCard(String playerUsername,int pos) { client.doEvent(new DrawLowerTribeCard(playerUsername,pos)); } /** - * Attempts to draw an upper building card for the specified player from the specified position. - * - * @param playerUsername the username of the player performing the action. - * @param pos the position of the upper building card to draw. - * @return {@code true} if the action succeeds, {@code false} if the player does not exist - * or if the draw operation fails. + * Used to draw a building card from the upper list. + * Create a NetworkEvent and then sends it through the network client. + * @param playerUsername The name of the player who requested to perform the action + * @param pos Index of the card to draw */ public void drawUpperBuildingCard(String playerUsername,int pos) { client.doEvent(new DrawUpperBuildingCard(playerUsername,pos)); } /** - * Attempts to draw a lower building card for the specified player from the specified position. - * - * @param playerUsername the username of the player performing the action. - * @param pos the position of the lower building card to draw. - * @return {@code true} if the action succeeds, {@code false} if the player does not exist - * or if the draw operation fails. + * Used to draw a building card from the lower list. + * Create a NetworkEvent and then sends it through the network client. + * @param playerUsername The name of the player who requested to perform the action + * @param pos Index of the card to draw */ public void drawLowerBuildingCard(String playerUsername,int pos) { client.doEvent(new DrawLowerBuildingCard(playerUsername,pos)); } + + /** + * Used to skip the drawing action from the upper list. + * Available only when the upper list is empty (or the player can't draw any card). + * @param playerUsername The name of the player who requested to perform the action + */ public void skipUpper(String playerUsername) { client.doEvent(new SkipUpper(playerUsername)); } + + /** + * Used to skip the drawing action from the lower list. + * Available only when the lower list is empty (or the player can't draw any card). + * @param playerUsername The name of the player who requested to perform the action + */ public void skipLower(String playerUsername) { client.doEvent(new SkipLower(playerUsername));} /** - * Attempts to pick an optional tribe card for the specified player from the specified position. - * - * @param playerUsername the username of the player performing the action. - * @param pos the position of the optional tribe card to pick. - * @return {@code true} if the action succeeds, {@code false} if the player does not exist - * or if the pick operation fails. + * Used to draw a tribe card from the upper list. + * Available only if the player owns the building 12. + * @param playerUsername The name of the player who requested to perform the action + * @param pos Index of the card to draw */ public void pickOptionalTribeCard(String playerUsername,int pos) { client.doEvent(new PickOptionalTribeCard(playerUsername,pos)); } + /** - * Attempts to pick an optional building card for the specified player from the specified position. - * - * @param playerUsername the username of the player performing the action. - * @param pos the position of the optional building card to pick. - * @return {@code true} if the action succeeds, {@code false} if the player does not exist - * or if the pick operation fails. + * Used to draw a building card from the upper list. + * Available only if the player owns the building 12. + * @param playerUsername The name of the player who requested to perform the action + * @param pos Index of the card to draw */ public void pickOptionalBuildingCard(String playerUsername,int pos) { client.doEvent(new PickOptionalBuildingCard(playerUsername,pos)); } /** - * Refuse to pick an optional building card for the specified player. - * @param playerUsername the username of the player performing the action. - * @return {@code true} if the action succeeds, {@code false} if the player does not exist - * or if the pick operation fails. + * Used to skip the action of drawing a card from the upper list. + * Available only if the player owns the building 12. + * @param playerUsername The name of the player who requested to perform the action */ public void noOptionalCard(String playerUsername) { client.doEvent(new NoOptionalCard(playerUsername)); } + /** - * Attempts to perform the slot choice action for the specified player at the specified position. - * - * @param playerUsername the username of the player performing the action. - * @param pos the position of the chosen slot. - * @return {@code true} if the action succeeds, {@code false} if the player does not exist - * or if the slot choice operation fails. + * Used to sperform the slot choiche action for the specified player at the specified position. + * @param playerUsername The name of the player who requested to perform the action + * @param pos Index of the selected slot */ public void slotChoice(String playerUsername,int pos) { client.doEvent(new SlotChoice(playerUsername,pos)); From b8c6c86d9261c969c8b8e705f422b3b5ef6c18bc Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Sat, 2 May 2026 17:19:16 +0200 Subject: [PATCH 2/5] Fix: ClientContrioller JavaDOC more fluid --- .../gc14/Controller/ClientController.java | 80 ++++++++++--------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java b/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java index b3cc2fc..144435f 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java +++ b/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java @@ -24,8 +24,9 @@ public class ClientController { /** - * Constructor of the class. Initializes all attributes. - * @param view The client view to set (either TUI or GUI). + * Constructs the ClientController. + * Initializes all attributes. + * @param view the client view (either TUI or GUI) */ public ClientController(IView view) { this.view = view; @@ -35,8 +36,8 @@ public class ClientController { /** - * Method to set the network client. - * @param client The client to sei (either TCP or RMI) + * Sets the network client. + * @param client the client to set (either TCP or RMI) */ public void setClient(IClient client) { this.client = client; @@ -44,8 +45,8 @@ public class ClientController { /** - * Method to set the model in the Game Controller and in the view. - * @param model The model to set + * Sets the model in the GameController and updates the view. + * @param model the model to set */ public void setModel(Game model) { localController.setModel(model); @@ -54,8 +55,8 @@ public class ClientController { /** - * Method to show an error in the view. - * @param message The error message to show in the view + * Displays an error message in the view. + * @param message the error message to display */ public void onError(String message) { view.showError(message); @@ -63,10 +64,10 @@ public class ClientController { /** - * Used to draw a tribe card from the upper list. - * Create a NetworkEvent and then sends it through the network client. - * @param playerUsername The name of the player who requested to perform the action - * @param pos Index of the card to draw + * Requests to draw a tribe card from the upper list. + * Creates a NetworkEvent and sends it through the network client. + * @param playerUsername the name of the player performing the action + * @param pos the index of the card to draw */ public void drawUpperTribeCard(String playerUsername, int pos) { client.doEvent(new DrawUpperTribeCard(playerUsername,pos)); @@ -74,30 +75,32 @@ public class ClientController { /** - * Used to draw a tribe card from the lower list. - * Create a NetworkEvent and then sends it through the network client. - * @param playerUsername The name of the player who requested to perform the action - * @param pos Index of the card to draw + * Requests to draw a tribe card from the lower list. + * Creates a NetworkEvent and sends it through the network client. + * @param playerUsername the name of the player performing the action + * @param pos the index of the card to draw */ public void drawLowerTribeCard(String playerUsername,int pos) { client.doEvent(new DrawLowerTribeCard(playerUsername,pos)); } + /** - * Used to draw a building card from the upper list. - * Create a NetworkEvent and then sends it through the network client. - * @param playerUsername The name of the player who requested to perform the action - * @param pos Index of the card to draw + * Requests to draw a building card from the upper list. + * Creates a NetworkEvent and sends it through the network client. + * @param playerUsername the name of the player performing the action + * @param pos the index of the card to draw */ public void drawUpperBuildingCard(String playerUsername,int pos) { client.doEvent(new DrawUpperBuildingCard(playerUsername,pos)); } + /** - * Used to draw a building card from the lower list. - * Create a NetworkEvent and then sends it through the network client. - * @param playerUsername The name of the player who requested to perform the action - * @param pos Index of the card to draw + * Requests to draw a building card from the lower list. + * Creates a NetworkEvent and sends it through the network client. + * @param playerUsername the name of the player performing the action + * @param pos the index of the card to draw */ public void drawLowerBuildingCard(String playerUsername,int pos) { client.doEvent(new DrawLowerBuildingCard(playerUsername,pos)); @@ -105,9 +108,9 @@ public class ClientController { /** - * Used to skip the drawing action from the upper list. - * Available only when the upper list is empty (or the player can't draw any card). - * @param playerUsername The name of the player who requested to perform the action + * Requests to skip drawing from the upper list. + * This action is available only when the upper list is empty or the player cannot draw any card. + * @param playerUsername the name of the player performing the action */ public void skipUpper(String playerUsername) { client.doEvent(new SkipUpper(playerUsername)); @@ -115,9 +118,9 @@ public class ClientController { /** - * Used to skip the drawing action from the lower list. - * Available only when the lower list is empty (or the player can't draw any card). - * @param playerUsername The name of the player who requested to perform the action + * Requests to skip drawing from the lower list. + * This action is available only when the lower list is empty or the player cannot draw any card. + * @param playerUsername the name of the player performing the action */ public void skipLower(String playerUsername) { client.doEvent(new SkipLower(playerUsername));} @@ -125,8 +128,8 @@ public class ClientController { /** * Used to draw a tribe card from the upper list. * Available only if the player owns the building 12. - * @param playerUsername The name of the player who requested to perform the action - * @param pos Index of the card to draw + * @param playerUsername the name of the player performing the action + * @param pos the index of the card to draw */ public void pickOptionalTribeCard(String playerUsername,int pos) { client.doEvent(new PickOptionalTribeCard(playerUsername,pos)); @@ -136,17 +139,18 @@ public class ClientController { /** * Used to draw a building card from the upper list. * Available only if the player owns the building 12. - * @param playerUsername The name of the player who requested to perform the action - * @param pos Index of the card to draw + * @param playerUsername the name of the player performing the action + * @param pos the index of the card to draw */ public void pickOptionalBuildingCard(String playerUsername,int pos) { client.doEvent(new PickOptionalBuildingCard(playerUsername,pos)); } + /** * Used to skip the action of drawing a card from the upper list. * Available only if the player owns the building 12. - * @param playerUsername The name of the player who requested to perform the action + * @param playerUsername the name of the player performing the action */ public void noOptionalCard(String playerUsername) { client.doEvent(new NoOptionalCard(playerUsername)); @@ -154,9 +158,9 @@ public class ClientController { /** - * Used to sperform the slot choiche action for the specified player at the specified position. - * @param playerUsername The name of the player who requested to perform the action - * @param pos Index of the selected slot + * Used to perform the slot choice action for the specified player at the specified position. + * @param playerUsername the name of the player performing the action + * @param pos the index of the selected slot */ public void slotChoice(String playerUsername,int pos) { client.doEvent(new SlotChoice(playerUsername,pos)); From 06162a243fdf7af0b4504c2094d293971f387479 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Sat, 2 May 2026 17:29:40 +0200 Subject: [PATCH 3/5] Add: toString methods JavaDOC --- .../polimi/ingsw/gc14/Model/Cards/Building/EffectType.java | 2 +- .../ingsw/gc14/Model/Cards/TribeCards/CharacterType.java | 2 +- .../it/polimi/ingsw/gc14/Model/GamePackage/GameStages.java | 2 +- src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java | 6 +++++- src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java | 5 +++++ src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java | 5 +++++ src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java | 5 +++++ .../java/it/polimi/ingsw/gc14/Model/Orders/OrderPlayer.java | 4 ++++ 8 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/EffectType.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/EffectType.java index 8fbe48c..c8ddda2 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/EffectType.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/EffectType.java @@ -1,5 +1,5 @@ package it.polimi.ingsw.gc14.Model.Cards.Building; public enum EffectType { - FINAL, CARD_SET,INVENTOR_PAIR, ON_EVENT , ON_END_TURN, ON_ROUND_END + FINAL, CARD_SET, INVENTOR_PAIR, ON_EVENT, ON_END_TURN, ON_ROUND_END } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/CharacterType.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/CharacterType.java index bd4869c..5df0d9e 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/CharacterType.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/CharacterType.java @@ -1,5 +1,5 @@ package it.polimi.ingsw.gc14.Model.Cards.TribeCards; public enum CharacterType { - INVENTOR,BUILDER, GATHERER,ARTIST,SHAMAN,HUNTER + INVENTOR, BUILDER, GATHERER, ARTIST, SHAMAN, HUNTER } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/GameStages.java b/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/GameStages.java index b001fe3..97e8fa3 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/GameStages.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/GameStages.java @@ -1,5 +1,5 @@ package it.polimi.ingsw.gc14.Model.GamePackage; public enum GameStages { - WAITING,SLOT_CHOICE, RESOLVING_ACTIONS, OPTIONAL_CARD_EFFECT, RESOLVING_EVENT,ENDING,ENDED + WAITING, SLOT_CHOICE, RESOLVING_ACTIONS, OPTIONAL_CARD_EFFECT, RESOLVING_EVENT, ENDING, ENDED } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java index 589ac3d..ced283e 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java @@ -52,10 +52,14 @@ public class Order2 extends OrderLogicCard { } } } + + /** + * Creates the TURN ORDER box of the TUI. + * @return the string containing the box + */ @Override public String toString() { - var table = new AsciiTable(BorderStyle.UNICODE, 2); List stringUp=new ArrayList<>(); for(int i=0;i<2;i++) diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java index 6cc6b57..b3e1247 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java @@ -53,6 +53,11 @@ public class Order3 extends OrderLogicCard { } } } + + /** + * Creates the TURN ORDER box of the TUI. + * @return the string containing the box + */ @Override public String toString() { diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java index e4a8bed..20b573b 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java @@ -60,6 +60,11 @@ public class Order4 extends OrderLogicCard { } } } + + /** + * Creates the TURN ORDER box of the TUI. + * @return the string containing the box + */ @Override public String toString() { diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java index c435ae2..e8ea88f 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java @@ -61,6 +61,11 @@ public class Order5 extends OrderLogicCard { } } } + + /** + * Creates the TURN ORDER box of the TUI. + * @return the string containing the box + */ @Override public String toString() { diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/OrderPlayer.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/OrderPlayer.java index cb3034b..8d3b299 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/OrderPlayer.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/OrderPlayer.java @@ -17,6 +17,10 @@ public class OrderPlayer implements Serializable { this.player=player; this.played=played; } + + /** + * @return the string containing the username and whether it played or not. + */ @Override public String toString() { return player.getUserName()+" "+played; From ec4fe1cf441a5a71042849800b910233142b9cd5 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Sat, 2 May 2026 18:36:26 +0200 Subject: [PATCH 4/5] 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. From b68cbd8591c473830bd4d1508b75c5f8404e93ba Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Sat, 2 May 2026 18:44:28 +0200 Subject: [PATCH 5/5] Fix: JavaDOC to Game --- .../java/it/polimi/ingsw/gc14/Model/Game.java | 64 ++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java index 15f09ad..465da3e 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java @@ -49,7 +49,8 @@ public class Game implements Serializable { } /** - * The current number of players. + * Returns the current number of players participating in the game. + * @return the current number of players. */ public int getCurrentPlayerNumber() { return playersList.size(); @@ -318,6 +319,18 @@ public class Game implements Serializable { return true; } + /** + * Skips the upper card draw for the specified player when no drawable cards are available. + * The operation succeeds only if the current game stage is {@code RESOLVING_ACTIONS}, + * the specified player is the current player, at least one upper draw is still available, + * and there are no drawable upper tribe cards (i.e. all remaining upper tribe cards are event cards) + * and no upper building cards that the player can afford. + * If successful, the upper draw counter is decremented. + * If both upper and lower draws become zero (or no cards remain drawable), the next player setup is triggered. + * + * @param player the player skipping the upper draw. + * @return {@code true} if the skip succeeds, {@code false} otherwise. + */ public boolean SkipUpperDrawing(Player player) { if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS) { @@ -337,6 +350,18 @@ public class Game implements Serializable { return true; } + /** + * Skips the lower card draw for the specified player when no drawable cards are available. + * The operation succeeds only if the current game stage is {@code RESOLVING_ACTIONS}, + * the specified player is the current player, at least one lower draw is still available, + * and there are no drawable lower tribe cards (i.e. all remaining lower tribe cards are event cards) + * and no lower building cards that the player can afford. + * If successful, the lower draw counter is decremented. + * If both upper and lower draws become zero (or no cards remain drawable), the next player setup is triggered. + * + * @param player the player skipping the lower draw. + * @return {@code true} if the skip succeeds, {@code false} otherwise. + */ public boolean SkipLowerDrawing(Player player) { if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS) { @@ -696,13 +721,32 @@ public class Game implements Serializable { } return; - +/** + * Checks whether there are any drawable lower tribe cards on the board, + * i.e. lower tribe cards that are not event cards. + * + * @return {@code true} if at least one non-event lower tribe card is available, {@code false} otherwise. + */ } } + + /** + * Checks whether there are any drawable upper tribe cards on the board, + * i.e. upper tribe cards that are not event cards. + * + * @return {@code true} if at least one non-event upper tribe card is available, {@code false} otherwise. + */ private boolean hasDrawableUp() { return getUpperListTribeCards().stream().filter(x-> !x.IsEventCard()).count()!=0; } + + /** + * Checks whether there are any drawable lower tribe cards on the board, + * i.e. lower tribe cards that are not event cards. + * + * @return {@code true} if at least one non-event lower tribe card is available, {@code false} otherwise. + */ private boolean hasDrawableDown() { return getLowerListTribeCards().stream().filter(x-> !x.IsEventCard()).count()!=0; @@ -817,6 +861,14 @@ public class Game implements Serializable { public String toString() { return PlayersStamp()+"\n"+BoardStamp()+"\n"; } + + /** + * Returns a string representation of all the players currently in the game, + * arranged side by side in pairs. + * If the number of players is odd, the last player is printed on its own line. + * + * @return {@code String} - a string representation of all the players. + */ public String PlayersStamp() { StringBuilder stringBuilder=new StringBuilder(); @@ -832,6 +884,14 @@ public class Game implements Serializable { } return stringBuilder.toString(); } + + /** + * Returns a string representation of the board, including the current state, + * the offer track with slot assignments, the upper and lower tribe card lists, + * and the upper and lower building card lists. + * + * @return {@code String} - a string representation of the board. + */ public String BoardStamp() { var offerTrack = new AsciiTable(BorderStyle.UNICODE, slotMap.size());