chess.view.position.Board Class
Chess board for the position setup dialog
Item Index
Methods
Events
Methods
clearBoard
()
Remove all pieces from the board
Returns:
disableDragAndDrop
()
Disable drag and drop feature of the board
Returns:
enableDragAndDrop
-
model
Enable drag and drop feature of the board. It expects a game model as first argument. When connected to a controller event, the controller always sends current game model as first argument when it fire events.
Parameters:
-
model
Object
Returns:
flip
()
Flip board
Returns:
flipToBlack
()
Show blacks pieces at the bottom. If black is allready on the bottom, this method will do nothing.
flipToWhite
()
Show whites pieces at the bottom. If white is allready on the bottom, this method will do nothing.
getCountPiecesOnBoard
()
Return number of visible pieces on the board
Returns:
getPieceOnSquare
-
square
Returns JSON object for a piece on a specific square or null if no piece is on the square
Parameters:
-
square
String
Example:
alert(board.getPieceOnSquare('e4');
playChainOfMoves
-
model
-
move
Animate/Play the "movements" involved in a move, example: O-O involves two moves, moving the king and moving the rook. By default, this method will be executed when the controller fires newMove or nextmove event.
Parameters:
-
model
game.model.Game -
move
Object
Example:
{ m: 'O-O', moves : [{ from: 'e1', to: 'g1' },{ from:'h1', to: 'f1'}] }
resetBoard
()
This method resets the board to the standard position at start of games
Returns:
setController
-
controller
All DHTML Chess 3 views are using the setController method. It is used to
control behaviour of the view. So if you want to create your own Chess View component, you
should take a look at setController. Example method:
setController : function(controller){
this.parent(controller); // always call supperclass
controller.addEvent('newGame', this.doSomethingOnNewGame.bind(this));
}
Here, the method doSomethingOnNewGame will be executed every time the controller loads a new game
Parameters:
-
controller
Object
showStartBoard
-
model
Show start position of game
Parameters:
-
model
game.model.Game
Returns:
Attributes
string boardLayout
Layout of board. The name correspondes to the suffix of the CSS class ludo-chess-board-container-wood. (In this example wood). If you want to create your own board layout. You can specify a custom value for boardLayout, create your own graphic and implement your own CSS rules. Take a look at css/board/board.css for more info
Default: wood
Events
clearboard
Event fired when all pieces are being removed from the board via the clearBoard() method
Event Payload:
-
Component
Objectthis
move
Event fired when a piece is moved from one square to another
Event Payload:
-
Object
From: "e2", to: "e4"move, example:
resetboard
Event fired when board is reset to standard start position, i.e. fen: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
Event Payload:
-
Component
Objectthis