Class GameState

java.lang.Object
net.royalur.rules.state.GameState
Direct Known Subclasses:
ControlGameState, EndGameState, OngoingGameState

public abstract class GameState extends Object
A game state represents a single point within a game.
  • 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

      public Board getBoard()
      Get the state of the pieces on the board.
      Returns:
      The state of the pieces on the board.
    • getLightPlayer

      public PlayerState getLightPlayer()
      Get the state of the light player.
      Returns:
      The state of the light player.
    • getDarkPlayer

      public PlayerState getDarkPlayer()
      Get the state of the dark player.
      Returns:
      The state of the dark player.
    • getPlayerState

      public PlayerState getPlayerState(PlayerType player)
      Gets the state of the player player.
      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

      @Nullable public abstract PlayerType 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

      public abstract String describe()
      Generates an English text description of the state of the game.
      Returns:
      An English text description of the state of the game.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object