API Docs for: 0.0.2
Show:

chess.view.position.Board Class

Chess board for the position setup dialog

Methods

clearBoard

()

Remove all pieces from the board

Returns:

void

disableDragAndDrop

()

Disable drag and drop feature of the board

Returns:

void

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:

Returns:

void

flip

()

Flip board

Returns:

void

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:

int

getPieceOnSquare

(
  • square
)

Returns JSON object for a piece on a specific square or null if no piece is on the square

Parameters:

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:

void

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:

showFen

(
  • fen
)

Show a specific FEN position on the board

Parameters:

Returns:

undefined

showStartBoard

(
  • model
)

Show start position of game

Parameters:

  • model game.model.Game

Returns:

void

Attributes

float animationDuration

Duration of piece animations in seconds.

Default: 0.35

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

string pieceLayout

Layout of pieces, examples: "alphapale", "alpha", "merida", "kingdom"

Default: alphapale

Events

clearboard

Event fired when all pieces are being removed from the board via the clearBoard() method

Event Payload:

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: