Class DatabaseAbstract

Describe a set of chess games, each of them being represented by a Game object.

Methods

  • Return the game corresponding to the given index.

    Parameters

    Returns Game

    exception.InvalidPGN if the corresponding game cannot be parsed, or if the given game index is larger than the number of games in the underlying PGN data.

  • Number of games in the database.

    Returns number

  • Return an Iterable object allowing to iterate over all the (valid) games within the database.

    Example, to print the ASCII representation of all the games within a database:

    const database = ... ;
    for (const game of database.games()) {
    console.log(game.ascii());
    }

    If the database contains some games that cannot be parsed (i.e. games for which the method Database.game would throw a exception.InvalidPGN exception), those games are ignored during the iteration. WARNING: for this reason, the number of games returned by the iterator may be lower than Database.gameCount.

    Returns Iterable<Game>