Package net.royalur.rules.state
Class GameState
java.lang.Object
net.royalur.rules.state.GameState
- Direct Known Subclasses:
ControlGameState
,EndGameState
,OngoingGameState
A game state represents a single point within a game.
-
Constructor Summary
ConstructorDescriptionGameState
(Board board, PlayerState lightPlayer, PlayerState darkPlayer, long timeSinceGameStartMs) Instantiates a game state. -
Method Summary
Modifier and TypeMethodDescriptionabstract String
describe()
Generates an English text description of the state of the game.boolean
getBoard()
Get the state of the pieces on the board.Get the state of the dark player.Get the state of the light player.getPlayerState
(PlayerType player) Gets the state of the playerplayer
.abstract PlayerType
Get the subject player of the game state.long
Gets the time this state was created, measured by the number of milliseconds elapsed since the start of the game.abstract boolean
Returns whether this state represents a finished game.abstract boolean
Returns whether this state is a valid state to be played from.
-
Constructor Details
-
GameState
public GameState(Board board, PlayerState lightPlayer, PlayerState darkPlayer, long timeSinceGameStartMs) Instantiates a game state.- Parameters:
board
- The state of the pieces on the board.lightPlayer
- The state of the light player.darkPlayer
- The state of the dark player.timeSinceGameStartMs
- The time this state was created.
-
-
Method Details
-
getBoard
Get the state of the pieces on the board.- Returns:
- The state of the pieces on the board.
-
getLightPlayer
Get the state of the light player.- Returns:
- The state of the light player.
-
getDarkPlayer
Get the state of the dark player.- Returns:
- The state of the dark player.
-
getPlayerState
Gets the state of the playerplayer
.- Parameters:
player
- The player to retrieve the state of.- Returns:
- The state of the player
player
.
-
getTimeSinceGameStartMs
public long getTimeSinceGameStartMs()Gets the time this state was created, measured by the number of milliseconds elapsed since the start of the game.- Returns:
- The time this state was created.
-
getSubject
Get the subject player of the game state. e.g., player to roll/move, player that rolled/moved, player that won. -
isPlayable
public abstract boolean isPlayable()Returns whether this state is a valid state to be played from.- Returns:
- Whether this state is a valid state to be played from.
-
isFinished
public abstract boolean isFinished()Returns whether this state represents a finished game.- Returns:
- Whether this state represents a finished game.
-
describe
Generates an English text description of the state of the game.- Returns:
- An English text description of the state of the game.
-
equals
-