Class NodeAbstract

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

Hierarchy

Methods

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

    Parameters

    • nag: number

    Returns void

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

    Parameters

    • Optional isLongVariation: boolean

      false by default.

    Returns Variation

  • 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

  • FEN representation of the chess position after the current move.

    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, after the current move.

    Returns number

  • SAN-like representation of the move associated to the current node (or '--' for a null-move).

    Here, chess pieces are represented with their respective unicode character, instead of the first letter of their English name.

    Returns string

  • 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

  • Full-move number. It starts at 1 (by default), and is incremented after each black move.

    Returns number

  • 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

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

    Returns

    false if no comment is defined.

    Returns boolean

  • Deprecated

    Use obj instanceof Variation instead.

    Returns boolean

  • Color of the player who plays the current move.

    Returns Color

  • NAGs associated to the current node or variation.

    Returns

    array sorted in increasing order.

    Returns number[]

  • Return the Node that comes after the current one in their parent variation.

    Returns

    undefined if the current node is the last one of the variation.

    Returns undefined | Node

  • SAN representation of the move associated to the current node (or '--' for a null-move).

    Returns string

  • 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

  • Chess position obtained after the current move.

    Returns Position

  • Chess position before the current move.

    Returns Position

  • Return the Node that comes before the current one in their parent variation.

    Returns

    undefined if the current node is the first one of the variation.

    Returns undefined | Node

  • Replace the move on the current node (and the following ones, if any) by the moves of the variation corresponding to the given index, and create a new variation with the move on the current node and its successors.

    WARNING: the promoted variation must NOT be empty (otherwise an exception is thrown).

    Parameters

    • variationIndex: number

      Index of the variation to promote (must be such that 0 <= variationIndex < thisNode.variations().length).

    Returns void

  • Erase all the moves after the one on the current Node: after that, next returns undefined.

    If the current Node is already the last one in its variation (i.e. if next returns undefined already), nothing happens.

    Returns void

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

    Parameters

    • nag: number

    Returns void

  • Remove the variation corresponding to the given index.

    Parameters

    • variationIndex: number

      Index of the variation to remove (must be such that 0 <= variationIndex < thisNode.variations().length).

    Returns void

  • Change the order of the variations by swapping the two variations corresponding to the given indexes.

    Parameters

    • variationIndex1: number

      Index of one variation to swap (must be such that 0 <= variationIndex1 < thisNode.variations().length).

    • variationIndex2: number

      Index of the other variation to swap (must be such that 0 <= variationIndex2 < thisNode.variations().length).

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

  • Alternative variations that can be followed instead of the current move.

    Returns Variation[]

Generated using TypeDoc
Feb 25, 2024