Board Class
A Board class, represents a state of the game
Constructor
Board
()
Item Index
Methods
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
Objectcoordinates of origin
-
destination
Objectcoordinates of destination
-
piece
Objectpiece to castle
drawEnpassant
-
origin
-
destination
-
piece
renders the en passant capture
Parameters:
-
origin
Objectcoordinates of origin
-
destination
Objectcoordinates of destination
-
piece
Objectpiece to take en passant
drawLegalMoves
()
draws highlight of legal moves
drawMove
-
origin
-
destination
-
piece
renders the move of a piece
Parameters:
-
origin
Objectcoordinates of origin
-
destination
Objectcoordinates of destination
-
piece
Objectpiece 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 represnts a Forsyth–Edwards notation of the current state of the chess game
highlightSelectedPiece
-
piece
draws highlight of selected piece
Parameters:
-
piece
Objectselected piece
setBoard
-
data
sets a chess board according to a given data
Parameters:
-
data
Objectdata represents the state of the game
setBoardSide
-
wp_id
sets a board side of a player according to a given white player id
Parameters:
-
wp_id
Numberwhite player id
setEnPassant
-
coor
sets a boolean flag to pawn which can be taken en passant
Parameters:
-
coor
Objectthe coordinates of the pawn to be set
setPieces
-
fen
sets a pieces property according to a given Forsyth–Edwards notation value
Parameters:
-
fen
Stringstring 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