Package be.belegkarnil.game.board.tak
Class Player
java.lang.Object
be.belegkarnil.game.board.tak.Player
- All Implemented Interfaces:
Externalizable,Serializable
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintCount the capstonesPieces owned by the playerintCount the number of pieces the player ownsintCount the number of times that the player skip his turn during a roundintCount the stonesPieces owned by the playerintcountWin()Count the number of times the player won a round during a gamegetColor()Get the current assigned color of the playergetName()Get the player's nameGet a dictionary of amount ofPieces that the player has.intgetScore()Get the current (round) scoreGet the strategy used by the playerfinal booleanKnow if the player owns a specific {link @Piece}booleanKnow if the player has at least onePiecevoidUsed byExternalizablevoidUsed byExternalizable
-
Constructor Details
-
Player
Construct a new player- Parameters:
name- The player's namestrategy- The strategy used by the player
-
-
Method Details
-
hasPiece
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
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 stonesPieces owned by the player- Returns:
- the number of MENHIR and DOLMEN
-
countCapstones
public int countCapstones()Count the capstonesPieces owned by the player- Returns:
- the number of DOME
-
getPieces
Get a dictionary of amount ofPieces that the player has. -
hasPieces
public boolean hasPieces()Know if the player has at least onePiece- Returns:
- true iff the player has at least one
Piece
-
getStrategy
Get the strategy used by the player- Returns:
- The strategy
-
writeExternal
Used byExternalizable- Specified by:
writeExternalin interfaceExternalizable- Parameters:
out- seeExternalizable- Throws:
IOException- seeExternalizable
-
readExternal
Used byExternalizable- Specified by:
readExternalin interfaceExternalizable- Parameters:
in- seeExternalizable- Throws:
IOException- seeExternalizableClassNotFoundException- seeExternalizable
-
countPieces
public int countPieces()Count the number of pieces the player owns- Returns:
- the number of pieces the player has in its hands
-
getColor
Get the current assigned color of the player- Returns:
- the assigned color (see
Constants)
-