Docs: refine JavaDoc for building effects and controllers

This commit is contained in:
MatteoPellegrino05
2026-05-20 16:52:26 +02:00
parent 884121f4b2
commit 0b24845e9d
9 changed files with 259 additions and 196 deletions
@@ -1,42 +1,39 @@
package it.polimi.ingsw.gc14.Controller; package it.polimi.ingsw.gc14.Controller;
import it.polimi.ingsw.gc14.Model.*; import it.polimi.ingsw.gc14.Model.MiniModel;
import it.polimi.ingsw.gc14.Model.GamePackage.Board;
import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
import it.polimi.ingsw.gc14.Network.IClient; import it.polimi.ingsw.gc14.Network.IClient;
import it.polimi.ingsw.gc14.Network.NetworkEvents.*;
import it.polimi.ingsw.gc14.View.IView; import it.polimi.ingsw.gc14.View.IView;
import java.rmi.RemoteException;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
* Controller class that holds all the components of the client, such as view, network client and Game Controller. * Controller responsible for coordinating the client-side components,
* It provides methods to set the client components and to execute requested actions. * including the view, the network client and the local mini model.
*
* <p>It receives user actions from the view, performs basic client-side
* checks and forwards valid requests to the network client.
*/ */
public class ClientController { public class ClientController {
/** Game Controller of the client */ /** Local mini model representing the client-side game state. */
public MiniModel miniModel; public MiniModel miniModel;
/** View of the client */ /** View of the client. */
public IView view; public IView view;
/** Network client (either TCP or RMI) */ /** Network client, either TCP or RMI. */
private IClient client; private IClient client;
/** /** Username associated with this client. */
* The username of the client associated with this event.
*/
public String myUsername; public String myUsername;
/** /**
* Constructs the ClientController. * Constructs a client controller with the specified view.
* Initializes all attributes. *
* @param view the client view (either TUI or GUI) * <p>The network client is initially unset and an empty local mini model
* is created.
*
* @param view the client view, either TUI or GUI.
*/ */
public ClientController(IView view) { public ClientController(IView view) {
this.view = view; this.view = view;
@@ -44,19 +41,19 @@ public class ClientController {
this.miniModel = new MiniModel(); this.miniModel = new MiniModel();
} }
/** /**
* Sets the network client. * Sets the network client.
* @param client the client to set (either TCP or RMI) *
* @param client the client to set, either TCP or RMI.
*/ */
public void setClient(IClient client) { public void setClient(IClient client) {
this.client = client; this.client = client;
} }
/** /**
* Sets the model in the GameController and updates the view. * Sets the local mini model and updates the view accordingly.
* @param model the model to set *
* @param model the mini model to set.
*/ */
public void setModel(MiniModel model) { public void setModel(MiniModel model) {
this.miniModel = model; this.miniModel = model;
@@ -64,131 +61,139 @@ public class ClientController {
} }
/** /**
* Sets the username of the client associated with this event. * Sets the username associated with this client.
* *
* @param username the username to set. * @param username the username to set.
*/ */
public void setMyUsername (String username) { public void setMyUsername(String username) {
this.myUsername=username; this.myUsername = username;
} }
/** /**
* Displays an error message in the view. * Displays an error message in the view.
* @param message the error message to display *
* @param message the error message to display.
*/ */
public void onError(String message) { public void onError(String message) {
view.showError(message); view.showError(message);
} }
/** /**
* Requests to draw a tribe card from the upper list. * 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 * <p>If the specified player is not the current player, an error message
* @param pos the index of the card to draw * is shown. Otherwise, the request is forwarded to the network client.
*
* @param playerUsername the username of the player performing the action.
* @param pos the index of the card to draw.
*/ */
public void drawUpperTribeCard(String playerUsername, int pos) { public void drawUpperTribeCard(String playerUsername, int pos) {
if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName()))
{
view.showError("It's not your turn!"); view.showError("It's not your turn!");
} } else {
else
{
client.drawUpperTribeCard(playerUsername, pos); client.drawUpperTribeCard(playerUsername, pos);
} }
} }
/** /**
* Requests to draw a tribe card from the lower list. * 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 * <p>If the specified player is not the current player, an error message
* @param pos the index of the card to draw * is shown. Otherwise, the request is forwarded to the network client.
*
* @param playerUsername the username of the player performing the action.
* @param pos the index of the card to draw.
*/ */
public void drawLowerTribeCard(String playerUsername,int pos) { public void drawLowerTribeCard(String playerUsername, int pos) {
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!"); view.showError("It's not your turn!");
else } else {
client.drawLowerTribeCard(playerUsername, pos); client.drawLowerTribeCard(playerUsername, pos);
} }
}
/** /**
* Requests to draw a building card from the upper list. * 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 * <p>If the specified player is not the current player, an error message
* @param pos the index of the card to draw * is shown. Otherwise, the request is forwarded to the network client.
*
* @param playerUsername the username of the player performing the action.
* @param pos the index of the card to draw.
*/ */
public void drawUpperBuildingCard(String playerUsername,int pos) { public void drawUpperBuildingCard(String playerUsername, int pos) {
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!"); view.showError("It's not your turn!");
else { } else {
client.drawUpperBuildingCard(playerUsername,pos); client.drawUpperBuildingCard(playerUsername, pos);
} }
} }
/** /**
* Requests to draw a building card from the lower list. * 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 * <p>If the specified player is not the current player, an error message
* @param pos the index of the card to draw * is shown. Otherwise, the request is forwarded to the network client.
*
* @param playerUsername the username of the player performing the action.
* @param pos the index of the card to draw.
*/ */
public void drawLowerBuildingCard(String playerUsername,int pos) { public void drawLowerBuildingCard(String playerUsername, int pos) {
if(!Objects.equals(playerUsername,miniModel.currentState.getCurrentPlayer().getUserName())) if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!"); view.showError("It's not your turn!");
else { } else {
client.drawLowerBuildingCard(playerUsername,pos); client.drawLowerBuildingCard(playerUsername, pos);
} }
} }
/** /**
* Requests to skip turn . * Requests to skip the current turn.
* This action is available only when the player cannot draw any tribe card. *
* @param playerUsername the name of the player performing the action * <p>If the specified player is not the current player, an error message
* is shown. Otherwise, the request is forwarded to the network client.
*
* @param playerUsername the username of the player performing the action.
*/ */
public void skipTurn(String playerUsername) { public void skipTurn(String playerUsername) {
if(!Objects.equals(playerUsername,miniModel.currentState.getCurrentPlayer().getUserName())) if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!"); view.showError("It's not your turn!");
else { } else {
client.skipTurn(playerUsername); client.skipTurn(playerUsername);
} }
} }
/** /**
* Used to perform the slot choice action for the specified player at the specified position. * Requests the selection of a slot by the specified player.
* @param playerUsername the name of the player performing the action *
* @param pos the index of the selected slot * <p>If the specified player is not the current player, an error message
* is shown. Otherwise, the request is forwarded to the network client.
*
* @param playerUsername the username of the player performing the action.
* @param pos the index of the selected slot.
*/ */
public void slotChoice(String playerUsername,int pos) { public void slotChoice(String playerUsername, int pos) {
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!"); view.showError("It's not your turn!");
else { } else {
client.slotChoice(playerUsername,pos); client.slotChoice(playerUsername, pos);
} }
} }
/** /**
* Handles the selection of a totem by the specified player. * Handles the selection of a totem by the specified player.
* *
* <p>If the player is not the current one, an error message is shown. * <p>If the specified player is not the current player, an error message
* Otherwise, the selected totem is retrieved from the available totems * is shown. Otherwise, the selected totem is retrieved from the available
* and the choice is forwarded to the client. * totems list and the choice is forwarded to the network client.
* *
* @param playerUsername the username of the player making the choice. * @param playerUsername the username of the player making the choice.
* @param pos the position of the selected totem in the available totems list. * @param pos the index of the selected totem in the available totems list.
*/ */
public void totemChoice(String playerUsername,int pos) { public void totemChoice(String playerUsername, int pos) {
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!"); view.showError("It's not your turn!");
else { } else {
client.totemChoice(playerUsername, String.valueOf(miniModel.availableTotems.get(pos))); client.totemChoice(playerUsername, String.valueOf(miniModel.availableTotems.get(pos)));
} }
} }
} }
@@ -5,9 +5,10 @@ import it.polimi.ingsw.gc14.Model.Player;
import it.polimi.ingsw.gc14.Model.Totems; import it.polimi.ingsw.gc14.Model.Totems;
/** /**
* Controller class that manages interactions between the client-side logic * Controller responsible for managing interactions with the {@link Game} model.
* and the {@link Game} model. *
* It provides methods to add players and to perform game actions by delegating them to the model. * <p>It provides methods to update the game state by delegating player-related
* actions and game actions to the underlying model.
*/ */
public class GameController { public class GameController {
@@ -36,7 +37,8 @@ public class GameController {
* *
* @param username the username of the player who disconnected. * @param username the username of the player who disconnected.
* @return {@code true} if the disconnection is handled successfully, * @return {@code true} if the disconnection is handled successfully,
* {@code false} if no player with the specified username exists. * {@code false} if no player with the specified username exists
* or if the operation fails.
*/ */
public boolean DisconnectedPlayer(String username) public boolean DisconnectedPlayer(String username)
{ {
@@ -51,7 +53,8 @@ public class GameController {
* *
* @param username the username of the player who reconnected. * @param username the username of the player who reconnected.
* @return {@code true} if the reconnection is handled successfully, * @return {@code true} if the reconnection is handled successfully,
* {@code false} if no player with the specified username exists. * {@code false} if no player with the specified username exists
* or if the operation fails.
*/ */
public boolean ReconnectPlayer(String username) public boolean ReconnectPlayer(String username)
{ {
@@ -83,19 +86,21 @@ public class GameController {
* Attempts to add a new player with the specified username to the game model. * Attempts to add a new player with the specified username to the game model.
* *
* @param username the username of the player to add. * @param username the username of the player to add.
* @return {@code true} if the player is successfully added, {@code false} otherwise. * @return {@code true} if the player is successfully added,
* {@code false} otherwise.
*/ */
public boolean addPlayer(String username) { public boolean addPlayer(String username) {
return model.addPlayer(new Player(username)); return model.addPlayer(new Player(username));
} }
/** /**
* Attempts to draw an upper tribe card for the specified player from the specified position. * 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 playerUsername the username of the player performing the action.
* @param pos the position of the upper tribe card to draw. * @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 * @return {@code true} if the action succeeds,
* or if the draw operation fails. * {@code false} if the player does not exist or if the draw operation fails.
*/ */
public boolean drawUpperTribeCard(String playerUsername,int pos) { public boolean drawUpperTribeCard(String playerUsername,int pos) {
Player player= model.getPlayerByUsername(playerUsername); Player player= model.getPlayerByUsername(playerUsername);
@@ -105,12 +110,13 @@ public class GameController {
} }
/** /**
* Attempts to draw a lower tribe card for the specified player from the specified position. * 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 playerUsername the username of the player performing the action.
* @param pos the position of the lower tribe card to draw. * @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 * @return {@code true} if the action succeeds,
* or if the draw operation fails. * {@code false} if the player does not exist or if the draw operation fails.
*/ */
public boolean drawLowerTribeCard(String playerUsername,int pos) { public boolean drawLowerTribeCard(String playerUsername,int pos) {
Player player= model.getPlayerByUsername(playerUsername); Player player= model.getPlayerByUsername(playerUsername);
@@ -120,12 +126,13 @@ public class GameController {
} }
/** /**
* Attempts to draw an upper building card for the specified player from the specified position. * 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 playerUsername the username of the player performing the action.
* @param pos the position of the upper building card to draw. * @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 * @return {@code true} if the action succeeds,
* or if the draw operation fails. * {@code false} if the player does not exist or if the draw operation fails.
*/ */
public boolean drawUpperBuildingCard(String playerUsername,int pos) { public boolean drawUpperBuildingCard(String playerUsername,int pos) {
Player player= model.getPlayerByUsername(playerUsername); Player player= model.getPlayerByUsername(playerUsername);
@@ -135,12 +142,13 @@ public class GameController {
} }
/** /**
* Attempts to draw a lower building card for the specified player from the specified position. * 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 playerUsername the username of the player performing the action.
* @param pos the position of the lower building card to draw. * @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 * @return {@code true} if the action succeeds,
* or if the draw operation fails. * {@code false} if the player does not exist or if the draw operation fails.
*/ */
public boolean drawLowerBuildingCard(String playerUsername,int pos) { public boolean drawLowerBuildingCard(String playerUsername,int pos) {
Player player= model.getPlayerByUsername(playerUsername); Player player= model.getPlayerByUsername(playerUsername);
@@ -153,9 +161,9 @@ public class GameController {
/** /**
* Skips the card drawing action for the specified player. * Skips the card drawing action for the specified player.
* *
* @param playerUsername the username of the player who wants to skip the turn action. * @param playerUsername the username of the player performing the action.
* @return {@code true} if the skip action is valid and successfully performed; * @return {@code true} if the skip action is valid and successfully performed,
* {@code false} if the player does not exist or the action is not valid. * {@code false} if the player does not exist or if the action is not valid.
*/ */
public boolean SkipTurn(String playerUsername) { public boolean SkipTurn(String playerUsername) {
Player player= model.getPlayerByUsername(playerUsername); Player player= model.getPlayerByUsername(playerUsername);
@@ -167,12 +175,13 @@ public class GameController {
/** /**
* Attempts to perform the slot choice action for the specified player at the specified position. * 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 playerUsername the username of the player performing the action.
* @param pos the position of the chosen slot. * @param pos the position of the chosen slot.
* @return {@code true} if the action succeeds, {@code false} if the player does not exist * @return {@code true} if the action succeeds,
* or if the slot choice operation fails. * {@code false} if the player does not exist or if the slot choice operation fails.
*/ */
public boolean slotChoice(String playerUsername,int pos) { public boolean slotChoice(String playerUsername,int pos) {
Player player= model.getPlayerByUsername(playerUsername); Player player= model.getPlayerByUsername(playerUsername);
@@ -187,7 +196,8 @@ public class GameController {
* @param playerUsername the username of the player making the choice. * @param playerUsername the username of the player making the choice.
* @param totem the name of the selected totem. * @param totem the name of the selected totem.
* @return {@code true} if the choice is handled successfully, * @return {@code true} if the choice is handled successfully,
* {@code false} if no player with the specified username exists. * {@code false} if no player with the specified username exists
* or if the choice operation fails.
*/ */
public boolean TotemChoice(String playerUsername,String totem) { public boolean TotemChoice(String playerUsername,String totem) {
Player player= model.getPlayerByUsername(playerUsername); Player player= model.getPlayerByUsername(playerUsername);
@@ -8,28 +8,34 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
/** /**
* From the moment you buy this building, every time you complete a set of 6 different characters, you gain 5 food. * Building effect that grants 5 food for each new complete set of
* Note: sets of characters already present before purchasing the building do not count. * 6 different character types obtained after purchasing this building.
*
* <p>Character sets already completed before the building is purchased
* are stored during initialization and do not provide food.
*/ */
public class Building0 extends BuildingCard { public class Building0 extends BuildingCard {
/** /**
* The purchased attribute is used to indicate whether the card has already been initialized. * Indicates whether the building effect has already been initialized
* after purchase.
*/ */
boolean purchased ; boolean purchased ;
/** /**
* The numSet attribute indicates how many complete sets the player has. * Number of complete character sets already counted by this building effect.
*/ */
private int numSet; private int numSet;
/** /**
* Constructor of the building. * Creates a building with the specified image identifier, era, price
* and prestige value.
* *
* @param idImage the image identifier of the building. * @param idImage the image identifier of the building.
* @param era the game era of the building. * @param era the game era of the building.
* @param price the price in food of the building. * @param price the price in food of the building.
* @param prestigeValue the number of Prestige Points gained from this building at the end of the game. * @param prestigeValue the number of Prestige Points granted by this building
* at the end of the game.
*/ */
public Building0(String idImage,int era,int price,int prestigeValue) { public Building0(String idImage,int era,int price,int prestigeValue) {
super(idImage,era,price,prestigeValue); super(idImage,era,price,prestigeValue);
@@ -40,10 +46,12 @@ public class Building0 extends BuildingCard {
} }
/** /**
* Constructor of the building * Creates a building with the specified era, price and prestige value.
* @param era The game era of the building. *
* @param price The price (in food) of the building. * @param era the game era of the building.
* @param prestigeValue The number of Prestige Points gained from this building at the end of the game. * @param price the price in food of the building.
* @param prestigeValue the number of Prestige Points granted by this building
* at the end of the game.
*/ */
public Building0(int era,int price,int prestigeValue) { public Building0(int era,int price,int prestigeValue) {
super(era,price,prestigeValue); super(era,price,prestigeValue);
@@ -54,9 +62,12 @@ public class Building0 extends BuildingCard {
} }
/** /**
* Method used to purchase the building. It also handles its initialization. * Attempts to purchase the building and initializes its effect if the
* @param player The player who buys the building. * purchase succeeds.
* @return The outcome of the operation. *
* @param player the player who attempts to buy the building.
* @return {@code true} if the building is successfully purchased and initialized,
* {@code false} otherwise.
*/ */
@Override @Override
public boolean buy(Player player) public boolean buy(Player player)
@@ -68,9 +79,12 @@ public class Building0 extends BuildingCard {
} }
/** /**
* Initializes the building by counting the number of complete sets at the moment of purchase. * Initializes the building effect by storing the number of complete
* The building can only be initialized once. * character sets already owned by the player at the moment of purchase.
* @param player The player who owns the building, whose cards are counted to determine the number of sets. *
* <p>The initialization is performed only once.
*
* @param player the player who owns the building.
*/ */
public void initialize(Player player) public void initialize(Player player)
{ {
@@ -88,8 +102,13 @@ public class Building0 extends BuildingCard {
} }
/** /**
* Method to clone the building: it creates an exact copy. * Creates a new building instance with the same configuration values
* @return The new copy of the building * as this card.
*
* <p>The runtime state of the effect, such as initialization status and
* counted character sets, is not copied.
*
* @return a new building card with the same base properties.
*/ */
@Override @Override
public BuildingCard clone() { public BuildingCard clone() {
@@ -97,10 +116,13 @@ public class Building0 extends BuildingCard {
} }
/** /**
* Calculates the current number of card sets and subtracts the previous value (i.e., the number of newly obtained sets). * Applies the building effect to the specified player.
* The player gains an amount of food equal to 5 times this result. *
* @param player The player who owns the building. * <p>The method counts the complete character sets currently owned by the player
* @throws IllegalArgumentException thrown if the specified player does not own this card. * and grants 5 food for each set completed since the last stored value.
*
* @param player the player who owns the building.
* @throws IllegalArgumentException if the specified player does not own this card.
*/ */
@Override @Override
public void applyEffect(Player player) throws IllegalArgumentException { public void applyEffect(Player player) throws IllegalArgumentException {
@@ -5,27 +5,31 @@ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
/** /**
* During the Sustenance Event, you have a discount of 1 food token on the total you * Building effect that grants a discount of 1 food during the Sustenance Event
* would have to pay, for each of the indicated characters in your tribe. * for each character of the indicated type present in the player's tribe.
*/ */
public class Building1 extends BuildingCard { public class Building1 extends BuildingCard {
/** /**
* The icon attribute indicates the character type involved in the building effect. * Character type involved in the building effect.
*/ */
private CharacterType icon ; private CharacterType icon ;
/** /**
* @return The character type associated with this building effect. * Returns the character type associated with this building effect.
*
* @return the character type associated with this building effect.
*/ */
public CharacterType getIcon() {return icon;} public CharacterType getIcon() {return icon;}
/** /**
* Constructor of the building. * Creates a building with the specified era, price, prestige value
* @param era The game era of the building. * and character type involved in its effect.
* @param price The price (in food) of the building. *
* @param prestigeValue The number of Prestige Points gained from this building at the end of the game. * @param era the game era of the building.
* @param icon The character type used by the building effect. * @param price the price in food of the building.
* @param prestigeValue the number of Prestige Points gained from this building at the end of the game.
* @param icon the character type used by the building effect.
*/ */
public Building1(int era, int price,int prestigeValue, CharacterType icon) { public Building1(int era, int price,int prestigeValue, CharacterType icon) {
super(era,price,prestigeValue); super(era,price,prestigeValue);
@@ -35,7 +39,8 @@ public class Building1 extends BuildingCard {
} }
/** /**
* Constructor of the building. * Creates a building with the specified image identifier, era, price,
* prestige value and character type involved in its effect.
* *
* @param idIMG the image identifier of the building. * @param idIMG the image identifier of the building.
* @param era the game era of the building. * @param era the game era of the building.
@@ -51,8 +56,10 @@ public class Building1 extends BuildingCard {
} }
/** /**
* Method to clone the building: it creates an exact copy. * Creates a new building instance with the same configuration values
* @return The new copy of the building. * as this card.
*
* @return a new building card with the same base properties and icon.
*/ */
@Override @Override
public BuildingCard clone() { public BuildingCard clone() {
@@ -60,14 +67,10 @@ public class Building1 extends BuildingCard {
} }
/** /**
* Prints a string representation of this {@code Building1}. This specific variation is used in the {@code Game}'s * Returns a string representation of this building, including the character
* toString to print a more detailed version. * type associated with its effect.
* <p>includes: *
* <li>{@link #icon Icon} * @return a string representation of this building.
* </p>
* @return {@code String} - a string representation of this {@code Building1}.
* @see it.polimi.ingsw.gc14.Model.Game Game
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
*/ */
@Override @Override
public String toString() { public String toString() {
@@ -8,9 +8,10 @@ import it.polimi.ingsw.gc14.Model.Player;
import java.util.HashMap; import java.util.HashMap;
/** /**
* Represents the building card number 10. * At the end of the game, the player gains 6 Prestige Points
* for each complete set of character types in their tribe.
* *
* <p>This class defines the specific behavior and effects of building card 10. * <p>A complete set contains one character card of each {@link CharacterType}.
*/ */
public class Building10 extends BuildingCard { public class Building10 extends BuildingCard {
@@ -53,8 +54,9 @@ public class Building10 extends BuildingCard {
/** /**
* Applies the effect of this building card to the specified player. * Applies the effect of this building card to the specified player.
* The effect grants 6 prestige points for each complete set of character cards. *
* owned by the player, where a complete set contains one card of each. * <p>The effect grants 6 Prestige Points for each complete set of character
* cards owned by the player, where a complete set contains one card of each
* {@link CharacterType}. * {@link CharacterType}.
* *
* @param player the player to whom the effect is applied. * @param player the player to whom the effect is applied.
@@ -6,9 +6,11 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Player;
/** /**
* Represents the building card number 11. * At the end of the game, the player gains Prestige Points based on the number
* of cards of the indicated character type in their tribe.
* *
* <p>This class defines the specific behavior and effects of building card 11. * <p>The gained amount is equal to the number of matching character cards
* multiplied by the building's prestige multiplier.
*/ */
public class Building11 extends BuildingCard { public class Building11 extends BuildingCard {
@@ -85,8 +87,8 @@ public class Building11 extends BuildingCard {
* The effect grants prestige points equal to the number of cards of the * The effect grants prestige points equal to the number of cards of the
* associated CharacterType owned by the player, multiplied by the prestige multiplier. * associated CharacterType owned by the player, multiplied by the prestige multiplier.
* *
* @param player the player to whom the effect is applied- * @param player the player to whom the effect is applied.
* @throws IllegalArgumentException if the player does not own this building card- * @throws IllegalArgumentException if the player does not own this building card.
*/ */
@Override @Override
public void applyEffect(Player player) throws IllegalArgumentException { public void applyEffect(Player player) throws IllegalArgumentException {
@@ -96,15 +98,10 @@ public class Building11 extends BuildingCard {
} }
/** /**
* Prints a string representation of this {@code Building1}. This specific variation is used in the {@code Game}'s * Returns a string representation of this {@code Building11}, including the
* toString to print a more detailed version. * character type associated with its effect and its prestige multiplier.
* <p>includes: *
* <li>{@link #icon Icon} * @return a string representation of this {@code Building11}.
* <li>{@link #PrestigeMul Prestige Multiplier}
* </p>
* @return {@code String} - a string representation of this {@code Building1}.
* @see it.polimi.ingsw.gc14.Model.Game Game
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
*/ */
@Override @Override
public String toString() { public String toString() {
@@ -5,9 +5,8 @@ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Player;
/** /**
* Represents the building card number 13. * At the end of the game, this building grants 25 Prestige Points
* * to the player who owns it.
* <p>This class defines the specific behavior and effects of building card 13.
*/ */
public class Building13 extends BuildingCard{ public class Building13 extends BuildingCard{
@@ -49,7 +48,8 @@ public class Building13 extends BuildingCard{
} }
/** /**
* Applies the effect of this building card to the specified player. * Applies the effect of this building card to the specified player,
* granting 25 Prestige Points.
* *
* @param player the player to whom the effect is applied. * @param player the player to whom the effect is applied.
* @throws IllegalArgumentException if the player does not own this building card. * @throws IllegalArgumentException if the player does not own this building card.
@@ -8,23 +8,28 @@ import it.polimi.ingsw.gc14.Model.Player;
import java.util.HashMap; import java.util.HashMap;
/** /**
* From the moment you purchase this building, every time you obtain a pair of identical inventors, you gain 3 food. * Building effect that grants 3 food for each new pair of identical inventors
* This effect doesn't apply to already owned pairs at the time of purchase. * obtained after purchasing this building.
*
* <p>Pairs of identical inventors already owned at the moment of purchase
* are stored during initialization and do not provide food.
*/ */
public class Building4 extends BuildingCard { public class Building4 extends BuildingCard {
/** /**
* The purchased attribute is used to indicate whether the card has already been initialized. * Indicates whether the building effect has already been initialized
* after purchase.
*/ */
boolean purchased ; boolean purchased ;
/** /**
* The numPair attribute indicates how many pairs of inventors the player has. * Number of inventor pairs already counted by this building effect.
*/ */
int numPair; int numPair;
/** /**
* Constructor of the building * Creates a building with the specified era, price and prestige value.
*
* @param era The game era of the building. * @param era The game era of the building.
* @param price The price (in food) of the building. * @param price The price (in food) of the building.
* @param prestigeValue The number of Prestige Points gained from this building at the end of the game. * @param prestigeValue The number of Prestige Points gained from this building at the end of the game.
@@ -36,7 +41,8 @@ public class Building4 extends BuildingCard {
} }
/** /**
* Constructor of the building. * Creates a building with the specified image identifier, era, price
* and prestige value.
* *
* @param idIMG the image identifier of the building. * @param idIMG the image identifier of the building.
* @param era the game era of the building. * @param era the game era of the building.
@@ -50,9 +56,12 @@ public class Building4 extends BuildingCard {
} }
/** /**
* Initializes the building by counting the number of pairs of inventors at the moment of purchase. * Initializes the building effect by storing the number of pairs of identical
* The building can only be initialized once. * inventors already owned by the player at the moment of purchase.
* @param player the player who owns the building, whose inventors are counted to determine the number of pairs. *
* <p>The initialization is performed only once.
*
* @param player the player who owns the building.
*/ */
public void initialize(Player player) public void initialize(Player player)
{ {
@@ -79,9 +88,12 @@ public class Building4 extends BuildingCard {
} }
/** /**
* Method used to purchase the building. It also handles its initialization. * Attempts to purchase the building and initializes its effect if the
* purchase succeeds.
*
* @param player The player who buys the building. * @param player The player who buys the building.
* @return The outcome of the operation. * @return {@code true} if the building is successfully purchased and initialized,
* {@code false} otherwise.
*/ */
@Override @Override
public boolean buy(Player player) public boolean buy(Player player)
@@ -93,8 +105,13 @@ public class Building4 extends BuildingCard {
} }
/** /**
* Method to clone the building: it creates an exact copy. * Creates a new building instance with the same configuration values
* @return The new copy of the building. * as this card.
*
* <p>The runtime state of the effect, such as initialization status and
* counted inventor pairs, is not copied.
*
* @return a new building card with the same base properties.
*/ */
@Override @Override
public BuildingCard clone() { public BuildingCard clone() {
@@ -102,8 +119,11 @@ public class Building4 extends BuildingCard {
} }
/** /**
* Calculates the current number of pairs and subtracts the previous value (i.e., the number of newly obtained pairs). * Applies the building effect to the specified player.
* The player gains an amount of food equal to 3 times this result. *
* <p>The method counts the current number of pairs of identical inventors
* and grants 3 food for each pair obtained since the last stored value.
*
* @param player The player who owns the building. * @param player The player who owns the building.
* @throws IllegalArgumentException Thrown if the specified player does not own this card. * @throws IllegalArgumentException Thrown if the specified player does not own this card.
*/ */
@@ -47,7 +47,11 @@ public class Building8 extends BuildingCard {
} }
/** /**
* For each builder in the player's hand, the player gains double the Prestige Point indicated on the builder card. * Applies the building effect by granting additional Prestige Points equal to
* the Prestige Value of each Builder card owned by the player.
*
* <p>This effectively doubles the contribution of Builder cards to the final score.
*
* @param player The player who owns the building. * @param player The player who owns the building.
* @throws IllegalArgumentException Thrown if the specified player does not own this building. * @throws IllegalArgumentException Thrown if the specified player does not own this building.
*/ */