Class Move

java.lang.Object
net.royalur.model.Move

public class Move extends Object
A move that can be made on a board.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Move(PlayerType player, Tile source, Piece sourcePiece, Tile dest, Piece destPiece, Piece capturedPiece)
    Creates a new move with origin source and destination dest.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(Board board)
    Apply this move to update the board board.
    Generates an English description of this move.
    boolean
     
    Gets the piece that will be captured by this move.
    Gets the piece that will be captured by this move, or null if there is no piece that will be captured.
    Gets the destination tile of this move.
    Gets the destination tile of this move, including off the board tiles when scoring a piece.
    int
    Gets the index of the destination piece in the path.
    Gets the destination tile of this move, or else returns null if there is no destination piece, in the case where a piece is moved off the board.
    Gets the destination piece of this move.
    Gets the destination piece of this move, or null if there is no destination piece, in the case where a piece is moved off the board.
    int
    Gets the index of the source tile of this move in the player's path.
    Gets the instigator of this move.
    Gets the source tile of this move.
    Gets the source tile of this move, including off the board tiles when introducing a piece.
    int
    Gets the index of the source piece in the path, or -1 if there is no source piece.
    Gets the source tile of this move, or else returns null if there is no source piece, in the case where a new piece is moved onto the board.
    Gets the source piece of this move.
    Gets the source piece of this move, or null if there is no source piece, in the case where a new piece is moved onto the board.
    boolean
    Determines whether this moves a piece to a destination on the board.
    int
     
    boolean
    Determines whether this move is moving a piece on the board.
    boolean
    Determines whether this move is capturing an existing piece on the board.
    boolean
    Determines whether this move will land a piece on a rosette.
    boolean
    Determines whether this move is moving a new piece onto the board.
    boolean
    Determines whether this move is moving a piece off of the board to score it.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Move

      public Move(PlayerType player, @Nullable Tile source, @Nullable Piece sourcePiece, @Nullable Tile dest, @Nullable Piece destPiece, @Nullable Piece capturedPiece)
      Creates a new move with origin source and destination dest. If source is null, it represents moving a new piece onto the board. If dest is null, it represents moving a piece off of the board.
      Parameters:
      player - The player that is the instigator of this move.
      source - The origin of the move. If this is null, it represents moving a new piece onto the board.
      sourcePiece - The piece on the board to be moved, or null if a new piece is to be moved onto the board.
      dest - The destination of the move. If this is null, it represents moving a piece off of the board.
      destPiece - The piece that will be placed at the destination of the move, or null if moving a piece off of the board.
      capturedPiece - The piece that will be captured by this move, or null if no piece would be captured by this move.
  • Method Details

    • getPlayer

      public PlayerType getPlayer()
      Gets the instigator of this move.
      Returns:
      The instigator of this move.
    • hasSource

      public boolean hasSource()
      Determines whether this move is moving a piece on the board. If a move introduces a new piece to the board, then it won't have a source piece.
      Returns:
      Whether this move is moving a piece on the board.
    • isIntroduction

      public boolean isIntroduction()
      Determines whether this move is moving a new piece onto the board.
      Returns:
      Whether this move is moving a new piece onto the board.
    • hasDest

      public boolean hasDest()
      Determines whether this moves a piece to a destination on the board. If a piece is being scored, then it won't have a destination.
      Returns:
      Whether this moves a piece to a destination on the board.
    • isScore

      public boolean isScore()
      Determines whether this move is moving a piece off of the board to score it.
      Returns:
      Whether this move is moving a piece off of the board to score it.
    • isCapture

      public boolean isCapture()
      Determines whether this move is capturing an existing piece on the board.
      Returns:
      Whether this move is capturing an existing piece on the board.
    • isDestRosette

      public boolean isDestRosette(BoardShape shape)
      Determines whether this move will land a piece on a rosette. Under common rule sets, this will give another turn to the player.
      Parameters:
      shape - The shape of the board.
      Returns:
      Whether this move will land a piece on a rosette.
    • getPathIndex

      public int getPathIndex(PathPair paths)
      Gets the index of the source tile of this move in the player's path. If a new piece is introduced, -1 will be returned.
      Parameters:
      paths - The paths used for the game where this move is to take place.
      Returns:
      The index of the source tile of this move in the player's path, or else -1 if this move introduces a piece.
    • getSourceOrNull

      @Nullable public Tile getSourceOrNull()
      Gets the source tile of this move, or else returns null if there is no source piece, in the case where a new piece is moved onto the board.
      Returns:
      The source tile of this move, or null.
    • getSource

      public Tile getSource()
      Gets the source tile of this move. If there is no source tile, in the case where a new piece is moved onto the board, this will throw an error.
      Returns:
      The source tile of this move.
    • getSource

      public Tile getSource(PathPair paths)
      Gets the source tile of this move, including off the board tiles when introducing a piece.
      Parameters:
      paths - The paths around the board that this move follows.
      Returns:
      The source tile of this move, including off the board tiles when introducing a piece.
    • getSourcePieceOrNull

      @Nullable public Piece getSourcePieceOrNull()
      Gets the source piece of this move, or null if there is no source piece, in the case where a new piece is moved onto the board.
      Returns:
      The source piece of this move, or null.
    • getSourcePiece

      public Piece getSourcePiece()
      Gets the source piece of this move. If there is no source piece, in the case where a new piece is moved onto the board, this will throw an error.
      Returns:
      The source piece of this move.
    • getDestOrNull

      @Nullable public Tile getDestOrNull()
      Gets the destination tile of this move, or else returns null if there is no destination piece, in the case where a piece is moved off the board.
      Returns:
      The destination tile of this move, or null.
    • getDest

      public Tile getDest()
      Gets the destination tile of this move. If there is no destination tile, in the case where a piece is moved off the board, this will throw an error.
      Returns:
      The destination tile of this move.
    • getDest

      public Tile getDest(PathPair paths)
      Gets the destination tile of this move, including off the board tiles when scoring a piece.
      Parameters:
      paths - The paths around the board that this move follows.
      Returns:
      The destination tile of this move, including off the board tiles when scoring a piece.
    • getDestPieceOrNull

      @Nullable public Piece getDestPieceOrNull()
      Gets the destination piece of this move, or null if there is no destination piece, in the case where a piece is moved off the board.
      Returns:
      The destination piece of this move, or null.
    • getDestPiece

      public Piece getDestPiece()
      Gets the destination piece of this move. If there is no destination piece, in the case where a piece is moved off the board, this will throw an error.
      Returns:
      The destination piece of this move.
    • getSourceIndex

      public int getSourceIndex()
      Gets the index of the source piece in the path, or -1 if there is no source piece.
      Returns:
      The index of the source piece in the path.
    • getDestIndex

      public int getDestIndex(PathPair paths)
      Gets the index of the destination piece in the path.
      Parameters:
      paths - The paths used for this move.
      Returns:
      The index of the destination piece in the path.
    • getCapturedPieceOrNull

      @Nullable public Piece getCapturedPieceOrNull()
      Gets the piece that will be captured by this move, or null if there is no piece that will be captured.
      Returns:
      The piece that will be captured by this move, or null.
    • getCapturedPiece

      public Piece getCapturedPiece()
      Gets the piece that will be captured by this move. If there is no piece that will be captured, this will throw an error.
      Returns:
      The piece that will be captured by this move.
    • apply

      public void apply(Board board)
      Apply this move to update the board board.
      Parameters:
      board - The board to update by applying this move.
    • describe

      public String describe()
      Generates an English description of this move.
      Returns:
      An English description of this move.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

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