Class ClientController
It receives user actions from the view, performs basic client-side checks and forwards valid requests to the network client.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionClientController(IView view) Constructs a client controller with the specified view. -
Method Summary
Modifier and TypeMethodDescriptionvoidNotifies the server of a voluntary disconnection and closes the network client connection.voiddrawLowerBuildingCard(int pos) Requests to draw a building card from the lower list.voiddrawLowerTribeCard(int pos) Requests to draw a tribe card from the lower list.voiddrawUpperBuildingCard(int pos) Requests to draw a building card from the upper list.voiddrawUpperTribeCard(int pos) Requests to draw a tribe card from the upper list.Gets the network client.Returns the local mini model.Returns the username associated with this client.getView()Returns the client view.voidSets the network client.voidSets the local mini model and updates the view accordingly.voidsetMyUsername(String username) Sets the username associated with this client.voidskipTurn()Requests to skip the current turn.voidslotChoice(int pos) Requests the selection of a slot by the specified player.voidtotemChoice(int pos) Handles the selection of a totem by the specified player.
-
Field Details
-
miniModel
Local mini model representing the client-side game state. -
view
View of the client. -
client
Network client, either TCP or RMI. -
myUsername
Username associated with this client.
-
-
Constructor Details
-
ClientController
Constructs a client controller with the specified view.The network client is initially unset and an empty local mini model is created.
- Parameters:
view- the client view, either TUI or GUI.
-
-
Method Details
-
getMiniModel
-
getView
-
getMyUsername
Returns the username associated with this client.- Returns:
- the username.
-
setClient
Sets the network client.- Parameters:
client- the client to set, either TCP or RMI.
-
getClient
Gets the network client.- Returns:
- client return the client, either TCP or RMI.
-
setModel
Sets the local mini model and updates the view accordingly.- Parameters:
model- the mini model to set.
-
setMyUsername
Sets the username associated with this client.- Parameters:
username- the username to set.
-
drawUpperTribeCard
public void drawUpperTribeCard(int pos) Requests to draw a tribe card from the upper list.The request is forwarded to the network client; the server validates it.
- Parameters:
pos- the index of the card to draw.
-
drawLowerTribeCard
public void drawLowerTribeCard(int pos) Requests to draw a tribe card from the lower list.The request is forwarded to the network client; the server validates it.
- Parameters:
pos- the index of the card to draw.
-
drawUpperBuildingCard
public void drawUpperBuildingCard(int pos) Requests to draw a building card from the upper list.The request is forwarded to the network client; the server validates it.
- Parameters:
pos- the index of the card to draw.
-
drawLowerBuildingCard
public void drawLowerBuildingCard(int pos) Requests to draw a building card from the lower list.The request is forwarded to the network client; the server validates it.
- Parameters:
pos- the index of the card to draw.
-
skipTurn
public void skipTurn()Requests to skip the current turn.The request is forwarded to the network client; the server validates it.
-
slotChoice
public void slotChoice(int pos) Requests the selection of a slot by the specified player.The request is forwarded to the network client; the server validates it.
- Parameters:
pos- the index of the selected slot.
-
totemChoice
public void totemChoice(int pos) Handles the selection of a totem by the specified player.If the specified player is not the current player, an error message is shown. Otherwise, the selected totem is retrieved from the available totems list and the choice is forwarded to the network client.
- Parameters:
pos- the index of the selected totem in the available totems list.
-
disconnect
public void disconnect()Notifies the server of a voluntary disconnection and closes the network client connection.
-