API Docs for:
Show:

Pawn Class

Module: Pieces

A Pawn class, represents a Knight piece

Constructor

Pawn

(
  • color
  • type
  • X
  • Y
  • id
)

Parameters:

  • color Object

    pawn's color

  • type Object

    type of the piece, e.g. "Pawn"

  • X Object

    x coordinate on the board (0-7), 0 represents 'a' file, 7 represents 'h' file

  • Y Object

    y coordinate on the board (0-7), 0 represents 8-th rank, 7 represnts 1-st rank

  • id Object

    id of the piece

Methods

getCoveredFields

() Array

get piece covered fields

Returns:

Array:

an array of (x,y) coordinates represents a set of fields, covered by a piece

getImageSource

() String

get relative path to the piece image

Returns:

String:

path to the piece image

getLegalMoves

() Array

get piece legal moves

Returns:

Array:

an array of (x,y) coordinates represents a legal moves for a piece

getNotationSymbol

() String

get notation symbol of the piece

Returns:

String:

notation symbol

isPromotionMove

(
  • chessCoor
)
Boolean

moves piece to a new field

Parameters:

  • chessCoor Object

    an object represents the coordinates of the field where pawn promotes

Returns:

Boolean:

true in case the move is promotion of a pawn, false otherwise

move

(
  • x
  • y
  • pc
)
Object

moves piece to a new field

Parameters:

  • x Number

    x coordinate of destination

  • y Number

    y coordinate of destination

  • pc String

    represents a promotion choice in case of pawn promotion. Valid values are 'Q' for Queen,'R' for Rook,'N' for Knight,'B' for Bishop or null in case pawn does not promote on that move.

Returns:

Object:

object represents a summary of the move

Properties

canBeTakenEnPassant

Boolean

Boolean flag if piece can be taken en passant

color

String

Pawn's color

ID

Number

Pawn's ID

notationName

String

notation symbol

type

String

Pawn's type

X

Number

x coordinate

Y

Number

y coordinate