Class GameController
java.lang.Object
it.polimi.ingsw.gc14.Controller.GameController
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a GameController without an associated game model.GameController(Game model) Creates a GameController associated with the specified game model. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAttempts to add a new player with the specified username to the game model.booleandisconnectedPlayer(String username) Marks the player associated with the specified username as disconnected.booleandrawLowerBuildingCard(String playerUsername, int pos) Attempts to draw a lower building card for the specified player from the specified position.booleandrawLowerTribeCard(String playerUsername, int pos) Attempts to draw a lower tribe card for the specified player from the specified position.booleandrawUpperBuildingCard(String playerUsername, int pos) Attempts to draw an upper building card for the specified player from the specified position.booleandrawUpperTribeCard(String playerUsername, int pos) Attempts to draw an upper tribe card for the specified player from the specified position.voidEnds the game due to forfeit: all remaining players are absent, so the game is terminated and final scores are computed.getModel()Returns the game model managed by this controller.booleanreconnectPlayer(String username) Marks the player associated with the specified username as reconnected.voidUpdates the game model managed by this controller.booleanSkips the card drawing action for the specified player.booleanslotChoice(String playerUsername, int pos) Attempts to perform the slot choice action for the specified player at the specified position.booleantotemChoice(String playerUsername, String totem) Applies the totem choice made by the player associated with the specified username.
-
Field Details
-
model
The game model managed by this controller.
-
-
Constructor Details
-
GameController
Creates a GameController associated with the specified game model.- Parameters:
model- the game model managed by this controller.
-
GameController
public GameController()Creates a GameController without an associated game model.
-
-
Method Details
-
disconnectedPlayer
Marks the player associated with the specified username as disconnected.- Parameters:
username- the username of the player who disconnected.- Returns:
trueif the disconnection is handled successfully,falseif no player with the specified username exists or if the operation fails.
-
reconnectPlayer
Marks the player associated with the specified username as reconnected.- Parameters:
username- the username of the player who reconnected.- Returns:
trueif the reconnection is handled successfully,falseif no player with the specified username exists or if the operation fails.
-
getModel
Returns the game model managed by this controller.- Returns:
- the game model managed by this controller.
-
setModel
Updates the game model managed by this controller.- Parameters:
model- the new game model managed by this controller.
-
addPlayer
Attempts to add a new player with the specified username to the game model.- Parameters:
username- the username of the player to add.- Returns:
trueif the player is successfully added,falseotherwise.
-
drawUpperTribeCard
Attempts to draw an upper tribe card for the specified player from the specified position.- Parameters:
playerUsername- the username of the player performing the action.pos- the position of the upper tribe card to draw.- Returns:
trueif the action succeeds,falseif the player does not exist or if the draw operation fails.
-
drawLowerTribeCard
Attempts to draw a lower tribe card for the specified player from the specified position.- Parameters:
playerUsername- the username of the player performing the action.pos- the position of the lower tribe card to draw.- Returns:
trueif the action succeeds,falseif the player does not exist or if the draw operation fails.
-
drawUpperBuildingCard
Attempts to draw an upper building card for the specified player from the specified position.- Parameters:
playerUsername- the username of the player performing the action.pos- the position of the upper building card to draw.- Returns:
trueif the action succeeds,falseif the player does not exist or if the draw operation fails.
-
drawLowerBuildingCard
Attempts to draw a lower building card for the specified player from the specified position.- Parameters:
playerUsername- the username of the player performing the action.pos- the position of the lower building card to draw.- Returns:
trueif the action succeeds,falseif the player does not exist or if the draw operation fails.
-
skipTurn
Skips the card drawing action for the specified player.- Parameters:
playerUsername- the username of the player performing the action.- Returns:
trueif the skip action is valid and successfully performed,falseif the player does not exist or if the action is not valid.
-
slotChoice
Attempts to perform the slot choice action for the specified player at the specified position.- Parameters:
playerUsername- the username of the player performing the action.pos- the position of the chosen slot.- Returns:
trueif the action succeeds,falseif the player does not exist or if the slot choice operation fails.
-
totemChoice
Applies the totem choice made by the player associated with the specified username.- Parameters:
playerUsername- the username of the player making the choice.totem- the name of the selected totem.- Returns:
trueif the choice is handled successfully,falseif no player with the specified username exists or if the choice operation fails.
-
endGameForfeit
public void endGameForfeit()Ends the game due to forfeit: all remaining players are absent, so the game is terminated and final scores are computed.
-