chess.view.board.Piece Class
Class representing the view of chess pieces in DHTML Chess. Instances of this class are created dynamically by chess.view.Board
Item Index
Methods
- animationComplete
- createDOM
- disableDragAndDrop
- dragPiece
- enableDragAndDrop
- flip
- getColorCode
- getEl
- getPos
- getPosOfSquare
- getSquare
- getSquareByCoordinates
- getTypeCode
- hide
- increaseZindex
- initDragPiece
- isAlreadyOnSquare
- isFlipped
- isVisible
- mouseEnterPiece
- mouseLeavePiece
- playMove
- position
- promote
- resize
- show
- stopDragPiece
- updateBackgroundImage
Methods
animationComplete
()
private
Method executed when move animation is complete
createDOM
()
private
Create DOM elements for the chess piece
disableDragAndDrop
()
Disable drag and drop for the chess piece. This will set the internal ddEnabled property to false and reset cursor to arrow.
dragPiece
-
e
Method executed when dragging has started and mouse moves
Parameters:
-
e
Event
Returns:
enableDragAndDrop
()
Enable drag and drop for the chess piece. This will set the internal ddEnabled property to true and update the cursor to a pointer/hand.
flip
()
Executed when board is flipped. It will call the position method.
getPos
-
square
Return x and y coordinate by 0x88 square number
Parameters:
-
square
Number
Returns:
Example:
var pos = piece.getPos();
// may return
{
"x":"12.5%",
"y":"25%"
}
getPosOfSquare
-
square
Return x and y position of square by 0x88 coordinate(without the % suffix)
Parameters:
-
square
Number
Returns:
hide
()
Hide the chess piece
increaseZindex
()
private
Move piece to front
initDragPiece
-
e
Start dragging a chess piece
Parameters:
-
e
Event
Returns:
isAlreadyOnSquare
-
square
Returns true if piece is already on a given 0x88 square number
Parameters:
-
square
Number
Returns:
mouseEnterPiece
()
private
Method executed when mouse enters a chess piece
mouseLeavePiece
()
private
Method executed when mouse leaves a chess piece
position
-
square
Position piece on board by 0x88 board square coordinate
Parameters:
-
square
Number
promote
-
toType
Promote piece to this type
Parameters:
-
toType
String
Example:
piece.promote('queen');
show
()
Show the chess piece
stopDragPiece
-
e
Stop dragging the chess piece.
Parameters:
-
e
Event
updateBackgroundImage
()
private
Update background image of piece when piece type is set or changed and when size of square is changed.