API Docs for:
Show:

Board Class

Defined in: js/classes/Board.js:1
Module: Pieces

A Board class, represents a state of the game

Constructor

Board

()

Methods

changeSideToMove

()

chnages current side to move

clearSelection

()

clears highlight of the selected piece

drawBoard

()

draws chess board with out pieces

drawCastling

(
  • origin
  • destination
  • piece
)

renders the castling

Parameters:

  • origin Object

    coordinates of origin

  • destination Object

    coordinates of destination

  • piece Object

    piece to castle

drawEnpassant

(
  • origin
  • destination
  • piece
)

renders the en passant capture

Parameters:

  • origin Object

    coordinates of origin

  • destination Object

    coordinates of destination

  • piece Object

    piece to take en passant

drawLegalMoves

()

draws highlight of legal moves

drawMove

(
  • origin
  • destination
  • piece
)

renders the move of a piece

Parameters:

  • origin Object

    coordinates of origin

  • destination Object

    coordinates of destination

  • piece Object

    piece to move

drawPieces

()

draws chess pieces

getBoardWidth

()

gets length of the side of the field

getBoardWidth

()

gets width of the board

getFEN

() String

generates Forsyth–Edwards notation of the current state of the chess game

Returns:

String:

string represnts a Forsyth–Edwards notation of the current state of the chess game

highlightSelectedPiece

(
  • piece
)

draws highlight of selected piece

Parameters:

  • piece Object

    selected piece

setBoard

(
  • data
)

sets a chess board according to a given data

Parameters:

  • data Object

    data represents the state of the game

setBoardSide

(
  • wp_id
)
private

sets a board side of a player according to a given white player id

Parameters:

  • wp_id Number

    white player id

setEnPassant

(
  • coor
)
private

sets a boolean flag to pawn which can be taken en passant

Parameters:

  • coor Object

    the coordinates of the pawn to be set

setPieces

(
  • fen
)
private

sets a pieces property according to a given Forsyth–Edwards notation value

Parameters:

  • fen String

    string represnts a Forsyth–Edwards notation

Properties

blackField

String private

The color of the black fields

boardContext

Object private

canvas context to draw board

drawMoves

Number

Counter of moves to achieve a draw by 50 moves rule

lmovesContext

Object private

canvas context to draw legal moves highlight

pieces

Array

An array of pieces on the board

piecesContext

Object private

canvas context to draw pieces

side

String

Board side, either 'black' or 'white'

sideToMove

String

Current side to move, either 'black' or 'white'

that

Object

self reference

whiteCanCastleLong

String

A flag, represents if white side has right to castle long, valid falues are 'true' and 'false'

whiteCanCastleLong

String

A flag, represents if white side has right to castle short, valid falues are 'true' and 'false'

whiteCanCastleLong

String

A flag, represents if black side has right to castle long, valid falues are 'true' and 'false'

whiteCanCastleLong

String

A flag, represents if black side has right to castle short, valid falues are 'true' and 'false'

whiteField

String private

The color of the white fields