Node()

Represent one move in the tree structure formed by a chess game with multiple variations.

new Node()

This constructor is not exposed in the public Kokopu API. Only internal objects and functions are allowed to instantiate Node objects.

Methods

addNag(nag)

Add the given NAG to the current move.

Parameters:
Name Type Description
nag number

addVariation(isLongVariation) → {Variation}

Create a new variation that can be played instead of the current move.

Parameters:
Name Type Description
isLongVariation boolean
Returns:
Variation

comment(value, isLongCommentopt)

Set the text comment associated to the current move.

Parameters:
Name Type Attributes Default Description
value string
isLongComment boolean <optional>
false

comment()nullable {string}

Get the text comment associated to the current move.

Returns:
string -

undefined if no comment is defined for the move.

fullMoveNumber() → {number}

Full-move number. It starts at 1, and is incremented after each black move.

Returns:
number

hasNag(nag) → {boolean}

Check whether the current move has the given NAG or not.

Parameters:
Name Type Description
nag number
Returns:
boolean

isLongComment() → {boolean}

Whether the text comment associated to the current move is long or short.

Returns:
boolean

moveColor() → {Color}

Color the side corresponding to the current move.

Returns:
Color

nags() → {Array.<number>}

Return the NAGs associated to the current move.

Returns:
Array.<number>

next()nullable {Node}

Go to the next move within the same variation.

Returns:
Node -

undefined if the current move is the last move of the variation, or the current node pointing at the next move otherwise.

notation() → {string}

SAN representation of the move associated to the current node.

Returns:
string

play(move) → {Node}

Play the given move, and make the current Node point at the resulting position.

Parameters:
Name Type Description
move string

SAN notation (or '--' for a null-move).

Throws:

If the move notation cannot be parsed.

Type
module:exception.InvalidNotation
Returns:
Node -

The current node, pointing at the new position.

position() → {Position}

Chess position obtained after the current move.

Returns:
Position

positionBefore() → {Position}

Chess position before the current move.

Returns:
Position

removeNag(nag)

Remove the given NAG from the current move.

Parameters:
Name Type Description
nag number

tag(tagKey)nullable {string}

Get the value associated to the given tag key on the current move.

Parameters:
Name Type Description
tagKey string
Returns:
string -

undefined if no value is associated to this tag key on the current move.

tag(tagKey, valuenullable)

Set the value associated to the given tag key on the current move.

Parameters:
Name Type Attributes Description
tagKey string
value string <nullable>

tags() → {Array.<string>}

Return the keys of the tags associated to the current move.

Returns:
Array.<string>

variations() → {Array.<Variation>}

Return the variations that can be followed instead of the current move.

Returns:
Array.<Variation>