Fix: ClientContrioller JavaDOC

This commit is contained in:
2026-05-02 17:06:16 +02:00
parent 670b4fcf84
commit e2c48ae59d
@@ -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));