java.lang.Object
it.polimi.ingsw.am13.client.gamestate.GameState
- All Implemented Interfaces:
Serializable
Representation of the state of the game in a certain instant.
The representation is not player-specific: it stores information for all the players in the game.
It is valid only for the game, hence the listed players cannot change (can only be set to disconnected). This implies
that the pre-game phase, where players join the room before it gets full, is not represented.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List
<CardObjectiveIF> The list of objectives that are common to all players Following game's rules, this should be always of size 2private PlayerLobby
The current player in a turn-based phase (the one who must play or pick a card).private final PlayerLobby
The first player (from which the rounds start)private final int
Game ID for this gameprivate GameStatus
The current game statusprivate List
<CardPlayableIF> The list of cards that are visible to the player (the two tops aof the decks and the four cards that are drawable).private final Map
<PlayerLobby, PlayerState> The players in the game, mapped via their player lobbyprivate int
Number of turns to reach the end of the turn-based phase.private List
<PlayerLobby> Winner of the game, initially null -
Constructor Summary
ConstructorsConstructorDescriptionGameState
(GameModelIF model) Creates a new representation of the game's state starting from the given interface of model -
Method Summary
Modifier and TypeMethodDescriptionint
int
getPlayerState
(PlayerLobby playerLobby) int
(package private) void
setCurrentPlayer
(PlayerLobby currentPlayer) Set the current player(package private) void
setGameStatus
(GameStatus gameStatus) Set the current game status(package private) void
setPickables
(List<CardPlayableIF> pickables) Sets the (6) pickable cards.void
setTurnsToEnd
(int turnsToEnd) Sets the number of turns till the end.void
setWinner
(List<PlayerLobby> winners) Sets the winner.
-
Field Details
-
gameId
private final int gameIdGame ID for this game -
players
The players in the game, mapped via their player lobby -
pickables
The list of cards that are visible to the player (the two tops aof the decks and the four cards that are drawable). Following game's rules, this should be always of size 6 -
commonObjectives
The list of objectives that are common to all players Following game's rules, this should be always of size 2 -
gameStatus
The current game status -
currentPlayer
The current player in a turn-based phase (the one who must play or pick a card). Null if the game phase is different from IN_GAME or FINAL_PHASE -
firstPlayer
The first player (from which the rounds start) -
winner
Winner of the game, initially null -
turnsToEnd
private int turnsToEndNumber of turns to reach the end of the turn-based phase. -1 if FINAL_PHASE has not been reached yet
-
-
Constructor Details
-
GameState
Creates a new representation of the game's state starting from the given interface of model- Parameters:
model
- Game model from which to retrieve the game's state
-
-
Method Details
-
getGameId
public int getGameId()- Returns:
- Game ID for this game
-
getPlayers
- Returns:
- List of players in the game. (should not change). The order is the order in a round, from the first player to the last one
-
getPlayerState
- Parameters:
playerLobby
- Player whose the state is to be retrieved- Returns:
- The representation of the state for the given player
-
getPickables
- Returns:
- The list of cards that are visible to the player (the two tops aof the decks and the four cards that are drawable). Following game's rules, this should be always of size 6
-
setPickables
Sets the (6) pickable cards. Note that the is not created another list- Parameters:
pickables
- List of pickable cards to set
-
getCommonObjectives
- Returns:
- The list of objectives that are common to all players Following game's rules, this should be always of size 2
-
getGameStatus
- Returns:
- The current game status
-
setGameStatus
Set the current game status- Parameters:
gameStatus
- Game status to set
-
getCurrentPlayer
- Returns:
- The current player in a turn-based phase (the one who must play or pick a card) Null if the game phase is different from IN_GAME or FINAL
-
setCurrentPlayer
Set the current player- Parameters:
currentPlayer
- Current player to set
-
getFirstPlayer
- Returns:
- The first player (from which the rounds start)
-
getWinner
- Returns:
- Winner of the game, initially null
-
setWinner
Sets the winner. This method should be used only once the game is ended- Parameters:
winners
- Winner to set
-
getTurnsToEnd
public int getTurnsToEnd()- Returns:
- Number of turns to reach the end of the turn-based phase
-
setTurnsToEnd
public void setTurnsToEnd(int turnsToEnd) Sets the number of turns till the end.- Parameters:
turnsToEnd
- Number of turns to reach the end of the turn-based phase
-
countConnected
public int countConnected()- Returns:
- the number of players that are currently connected
-