Class SimplePlayerStateProvider

java.lang.Object
net.royalur.rules.simple.SimplePlayerStateProvider
All Implemented Interfaces:
PlayerStateProvider

public class SimplePlayerStateProvider extends Object implements PlayerStateProvider
Provides new instances of, and manipulations to, simple player states.
  • Constructor Details

    • SimplePlayerStateProvider

      public SimplePlayerStateProvider(int startingPieceCount)
      Creates a new simple player state provider.
      Parameters:
      startingPieceCount - The number of pieces that each player starts with.
  • Method Details

    • getStartingPieceCount

      public int getStartingPieceCount()
      Description copied from interface: PlayerStateProvider
      Gets the number of pieces that players start with.
      Specified by:
      getStartingPieceCount in interface PlayerStateProvider
      Returns:
      The number of pieces that players start with.
    • create

      public PlayerState create(PlayerType player, int pieces, int score)
      Description copied from interface: PlayerStateProvider
      Generates a state for the player player.
      Specified by:
      create in interface PlayerStateProvider
      Parameters:
      player - The player to create the starting state for.
      pieces - The number of pieces the player has yet to play.
      score - The number of pieces the player has scored.
      Returns:
      A player state for the player player.
    • createStartingState

      public PlayerState createStartingState(PlayerType player)
      Description copied from interface: PlayerStateProvider
      Generates the starting state for the player player.
      Specified by:
      createStartingState in interface PlayerStateProvider
      Parameters:
      player - The player to create the starting state for.
      Returns:
      A player state for the player player.
    • applyPieceIntroduced

      public PlayerState applyPieceIntroduced(PlayerState playerState, Piece piece)
      Description copied from interface: PlayerStateProvider
      Generates a new player state that is a copy of playerState, with the given piece introduced to the board.
      Specified by:
      applyPieceIntroduced in interface PlayerStateProvider
      Parameters:
      playerState - The player state to modify the pieces of.
      piece - The piece that was introduced to the board.
      Returns:
      A new player state after the given piece was introduced to the board.
    • applyPieceCaptured

      public PlayerState applyPieceCaptured(PlayerState playerState, Piece piece)
      Description copied from interface: PlayerStateProvider
      Generates a new player state that is a copy of playerState, with the given piece captured.
      Specified by:
      applyPieceCaptured in interface PlayerStateProvider
      Parameters:
      playerState - The player state to modify the pieces of.
      piece - The piece that was captured.
      Returns:
      A new player state after the given piece was captured.
    • applyPieceScored

      public PlayerState applyPieceScored(PlayerState playerState, Piece piece)
      Description copied from interface: PlayerStateProvider
      Generates a new player state that is a copy of playerState, with the given piece scored.
      Specified by:
      applyPieceScored in interface PlayerStateProvider
      Parameters:
      playerState - The player state to modify the score of.
      piece - The piece that was scored.
      Returns:
      A new player state with the given new piece scored.