cm-chess (master) doxdox documentation

It's like chess.js, but in ES6 and can handle variations (tree-structured move history)

# Chess()

Like chess.js, but handles variations and is written in ES5 Uses chess.js for validation and cm-pgn for the history and PGN header

# header()

# history()

cm-chess uses cm-pgn for the history and header. See https://github.com/shaack/cm-pgn

# load(fen)

Load a FEN

Parameters

Name Types Description
fen

# loadPgn(pgn)

Load a PGN with variations, NAGs, header and annotations. cm-chess uses cm-pgn fot the header and history. See https://github.com/shaack/cm-pgn

Parameters

Name Types Description
pgn

# move(move, previousMove, sloppy)

Make a move in the game.

Parameters

Name Types Description
move
previousMove optional, the previous move (for variations)
sloppy to allow sloppy SAN

# Pgn.js()

Author and copyright: Stefan Haack (https://shaack.com) Repository: https://github.com/shaack/cm-chess License: MIT, see file 'LICENSE'

# renderPgn(renderHeader, renderComments, renderNags)

Render the game as PGN with header, comments and NAGs

Parameters

Name Types Description
renderHeader optional, default true
renderComments optional, default true
renderNags optional, default true

# setUpFen()

# this.lastMove()

# this.lastMove(move)

Parameters

Name Types Description
move optional

# this.lastMove(move)

Parameters

Name Types Description
move optional

# this.lastMove(move)

Parameters

Name Types Description
move optional

# this.lastMove(move)

Parameters

Name Types Description
move optional

# this.lastMove(move)

Parameters

Name Types Description
move optional

# this.lastMove(move)

Parameters

Name Types Description
move optional

# this.lastMove(move)

Parameters

Name Types Description
move optional

# this.lastMove(options, move)

Return all valid moves

Parameters

Name Types Description
options {{ square: "e2", piece: "n", verbose: true }} Fields with { verbose: true } - color indicates the color of the moving piece (w or b). - from and to fields are from and to squares in algebraic notation. - piece, captured, and promotion fields contain the lowercase representation of the applicable piece (pnbrqk). The captured and promotion fields are only present when the move is a valid capture or promotion. - san is the move in Standard Algebraic Notation (SAN). - flags field contains one or more of the string values: n - a non-capture b - a pawn push of two squares e - an en passant capture c - a standard capture p - a promotion k - kingside castling q - queenside castling A flags value of pc would mean that a pawn captured a piece on the 8th rank and promoted.
move

# this.lastMove(type, color, move)

Get the position of the specified figures at a specific move

Parameters

Name Types Description
type "p", "n", "b",...
color "b" or "w"
move

# this.lastMove(square, move)

get the piece on a square

Parameters

Name Types Description
square
move

# this.lastMove(move)

Parameters

Name Types Description
move

# this.lastMove(move)

Undo a move and all moves after it

Parameters

Name Types Description
move

# tMove()

# validateMove(move, previousMove, sloppy)

Don't make a move, just validate, if it would be a correct move

Parameters

Name Types Description
move
previousMove optional, the previous move (for variations)
sloppy to allow sloppy SAN

# Fen()

Author and copyright: Stefan Haack (https://shaack.com) Repository: https://github.com/shaack/cm-chess License: MIT, see file 'LICENSE'

# parse(fen)

https://en.wikipedia.org/wiki/Forsyth–Edwards_Notation

Parameters

Name Types Description
fen

# Header.js()