Class VariationAbstract

Represent one variation in the tree structure formed by a chess game, meaning a starting chess position and a list of moves played consecutively from this position.

Hierarchy

Methods

  • Add the given NAG to the current node or variation.

    Parameters

    • nag: number

    Returns void

  • Erase all the moves in the current Variation: after that, first returns undefined.

    If the current Variation is already empty (i.e. if first returns undefined already), nothing happens.

    Returns void

  • Remove all the NAGs from the current node or variation.

    Returns void

  • Remove all the key-value tag pairs from the the current node or variation.

    See

    tags for more details on tags.

    Returns void

  • Get the text comment (if any) associated to the current node or variation.

    Returns undefined | string

  • Set the text comment associated to the current node or variation.

    Parameters

    • value: undefined | string

      If undefined, the existing value (if any) is erased.

    • Optional isLongComment: boolean

      false by default.

    Returns void

  • Remove from the the current node or variation the NAGs for which the given filter evaluates to false (and keep those for which it evaluates to true).

    Parameters

    • filter: ((nag: number) => boolean)
        • (nag: number): boolean
        • Parameters

          • nag: number

          Returns boolean

    Returns void

  • Remove from the the current node or variation the key-value tag pairs for which the given filter evaluates to false (and keep those for which it evaluates to true).

    See

    tags for more details on tags.

    Parameters

    • filter: ((tagKey: string, tagValue: string) => boolean)
        • (tagKey: string, tagValue: string): boolean
        • Parameters

          • tagKey: string
          • tagValue: string

          Returns boolean

    Returns void

  • FEN representation of the chess position at the end of the variation.

    The fifty-move clock and full-move number are set according to the underlying game in the string returned by this method.

    Returns string

  • Chess position at the end of the variation.

    Returns Position

  • Return the first Node of the current variation.

    Returns

    undefined if the current variation is empty.

    Returns undefined | Node

  • Check whether the current node or variation has the given NAG or not.

    Parameters

    • nag: number

    Returns boolean

  • Identifier of the current Node or Variation within its parent Game.

    WARNING: the ID may change when variations are modified (added, removed, swapped, promoted...) among the parents the current node.

    Returns string

  • FEN representation of the chess position at the beginning of the variation.

    The fifty-move clock and full-move number are set according to the underlying game in the string returned by this method.

    Returns string

  • Number of half-moves since the last pawn move or capture at the beginning of the variation (see fiftyMoveClock).

    Returns number

  • Full-move number at the beginning of the variation (see fullMoveNumber).

    Returns number

  • Chess position at the beginning of the variation.

    Returns Position

  • Whether the text comment associated to the current node or variation is long or short.

    Returns

    false if no comment is defined.

    Returns boolean

  • Whether the current variation is considered as a "long" variation, i.e. a variation that should be displayed in an isolated block.

    Returns boolean

  • Deprecated

    Use obj instanceof Variation instead.

    Returns boolean

  • NAGs associated to the current node or variation.

    Returns

    array sorted in increasing order.

    Returns number[]

  • Return the nodes corresponding to the moves of the current variation.

    Returns Node[]

  • Return the Node to which the current variation is attached.

    Returns

    undefined if the current variation is the main one (see mainVariation).

    Returns undefined | Node

  • Create a new node representing the given move, and append it to the current node or variation.

    If there are some pre-existing subsequent nodes, they are all erased.

    Returns

    The newly created Node.

    Throws

    InvalidNotation if the move notation cannot be parsed, or if the parsed move would correspond to an illegal move.

    Parameters

    • move: string

      SAN representation of the move, or '--' for a null-move.

    Returns Node

  • Number of half-moves in the current variation.

    Returns number

  • Remove the given NAG from the current node or variation.

    Parameters

    • nag: number

    Returns void

  • Get the value associated to the given tag key on the current node or variation.

    See

    tags for more details on tags.

    Parameters

    • tagKey: string

    Returns undefined | string

  • Set the value associated to the given tag key on the current node or variation.

    See

    tags for more details on tags.

    Parameters

    • tagKey: string
    • value: undefined | string

      If undefined, the existing value (if any) is erased.

    Returns void

  • Return the keys of the tags associated to the current node or variation.

    The tag mechanism is a key-value associative container allowing to store some arbitrary data on each node or variation. In PGN, the tags are represented as [%tagKey tagValue] strings appended to text comments.

    The tag keys must be non-empty, and can contain only alphanumeric or underscore characters.

    Returns

    array sorted in increasing order.

    Returns string[]

Generated using TypeDoc