Merge branch 'main' into javadoc-fixes
This commit is contained in:
@@ -1,40 +1,119 @@
|
||||
package it.polimi.ingsw.gc14.Controller;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Game;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import it.polimi.ingsw.gc14.Network.IClient;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvents.*;
|
||||
import it.polimi.ingsw.gc14.Network.Observer;
|
||||
import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
//TODO Javadoc
|
||||
public class ClientController {
|
||||
//TODO Javadoc
|
||||
public Game localModel;
|
||||
|
||||
//TODO Javadoc
|
||||
public GameController localController;
|
||||
|
||||
//TODO Javadoc
|
||||
public IView view=null;
|
||||
private IClient client;
|
||||
|
||||
//TODO Javadoc
|
||||
public ClientController(IView view,Game localModel) {
|
||||
public ClientController(IView view) {
|
||||
this.view = view;
|
||||
this.localModel = localModel;
|
||||
this.localController = new GameController(localModel);
|
||||
this.localController = new GameController();
|
||||
}
|
||||
|
||||
//TODO Javadoc
|
||||
public ClientController() {
|
||||
this.localController = new GameController(localModel);
|
||||
public void setClient(IClient client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public void setModel(Game model) {
|
||||
this.localModel = model;
|
||||
localController.setModel(model);
|
||||
// localModel.addObserver((Observer) view); // registra la view come observer
|
||||
view.update(localController.getModel());
|
||||
}
|
||||
|
||||
//TODO Javadoc
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public void drawLowerBuildingCard(String playerUsername,int pos) {
|
||||
client.doEvent(new DrawLowerBuildingCard(playerUsername,pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos) {
|
||||
client.doEvent(new PickOptionalBuildingCard(playerUsername,pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void slotChoice(String playerUsername,int pos) {
|
||||
client.doEvent(new SlotChoice(playerUsername,pos));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user