java.lang.Object
it.polimi.ingsw.am13.client.gamestate.PlayerState
- All Implemented Interfaces:
Serializable
Representation of the state of one player in game.
It stores information about their starter card, the possible hand objectives and the chosen one, the cards in hand,
the points, the field (with the placed cards) and whether they are connected.
All the information can be set in any time, with no limitation or checks.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FieldState
Field of the player.private CardObjectiveIF
Personal objective card of the player.private final List
<CardPlayableIF> List of (3 or 2) hand card of the player.private boolean
Flag indicating if the player is currently connecting or not.private int
Points of the players, initially 0private final List
<CardObjectiveIF> List of (2) possible objective card, from with the player must choose for their personal objective card to hold for the game.private CardStarterIF
Starter card of the player. -
Constructor Summary
ConstructorsConstructorDescriptionPlayerState
(PlayerIF player) Builds a new representation of the player's state starting from their interface. -
Method Summary
Modifier and TypeMethodDescription(package private) void
addCardPicked
(CardPlayableIF card) Adds the given card to the player's handgetField()
int
boolean
(package private) void
Removes the given card from the player's hand.(package private) void
setConnected
(boolean connected) Sets the flag for connection of player(package private) void
setHandObjective
(CardObjectiveIF handObjective) Sets the player's chosen personal objective card.(package private) void
setPoints
(int points) Sets the player's current points.(package private) void
setStarterCard
(CardStarterIF starterCard) Sets the player's starter card.
-
Field Details
-
starterCard
Starter card of the player. Null if it has not been set yet. -
possibleHandObjectives
List of (2) possible objective card, from with the player must choose for their personal objective card to hold for the game. Null if they have not been set yet. -
handObjective
Personal objective card of the player. Null if it has not been chosen yet. -
isConnected
private boolean isConnectedFlag indicating if the player is currently connecting or not. It is set to true by default -
handPlayable
List of (3 or 2) hand card of the player. Empty if the player has no card -
points
private int pointsPoints of the players, initially 0 -
field
Field of the player. It could be an empty field if the player has not played yet
-
-
Constructor Details
-
PlayerState
Builds a new representation of the player's state starting from their interface.- Parameters:
player
- Interface of the player whose state is to be built
-
-
Method Details
-
getStarterCard
- Returns:
- Starter card of the player. Null if it has not been set yet.
-
setStarterCard
Sets the player's starter card. Following game's rules, this method should be used only once if the starter card is not already set- Parameters:
starterCard
- Starter card to set
-
getPossibleHandObjectives
- Returns:
- List of (2) possible objective card, from with the player must choose for their personal objective card to hold for the game. Null if they have not been set yet.
-
getHandObjective
- Returns:
- Personal objective card of the player. Null if it has not been chosen yet.
-
setHandObjective
Sets the player's chosen personal objective card. Following game's rules, this method should be used only once if the personal objective card is not already set- Parameters:
handObjective
- Personal objective card to set
-
getHandPlayable
- Returns:
- List of (3 or 2) hand card of the player. Empty if the player has no card
-
removeCardPlayed
Removes the given card from the player's hand. If the given card is not in player's hand, nothing changes.- Parameters:
card
- Card to remove from player's hand
-
addCardPicked
Adds the given card to the player's hand- Parameters:
card
- Card to add to player's hand
-
getPoints
public int getPoints()- Returns:
- Points of the players, initially 0
-
setPoints
void setPoints(int points) Sets the player's current points.- Parameters:
points
- Points to set
-
isConnected
public boolean isConnected()- Returns:
- Flag indicating if the player is currently connecting or not. It is set to true by default
-
setConnected
void setConnected(boolean connected) Sets the flag for connection of player- Parameters:
connected
- Flag for connection to set
-
getField
- Returns:
- Field of the player. It could be an empty field if the player has not played yet
-