Class Player

java.lang.Object
be.belegkarnil.game.board.tak.Player
All Implemented Interfaces:
Externalizable, Serializable

public class Player extends Object implements Externalizable
This class represents a Tak player that use a Strategy and owns some Pieces. It also maintains state information like the player name, the current (round) score, the number of round won during a Game, the number of time the player skip his turn (during a round).
Author:
Belegkarnil
See Also:
  • Constructor Details

    • Player

      public Player(String name, Strategy strategy)
      Construct a new player
      Parameters:
      name - The player's name
      strategy - The strategy used by the player
  • Method Details

    • hasPiece

      public final boolean hasPiece(Piece piece)
      Know if the player owns a specific {link @Piece}
      Parameters:
      piece - the piece to know if the player owns
      Returns:
      true iff the player owns the piece
    • getName

      public String getName()
      Get the player's name
      Returns:
      The player's name
    • getScore

      public int getScore()
      Get the current (round) score
      Returns:
      the score
    • countWin

      public int countWin()
      Count the number of times the player won a round during a game
      Returns:
      The number of times the player won a round
    • countSkip

      public int countSkip()
      Count the number of times that the player skip his turn during a round
      Returns:
      the number of times that the player skip his turn
    • countStones

      public int countStones()
      Count the stones Pieces owned by the player
      Returns:
      the number of MENHIR and DOLMEN
    • countCapstones

      public int countCapstones()
      Count the capstones Pieces owned by the player
      Returns:
      the number of DOME
    • getPieces

      public Map<Piece,Integer> getPieces()
      Get a dictionary of amount of Pieces that the player has.
      Returns:
      a Map<Piece,Integer> of key Piece and an Integer amount which is how much pieces the player has.
    • hasPieces

      public boolean hasPieces()
      Know if the player has at least one Piece
      Returns:
      true iff the player has at least one Piece
    • getStrategy

      public Strategy getStrategy()
      Get the strategy used by the player
      Returns:
      The strategy
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Parameters:
      out - see Externalizable
      Throws:
      IOException - see Externalizable
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Parameters:
      in - see Externalizable
      Throws:
      IOException - see Externalizable
      ClassNotFoundException - see Externalizable
    • countPieces

      public int countPieces()
      Count the number of pieces the player owns
      Returns:
      the number of pieces the player has in its hands
    • getColor

      public Color getColor()
      Get the current assigned color of the player
      Returns:
      the assigned color (see Constants)