Class Player

java.lang.Object
it.polimi.ingsw.Server.Model.Player

public class Player extends Object
This class represent all player's info and finalize shelf insertion and score update operation
  • Field Details

    • nickname

      private final String nickname
      Player's nickname
    • scoreCards

      private final Stack<ScoreCard> scoreCards
      List of ScoreCards achieved by the player
    • lastAchieved

      private final Map<ScoreCard,CommonGoalCard> lastAchieved
    • position

      private int position
      Player's position relative to the first player clockwise
    • score

      private int score
      Player's score
    • cgCard1

      private CommonGoalCard cgCard1
      First common goal card reference
    • cgCard2

      private CommonGoalCard cgCard2
      Second common goal card reference
    • shelf

      private Shelf shelf
      Player's shelf reference
    • pgCard

      private PersonalGoalCard pgCard
      Player's personal goal card
    • inGame

      private boolean inGame
      Boolean attribute used to check player's presence in the ongoing game
    • achievedCG1

      private boolean achievedCG1
      Boolean attributes that indicate if one of the two common goals is achieved
    • achievedCG2

      private boolean achievedCG2
      Boolean attributes that indicate if one of the two common goals is achieved
  • Constructor Details

  • Method Details

    • setGameParameters

      public void setGameParameters(PersonalGoalCard pgCard, CommonGoalCard cgCard1, CommonGoalCard cgCard2, Board board)
      Setter for initial Game parameters
      Parameters:
      pgCard - Personal Goal Card for the player
      cgCard1 - First Common Goal Card for the game
      cgCard2 - Second Common Goal Card for the game
      board - Board for the game
    • getNickname

      public String getNickname()
      Returns:
      Player's nickname
    • getPosition

      public int getPosition()
      This is a getter method for the position attribute
      Returns:
      int player's position
    • setPosition

      public void setPosition(int position)
      Parameters:
      position - Player's clockwise position in the game
    • getScore

      public int getScore()
      This is a getter method for the score attribute
      Returns:
      int player's score
    • getShelf

      public Shelf getShelf()
      This is a getter method for the shelf attribute
      Returns:
      Player's shelf
    • getPersonalGoalCard

      public PersonalGoalCard getPersonalGoalCard()
      This is a getter method for the PersonalGoalCard
      Returns:
      PersonalGoalCard
    • updateScore

      public void updateScore() throws Exception
      This method updates player's score checking the possible point obtained from the common and personal goal cards
      Throws:
      Exception - related to Model management
    • isInGame

      public boolean isInGame()
      This method returns player's game status
      Returns:
      boolean true if the player is still in game, false otherwise.
    • setOutOfTurn

      public void setOutOfTurn()
      This method set the inGame parameter at false
    • firstShelfFull

      public void firstShelfFull() throws RemoteException
      This method gives to the first player that has fulfilled the shelf an EndGameCard
      Throws:
      RemoteException - related to RMI
    • refreshEntities

      public void refreshEntities(CommonGoalCard cgCard1, CommonGoalCard cgCard2) throws RemoteException
      Refreshment strategy, related to persistency management strategy
      Parameters:
      cgCard1 - new Common Goal Card 1 object
      cgCard2 - new Common Goal Card 2 object
      Throws:
      RemoteException - related to RMI
    • getLastAchieved

      public Map<ScoreCard,CommonGoalCard> getLastAchieved()
      Returns:
      lastly achieved Common Goal Cards objectives
    • getScoreCards

      public Stack<ScoreCard> getScoreCards()
      Returns:
      Player's ScoreCards