Fix: ClientContrioller JavaDOC
This commit is contained in:
@@ -7,127 +7,156 @@ import it.polimi.ingsw.gc14.Network.NetworkEvents.*;
|
|||||||
import it.polimi.ingsw.gc14.Network.Observer;
|
import it.polimi.ingsw.gc14.Network.Observer;
|
||||||
import it.polimi.ingsw.gc14.View.IView;
|
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 {
|
public class ClientController {
|
||||||
|
|
||||||
|
/** Game Controller of the client */
|
||||||
public GameController localController;
|
public GameController localController;
|
||||||
|
|
||||||
//TODO Javadoc
|
/** View of the client */
|
||||||
public IView view=null;
|
public IView view;
|
||||||
|
|
||||||
|
/** Network client (either TCP or RMI) */
|
||||||
private IClient client;
|
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) {
|
public ClientController(IView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.localController = new GameController();
|
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) {
|
public void setClient(IClient client) {
|
||||||
this.client = 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) {
|
public void setModel(Game model) {
|
||||||
localController.setModel(model);
|
localController.setModel(model);
|
||||||
view.update(localController.getModel());
|
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) {
|
public void onError(String message) {
|
||||||
view.showError(message);
|
view.showError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to draw an upper tribe card for the specified player from the specified position.
|
* Used to draw a tribe card from the upper list.
|
||||||
*
|
* Create a NetworkEvent and then sends it through the network client.
|
||||||
* @param playerUsername the username of the player performing the action.
|
* @param playerUsername The name of the player who requested to perform the action
|
||||||
* @param pos the position of the upper tribe card to draw.
|
* @param pos Index of the card to draw
|
||||||
* @return {@code true} if the action succeeds, {@code false} if the player does not exist
|
|
||||||
* or if the draw operation fails.
|
|
||||||
*/
|
*/
|
||||||
public void drawUpperTribeCard(String playerUsername,int pos) {
|
public void drawUpperTribeCard(String playerUsername, int pos) {
|
||||||
client.doEvent(new DrawUpperTribeCard(playerUsername,pos));
|
client.doEvent(new DrawUpperTribeCard(playerUsername,pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to draw a lower tribe card for the specified player from the specified position.
|
* Used to draw a tribe card from the lower list.
|
||||||
*
|
* Create a NetworkEvent and then sends it through the network client.
|
||||||
* @param playerUsername the username of the player performing the action.
|
* @param playerUsername The name of the player who requested to perform the action
|
||||||
* @param pos the position of the lower tribe card to draw.
|
* @param pos Index of the card to draw
|
||||||
* @return {@code true} if the action succeeds, {@code false} if the player does not exist
|
|
||||||
* or if the draw operation fails.
|
|
||||||
*/
|
*/
|
||||||
public void drawLowerTribeCard(String playerUsername,int pos) {
|
public void drawLowerTribeCard(String playerUsername,int pos) {
|
||||||
client.doEvent(new DrawLowerTribeCard(playerUsername,pos));
|
client.doEvent(new DrawLowerTribeCard(playerUsername,pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to draw an upper building card for the specified player from the specified position.
|
* Used to draw a building card from the upper list.
|
||||||
*
|
* Create a NetworkEvent and then sends it through the network client.
|
||||||
* @param playerUsername the username of the player performing the action.
|
* @param playerUsername The name of the player who requested to perform the action
|
||||||
* @param pos the position of the upper building card to draw.
|
* @param pos Index of the card to draw
|
||||||
* @return {@code true} if the action succeeds, {@code false} if the player does not exist
|
|
||||||
* or if the draw operation fails.
|
|
||||||
*/
|
*/
|
||||||
public void drawUpperBuildingCard(String playerUsername,int pos) {
|
public void drawUpperBuildingCard(String playerUsername,int pos) {
|
||||||
client.doEvent(new DrawUpperBuildingCard(playerUsername,pos));
|
client.doEvent(new DrawUpperBuildingCard(playerUsername,pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to draw a lower building card for the specified player from the specified position.
|
* Used to draw a building card from the lower list.
|
||||||
*
|
* Create a NetworkEvent and then sends it through the network client.
|
||||||
* @param playerUsername the username of the player performing the action.
|
* @param playerUsername The name of the player who requested to perform the action
|
||||||
* @param pos the position of the lower building card to draw.
|
* @param pos Index of the card to draw
|
||||||
* @return {@code true} if the action succeeds, {@code false} if the player does not exist
|
|
||||||
* or if the draw operation fails.
|
|
||||||
*/
|
*/
|
||||||
public void drawLowerBuildingCard(String playerUsername,int pos) {
|
public void drawLowerBuildingCard(String playerUsername,int pos) {
|
||||||
client.doEvent(new DrawLowerBuildingCard(playerUsername,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) {
|
public void skipUpper(String playerUsername) {
|
||||||
client.doEvent(new SkipUpper(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));}
|
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.
|
* Used to draw a tribe card from the upper list.
|
||||||
*
|
* Available only if the player owns the building 12.
|
||||||
* @param playerUsername the username of the player performing the action.
|
* @param playerUsername The name of the player who requested to perform the action
|
||||||
* @param pos the position of the optional tribe card to pick.
|
* @param pos Index of the card to draw
|
||||||
* @return {@code true} if the action succeeds, {@code false} if the player does not exist
|
|
||||||
* or if the pick operation fails.
|
|
||||||
*/
|
*/
|
||||||
public void pickOptionalTribeCard(String playerUsername,int pos) {
|
public void pickOptionalTribeCard(String playerUsername,int pos) {
|
||||||
client.doEvent(new PickOptionalTribeCard(playerUsername,pos));
|
client.doEvent(new PickOptionalTribeCard(playerUsername,pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to pick an optional building card for the specified player from the specified position.
|
* Used to draw a building card from the upper list.
|
||||||
*
|
* Available only if the player owns the building 12.
|
||||||
* @param playerUsername the username of the player performing the action.
|
* @param playerUsername The name of the player who requested to perform the action
|
||||||
* @param pos the position of the optional building card to pick.
|
* @param pos Index of the card to draw
|
||||||
* @return {@code true} if the action succeeds, {@code false} if the player does not exist
|
|
||||||
* or if the pick operation fails.
|
|
||||||
*/
|
*/
|
||||||
public void pickOptionalBuildingCard(String playerUsername,int pos) {
|
public void pickOptionalBuildingCard(String playerUsername,int pos) {
|
||||||
client.doEvent(new PickOptionalBuildingCard(playerUsername,pos));
|
client.doEvent(new PickOptionalBuildingCard(playerUsername,pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refuse to pick an optional building card for the specified player.
|
* Used to skip the action of drawing a card from the upper list.
|
||||||
* @param playerUsername the username of the player performing the action.
|
* Available only if the player owns the building 12.
|
||||||
* @return {@code true} if the action succeeds, {@code false} if the player does not exist
|
* @param playerUsername The name of the player who requested to perform the action
|
||||||
* or if the pick operation fails.
|
|
||||||
*/
|
*/
|
||||||
public void noOptionalCard(String playerUsername) {
|
public void noOptionalCard(String playerUsername) {
|
||||||
client.doEvent(new NoOptionalCard(playerUsername));
|
client.doEvent(new NoOptionalCard(playerUsername));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to perform the slot choice action for the specified player at the specified position.
|
* 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 playerUsername the username of the player performing the action.
|
* @param pos Index of the selected slot
|
||||||
* @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.
|
|
||||||
*/
|
*/
|
||||||
public void slotChoice(String playerUsername,int pos) {
|
public void slotChoice(String playerUsername,int pos) {
|
||||||
client.doEvent(new SlotChoice(playerUsername,pos));
|
client.doEvent(new SlotChoice(playerUsername,pos));
|
||||||
|
|||||||
Reference in New Issue
Block a user