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 (view full)

Methods

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

    Parameters

    • nag: number

    Returns void

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

    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.

    • OptionalisLongComment: 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): 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).

    Parameters

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

          • tagKey: string
          • tagValue: string

          Returns boolean

    Returns void

    AbstractNode.tags for more details on tags.

  • 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 | Node

    undefined if the current variation is empty.

  • 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 Node.fiftyMoveClock).

    Returns number

  • Full-move number at the beginning of the variation (see Node.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 boolean

    false if no comment is defined.

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

    Returns boolean

  • Returns boolean

    Use obj instanceof Variation instead.

  • NAGs associated to the current node or variation.

    Returns number[]

    array sorted in increasing order.

  • 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 | Node

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

  • 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.

    Parameters

    • move: string

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

    Returns Node

    The newly created Node.

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

  • 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.

    Parameters

    • tagKey: string

    Returns undefined | string

    AbstractNode.tags for more details on tags.

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

    Parameters

    • tagKey: string
    • value: undefined | string

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

    Returns void

    AbstractNode.tags for more details on tags.

  • 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 string[]

    array sorted in increasing order.

""