Class SimpleRuleSet

java.lang.Object
net.royalur.rules.RuleSet
net.royalur.rules.simple.SimpleRuleSet

public class SimpleRuleSet extends RuleSet
The most common, simple, rules of the Royal Game of Ur. This still allows a large range of custom rules.
  • Constructor Details

    • SimpleRuleSet

      public SimpleRuleSet(BoardShape boardShape, PathPair paths, DiceFactory diceFactory, PieceProvider pieceProvider, PlayerStateProvider playerStateProvider, boolean safeRosettes, boolean rosettesGrantExtraRolls, boolean capturesGrantExtraRolls)
      Instantiates a simple rule set for the Royal Game of Ur.
      Parameters:
      boardShape - The shape of the game board.
      paths - The paths that the players must take around the board.
      diceFactory - The generator of dice that are used to generate dice rolls.
      pieceProvider - Provides the manipulation of piece values.
      playerStateProvider - Provides the manipulation of player states.
      safeRosettes - Whether rosette tiles are safe squares for pieces.
      rosettesGrantExtraRolls - Whether landing on rosette tiles gives an extra roll.
      capturesGrantExtraRolls - Whether capturing a piece gives an extra roll.
  • Method Details

    • createCompatibleFastGame

      public FastSimpleGame createCompatibleFastGame()
    • areRosettesSafe

      public boolean areRosettesSafe()
      Description copied from class: RuleSet
      Gets whether rosettes are considered safe squares in this rule set.
      Specified by:
      areRosettesSafe in class RuleSet
      Returns:
      Whether rosettes are considered safe squares in this rule set.
    • doRosettesGrantExtraRolls

      public boolean doRosettesGrantExtraRolls()
      Description copied from class: RuleSet
      Gets whether landing on rosette tiles grants an additional roll.
      Specified by:
      doRosettesGrantExtraRolls in class RuleSet
      Returns:
      Whether landing on rosette tiles grants an additional roll.
    • doCapturesGrantExtraRolls

      public boolean doCapturesGrantExtraRolls()
      Description copied from class: RuleSet
      Gets whether capturing a piece grants an additional roll.
      Specified by:
      doCapturesGrantExtraRolls in class RuleSet
      Returns:
      Whether capturing a piece grants an additional roll.
    • generateInitialGameState

      public GameState generateInitialGameState()
      Description copied from class: RuleSet
      Generates the initial state for a game.
      Specified by:
      generateInitialGameState in class RuleSet
      Returns:
      The initial state for a game.
    • findAvailableMoves

      public List<Move> findAvailableMoves(Board board, PlayerState player, Roll roll)
      Description copied from class: RuleSet
      Finds all available moves from the given state.
      Specified by:
      findAvailableMoves in class RuleSet
      Parameters:
      board - The current state of the board.
      player - The current state of the player.
      roll - The roll that was made. Must be non-zero.
      Returns:
      A list of all the available moves from the given state.
    • applyRoll

      public List<GameState> applyRoll(WaitingForRollGameState state, long timeSinceGameStartMs, Roll roll)
      Description copied from class: RuleSet
      Applies roll to state to generate the new state of the game. Multiple game states may be returned to include information game states for maintaining history. However, the latest or highest-index game state will represent the state of the game after the roll was made.
      Specified by:
      applyRoll in class RuleSet
      Parameters:
      state - The current state of the game.
      timeSinceGameStartMs - The time that this roll took place, measured relative to the start of the game.
      roll - The roll that the player made.
      Returns:
      A list of new game states after the given move was made. The list may include historical information game states, and will always include the new state of the game as its last element.
    • shouldGrantExtraRoll

      public boolean shouldGrantExtraRoll(MovedGameState movedState)
      Determines whether the move represented by movedState should grant another roll to the player that made the move.
      Parameters:
      movedState - The state representing a move.
      Returns:
      Whether the player that made the move should be granted another roll.
    • applyMove

      public List<GameState> applyMove(WaitingForMoveGameState state, long timeSinceGameStartMs, Move move)
      Description copied from class: RuleSet
      Applies move to state to generate the new state of the game. Multiple game states may be returned to include information game states for maintaining history. However, the latest or highest-index game state will represent the state of the game after the move was made.

      This method does not check that the given move is valid.

      Specified by:
      applyMove in class RuleSet
      Parameters:
      state - The current state of the game.
      timeSinceGameStartMs - The time that this roll took place, measured relative to the start of the game.
      move - The move that the player chose to make from this position.
      Returns:
      A list of new game states after the given move was made. The list may include historical information game states, and will always include the new state of the game as its last element.
    • selectLandmarkStates

      public List<GameState> selectLandmarkStates(List<GameState> states)
      Description copied from class: RuleSet
      Selects only the states that are required to reproduce exactly what happened in a game using this rule set. This is used to reduce the amount of information saved during serialisation.
      Specified by:
      selectLandmarkStates in class RuleSet
      Parameters:
      states - All the states in a game.