Package net.royalur.model
Class Move
java.lang.Object
net.royalur.model.Move
A move that can be made on a board.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Apply this move to update the boardboard
.describe()
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.getDest()
Gets the destination tile of this move.Gets the destination tile of this move, including off the board tiles when scoring a piece.int
getDestIndex
(PathPair paths) 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
getPathIndex
(PathPair paths) 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
hasDest()
Determines whether this moves a piece to a destination on the board.int
hashCode()
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
isDestRosette
(BoardShape shape) 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
isScore()
Determines whether this move is moving a piece off of the board to score it.
-
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 originsource
and destinationdest
. Ifsource
isnull
, it represents moving a new piece onto the board. Ifdest
isnull
, 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 isnull
, it represents moving a new piece onto the board.sourcePiece
- The piece on the board to be moved, ornull
if a new piece is to be moved onto the board.dest
- The destination of the move. If this isnull
, it represents moving a piece off of the board.destPiece
- The piece that will be placed at the destination of the move, ornull
if moving a piece off of the board.capturedPiece
- The piece that will be captured by this move, ornull
if no piece would be captured by this move.
-
-
Method Details
-
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Apply this move to update the boardboard
.- Parameters:
board
- The board to update by applying this move.
-
describe
Generates an English description of this move.- Returns:
- An English description of this move.
-
hashCode
public int hashCode() -
equals
-