Pawn Class
A Pawn class, represents a Knight piece
Constructor
Pawn
-
color
-
type
-
X
-
Y
-
id
Parameters:
-
color
Objectpawn's color
-
type
Objecttype of the piece, e.g. "Pawn"
-
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
Properties
Methods
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
isPromotionMove
-
chessCoor
moves piece to a new field
Parameters:
-
chessCoor
Objectan object represents the coordinates of the field where pawn promotes
Returns:
true in case the move is promotion of a pawn, false otherwise
move
-
x
-
y
-
pc
moves piece to a new field
Parameters:
-
x
Numberx coordinate of destination
-
y
Numbery coordinate of destination
-
pc
Stringrepresents 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 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