Class Player

All Implemented Interfaces:
Serializable, Remote
Direct Known Subclasses:
PlayerGUI, PlayerTUI

public class Player extends UnicastRemoteObject implements Serializable
class which represent the parent of PlayerGUI and PlayerTUI. Immutable
See Also:
  • Field Details

    • pingTimeout

      public static final int pingTimeout
      timer for pinging the socket from client to server
      See Also:
    • showErrors

      public static final boolean showErrors
      variable that chooses from debugging or running
      See Also:
    • name

      protected String name
    • objective

      protected PrivateObjective objective
    • librariesOfOtherPlayers

      public ArrayList<Library> librariesOfOtherPlayers
      list of the libraries of all the players in the game
    • board

      public Board board
      the board seen and used by this player
    • library

      public Library library
      the personal library of this player
    • isChairMan

      public boolean isChairMan
      true iff the player is the chairman of this game
    • inStream

      protected transient ObjectInputStream inStream
    • outStream

      protected transient ObjectOutputStream outStream
    • mySocket

      protected transient Socket mySocket
    • fullChat

      protected String fullChat
    • chairmanName

      public String chairmanName
      the name of the chairman of the game
    • netMode

      public NetMode netMode
      the network mode chosen by the user
    • uiMode

      public UIMode uiMode
      the UI mode chosen by the user - not sure if necessary
    • numPlayers

      public int numPlayers
      number of players in this current game
    • CO_1_Done

      protected boolean CO_1_Done
    • CO_2_Done

      protected boolean CO_2_Done
    • activeName

      public String activeName
      the name of the player currently having his turn
    • pointsUntilNow

      public int pointsUntilNow
      points achieved until now with the common objectives
    • endGame

      protected boolean endGame
    • pointsMap

      public HashMap<String,Integer> pointsMap
      points achieved until now with the common objectives by all the other players: (name, points)
    • closed

      protected boolean closed
    • turnThread

      protected transient Thread turnThread
  • Constructor Details

    • Player

      public Player() throws RemoteException
      constructor used by the server to initializer a base Player object
      Throws:
      RemoteException - exc
    • Player

      public Player(Player p) throws RemoteException
      copy constructor for the Player object
      Parameters:
      p - the Player object to copy
      Throws:
      RemoteException - exc
    • Player

      public Player(PlayerSend p) throws RemoteException
      constructor that built a Player object from an old PlayerSend Object (used for persistence)
      Parameters:
      p - the old PlayerObject that was saved on the server
      Throws:
      RemoteException - exc
  • Method Details

    • clone

      public void clone(PlayerTUI p)
      Clone the player on the client in the player on the server
      Parameters:
      p - the Player that will be cloned in the current Object
    • checkRawCoords

      protected boolean checkRawCoords(String[] s)
      Check if the input by the user is correct
      Parameters:
      s - array of the coordinates
      Returns:
      true if the input is correct
    • doesPlayerExists

      protected boolean doesPlayerExists(String name)
      check if the name of a player exists in the game (used by the chat)
      Parameters:
      name - the name to check in this game
      Returns:
      true iff that player actually exists in the current game
    • pickCards

      protected void pickCards(ArrayList<Integer> coord, int col)
      take the cards from the board and transfer them in the player library
      Parameters:
      coord - the list of coupled coordinates of the cards that the player want to take from the board
    • setPrivateObjective

      public void setPrivateObjective(PrivateObjective obj)
      setter for the PO
      Parameters:
      obj - the PO that needs to be set
    • setName

      public void setName(String n)
      setter for the attribute name
      Parameters:
      n - the name to set
    • setIsChairMan

      public void setIsChairMan(boolean b)
      setter for the attribute isChairMan
      Parameters:
      b - the boolean to set
    • getInStream

      public ObjectInputStream getInStream()
      getter for the socket input stream (from the server)
      Returns:
      the input stream of this player
    • getName

      public String getName()
      getter for the name
      Returns:
      the name of the player
    • getIsChairMan

      public boolean getIsChairMan()
      getter for the isChairMan
      Returns:
      if is chairman
    • getCO_1_Done

      public boolean getCO_1_Done()
      getter for the first common objective
      Returns:
      the first common objective
    • getCO_2_Done

      public boolean getCO_2_Done()
      getter for the second common objective
      Returns:
      the second common objective
    • getFullChat

      public String getFullChat()
      getter for the full chat
      Returns:
      the full chat until now
    • getEndGame

      public boolean getEndGame()
      getter for the endGame
      Returns:
      if the game is in endGame
    • getPrivateObjective

      public PrivateObjective getPrivateObjective()
      Getter for the private objective
      Returns:
      the private objective of the player