Class PlayerState

java.lang.Object
it.polimi.ingsw.am13.client.gamestate.PlayerState
All Implemented Interfaces:
Serializable

public class PlayerState extends Object implements 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 Details

    • starterCard

      private CardStarterIF starterCard
      Starter card of the player. Null if it has not been set yet.
    • possibleHandObjectives

      private final List<CardObjectiveIF> 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

      private CardObjectiveIF handObjective
      Personal objective card of the player. Null if it has not been chosen yet.
    • isConnected

      private boolean isConnected
      Flag indicating if the player is currently connecting or not. It is set to true by default
    • handPlayable

      private final List<CardPlayableIF> handPlayable
      List of (3 or 2) hand card of the player. Empty if the player has no card
    • points

      private int points
      Points of the players, initially 0
    • field

      private final FieldState field
      Field of the player. It could be an empty field if the player has not played yet
  • Constructor Details

    • PlayerState

      public PlayerState(PlayerIF player)
      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

      public CardStarterIF getStarterCard()
      Returns:
      Starter card of the player. Null if it has not been set yet.
    • setStarterCard

      void setStarterCard(CardStarterIF starterCard)
      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

      public List<CardObjectiveIF> 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

      public CardObjectiveIF getHandObjective()
      Returns:
      Personal objective card of the player. Null if it has not been chosen yet.
    • setHandObjective

      void setHandObjective(CardObjectiveIF handObjective)
      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

      public List<CardPlayableIF> getHandPlayable()
      Returns:
      List of (3 or 2) hand card of the player. Empty if the player has no card
    • removeCardPlayed

      void removeCardPlayed(CardPlayableIF card)
      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

      void addCardPicked(CardPlayableIF card)
      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

      public FieldState getField()
      Returns:
      Field of the player. It could be an empty field if the player has not played yet