java.lang.Object
it.polimi.ingsw.am13.client.gamestate.GameStateHandler
Class handling the representation of the state of the game (
GameState
).
There is an "update method" for each game event (hence not events like "joinedRoom"). Each of these methods set the
right attributes of the game state to change it according to the event who provoked the change.
So if there is the need for manipulating the game state (i.e. creating it and changing it to keep representing the current
game's state), it should be done by using this class-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGameStateHandler
(GameState state) Builds a new handler for the representation of the game's state, starting from an already built representationGameStateHandler
(GameModelIF model) Builds a new handler for the representation of the game's state, starting from the interface of the game's model -
Method Summary
Modifier and TypeMethodDescriptiongetState()
void
updateChosenPersonalObjective
(PlayerLobby player, CardObjectiveIF chosenObj) A player has chosen their personal objective card.void
updateFinalPhase
(int turnsToEnd) The game is in the final phase.void
The game has begun the turn-based phase.void
updateNextTurn
(PlayerLobby player) The next turn has been reachedvoid
updatePickedCard
(PlayerLobby player, List<CardPlayableIF> updatedVisibleCards, CardPlayableIF pickedCard) A player has picked a card from the common visible cards.void
updatePlayedCard
(PlayerLobby player, CardPlayableIF card, Coordinates coords, int points, List<Coordinates> availableCoords) A player has played a card.void
updatePlayedStarter
(PlayerLobby player, CardStarterIF cardStarter, List<Coordinates> availableCoords) A player has played their starter card.void
updatePlayerDisconnected
(PlayerLobby player) A player has disconnected from the game.void
updatePlayerReconnected
(PlayerLobby player) A player has reconnected to the game.void
updatePoints
(Map<PlayerLobby, Integer> pointsMap) The points given by Objective cards (common and personal) have been calculated.void
updateWinner
(List<PlayerLobby> winners) The winner has been calculated
-
Field Details
-
state
Game state to handle
-
-
Constructor Details
-
GameStateHandler
Builds a new handler for the representation of the game's state, starting from the interface of the game's model- Parameters:
model
- Interface of the game's model from which to build the representation of the game's state and the corresponding handler
-
GameStateHandler
Builds a new handler for the representation of the game's state, starting from an already built representation- Parameters:
state
- Already built representation of the game's state, whose handler is to be created
-
-
Method Details
-
getState
- Returns:
- Representation of game's state handled
-
updatePlayedStarter
public void updatePlayedStarter(PlayerLobby player, CardStarterIF cardStarter, List<Coordinates> availableCoords) A player has played their starter card.- Parameters:
player
- The player that played the starter card.cardStarter
- The starter card played.availableCoords
- The list of coordinates that are available to play a card
-
updateChosenPersonalObjective
A player has chosen their personal objective card.- Parameters:
player
- The player that chose the personal objective card.chosenObj
- Objective card chosen by the player
-
updateNextTurn
The next turn has been reached- Parameters:
player
- The player that is going to play the next turn.
-
updatePlayedCard
public void updatePlayedCard(PlayerLobby player, CardPlayableIF card, Coordinates coords, int points, List<Coordinates> availableCoords) A player has played a card.- Parameters:
player
- The player that played the card.card
- The card played.coords
- The coordinates where the card has been placed, relative to the player's field.points
- The points given by the card.availableCoords
- The list of coordinates that are available to play a card
-
updatePickedCard
public void updatePickedCard(PlayerLobby player, List<CardPlayableIF> updatedVisibleCards, CardPlayableIF pickedCard) A player has picked a card from the common visible cards.- Parameters:
player
- The player that picked the card.updatedVisibleCards
- The updated list of visible cards in the common field.pickedCard
- The card picked by the player
-
updatePoints
The points given by Objective cards (common and personal) have been calculated. Following the game's rules, the specified points are the final ones- Parameters:
pointsMap
- A map containing the points of each player.
-
updateWinner
The winner has been calculated- Parameters:
winners
- The player(s) that won the game.
-
updatePlayerDisconnected
A player has disconnected from the game.- Parameters:
player
- The player that has disconnected.
-
updatePlayerReconnected
A player has reconnected to the game.- Parameters:
player
- The player that has reconnected.
-
updateFinalPhase
public void updateFinalPhase(int turnsToEnd) The game is in the final phase.- Parameters:
turnsToEnd
- Number of turns to reach the end of the turn-based phase
-
updateInGame
public void updateInGame()The game has begun the turn-based phase.
-