Clear all the headers (player names, elos, titles, event name, date, etc...).
The Game.result header is reseted to its default value. The initial position and moves are not modified.
Get the date of the game.
Set the date of the game.
If undefined
, the existing value (if any) is erased.
Set the date of the game.
If the month and/or the day of month are missing, the date of the game will be partially defined (see DateValue for more details regarding partially defined dates).
Optional
month: numberOptional
day: numberGet the date of the game as a standard JavaScript Date
object.
If the day of month is undefined for the current game, the returned Date
object points at the first day of the corresponding month.
If neither the day of month nor the month are undefined for the current game, the returned Date
object points at the first day of the corresponding year.
Get the date of the game as a human-readable string (e.g. 'November 1955'
, 'September 4, 2021'
).
Optional
locales: string | string[]Locales to use to generate the result. If undefined, the default locale of the execution environment is used. See Intl documentation for more details.
FEN representation of the chess position at the end of the game.
The fifty-move clock and full-move number are set according to the move history in the string returned by this method.
Return the node or variation corresponding to the given ID (see Node.id and Variation.id to retrieve the ID of a node or variation).
For the main variation, IDs are built as follows:
'start'
is the ID of the main variation,'3w'
is for instance the ID of the node whose Node.fullMoveNumber is 3 and Node.moveColor is white
(i.e. the 3rd white move if the game starts from the usual initial position),'end'
is an alias corresponding to the last node in the main variation (or the main variation itself if it is empty).For sub-variations, IDs are built as in the following examples:
'2b-v0-start'
is the ID of the sub-variation at index 0 on node '2b'
(in the main variation),'5w-v3-11b'
is the ID of the node whose Node.fullMoveNumber is 11 and Node.moveColor is black within
the sub-variation at index 3 on node '5w'
(in the main variation),'5w-v3-end'
is an alias corresponding to the last node in this sub-variation (or the sub-variation itself if it is empty).If true
, search id
among both IDs and ID aliases. If false
, search among IDs only.
undefined
if the given ID does not correspond to an existing Node and Variation.
FEN representation of the chess position at the beginning of the game.
The fifty-move clock and full-move number are set according to the move history in the string returned by this method.
Get the elo of the player corresponding to the given color.
If defined, the returned value is guaranteed to be an integer >= 0.
Set the elo of the player corresponding to the given color.
If undefined
, the existing value (if any) is erased. Must be an integer >= 0.
Get the name of the player corresponding to the given color.
Set the name of the player corresponding to the given color.
If undefined
, the existing value (if any) is erased.
Get the title of the player corresponding to the given color.
Set the title of the player corresponding to the given color.
If undefined
, the existing value (if any) is erased.
Get the result of the game.
Set the result of the game.
Get the reason of the conclusion of the game. Examples of possible values:
'normal'
: game terminated in a normal fashion,'time forfeit'
: loss due to losing player's failure to meet time control requirements,'adjudication'
: result due to third party adjudication process,'death'
: losing player called to greater things, one hopes,'emergency'
: game concluded due to unforeseen circumstances,This list is not exhaustive and any string is valid value for this field.
Set the name of the opening sub-variation.
If undefined
, the existing value (if any) is erased.
Get the chess game variant of the game.
Static
fromPOJOexception.InvalidPOJO if the given object cannot be decoded, either because it does not follow the schema defined by GamePOJO, or because it would result in an inconsistent game (e.g. if it contains some invalid moves).
Chess game, with the move history, the position at each step of the game, the comments and annotations (if any), the result of the game, and some meta-data such as the name of the players, the date of the game, the name of the tournament, etc...