MoveDescriptor()

Describe a legal chess move, with its characteristics.

new MoveDescriptor()

This constructor is not exposed in the public Kokopu API. Only internal objects and functions are allowed to instantiate MoveDescriptor objects.

Methods

capturedColoredPiece() → {ColoredPiece}

Color and type of the captured piece.

Throws:

If the current move is not a capture (see MoveDescriptor#isCapture).

Type
module:exception.IllegalArgument
Returns:
ColoredPiece

capturedPiece() → {Piece}

Type of the captured piece.

Throws:

If the current move is not a capture (see MoveDescriptor#isCapture).

Type
module:exception.IllegalArgument
Returns:
Piece

color() → {Color}

Color of the moving piece.

Returns:
Color

coloredPromotion() → {ColoredPiece}

Color and type of the promoted piece, in case of a promotion.

Throws:

If the current move is not a promotion (see MoveDescriptor#isPromotion).

Type
module:exception.IllegalArgument
Returns:
ColoredPiece

enPassantSquare() → {Square}

Square containing the captured pawn, in case of a en-passant move.

Throws:

If the current move is not a en-passant move (see MoveDescriptor#isEnPassant).

Type
module:exception.IllegalArgument
Returns:
Square

from() → {Square}

Origin square of the moving piece. In case of castling, this is the origin square of the king.

Returns:
Square

isCapture() → {boolean}

Whether or not the current move is a capture (either a regular capture or a en-passant capture).

Returns:
boolean

isCastling() → {boolean}

Whether or not the current move is a castling move.

Returns:
boolean

isEnPassant() → {boolean}

Whether or not the current move is a en-passant move.

Returns:
boolean

isPromotion() → {boolean}

Whether or not the current move is a promotion.

Returns:
boolean

movingColoredPiece() → {ColoredPiece}

Color and type of the moving piece. In case of castling, the moving piece is considered to be the king.

Returns:
ColoredPiece

movingPiece() → {Piece}

Type of the moving piece. In case of castling, the moving piece is considered to be the king.

Returns:
Piece

promotion() → {Piece}

Type of the promoted piece, in case of a promotion.

Throws:

If the current move is not a promotion (see MoveDescriptor#isPromotion).

Type
module:exception.IllegalArgument
Returns:
Piece

rookFrom() → {Square}

Origin square of the rook, in case of a castling move.

Throws:

If the current move is not a castling move (see MoveDescriptor#isCastling).

Type
module:exception.IllegalArgument
Returns:
Square

rookTo() → {Square}

Destination square of the rook, in case of a castling move.

Throws:

If the current move is not a castling move (see MoveDescriptor#isCastling).

Type
module:exception.IllegalArgument
Returns:
Square

to() → {Square}

Destination square of the moving piece. In case of castling, this is the destination square of the king.

Returns:
Square