King Class
A King class, represents a King piece
Constructor
King
-
color
-
type
-
X
-
Y
-
id
Parameters:
-
color
Objectking's color
-
type
Objecttype of the piece, e.g. "King"
-
X
Objectx coordinate on the board (0-7), 0 represents 'a' file, 7 represents 'h' file
-
Y
Objecty coordinate on the board (0-7), 0 represents 8-th rank, 7 represnts 1-st rank
-
id
Objectid of the piece
Item Index
Methods
checkCastling
-
direction
checks if King has right to castle
Parameters:
-
direction
Stringdirection of the castling either 'long' or 'short'
Returns:
true if King has right to castle, false otherwise
getCoveredFields
()
Array
get piece covered fields
Returns:
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:
path to the piece image
getLegalMoves
()
Array
get piece legal moves
Returns:
an array of (x,y) coordinates represents a legal moves for a piece
getNotationSymbol
()
String
get notation symbol of the piece
Returns:
notation symbol
move
-
x
-
y
moves piece to a new field
Parameters:
-
x
Numberx coordinate of destination
-
y
Numbery coordinate of destination
Returns:
object represents a summary of the move
Properties
color
String
King's color
ID
Number
King's ID
notationName
String
notation symbol
type
String
King's type
X
Number
x coordinate
Y
Number
y coordinate