Class representing a player

See PlayerValues for detailed descriptions of properties.

Constructors

Properties

active: boolean

If the player is active

id: string

Unique ID of the player

matches: {
    bye: boolean;
    color: "w" | "b";
    draw: number;
    id: string;
    loss: number;
    opponent: string;
    pairUpDown: boolean;
    win: number;
}[]

Array of matches the player is in

Type declaration

  • bye: boolean

    If the match is a bye.

  • color: "w" | "b"

    If the player is player one ('w') or player two ('b') in the match (used in Swiss pairings if colored: true).

  • draw: number

    Number of draws in the match.

  • id: string

    The ID of the match.

  • loss: number

    Number of losses for the player in the match.

  • opponent: string

    The ID of the opponent (or null if no opponent).

  • pairUpDown: boolean

    If the opponent has a different point total before the match (used in Swiss pairings).

  • win: number

    Number of wins for the player in the match.

meta: {
    [key: string]: any;
}

Any extra information

Type declaration

  • [key: string]: any
name: string

Name of the player

value: number

Numerical value for player, such as rating or seed

Accessors

  • set values(options): void
  • Set information about the player (only changes in information need to be included in the object).

    Parameters

    Returns void

Methods

  • Adds a match to the player's record.

    Throws an error if attempting to duplicate a match.

    Parameters

    • match: {
          bye?: boolean;
          color?: "w" | "b";
          draw?: number;
          id: string;
          loss?: number;
          opponent: string;
          pairUpDown?: boolean;
          win?: number;
      }

      Object with match details

      • Optional bye?: boolean
      • Optional color?: "w" | "b"
      • Optional draw?: number
      • id: string
      • Optional loss?: number
      • opponent: string
      • Optional pairUpDown?: boolean
      • Optional win?: number

    Returns void

  • Removes a match from player history.

    Throws an error if the match doesn't exist in the player's records.

    Parameters

    • id: string

      The ID of the match

    Returns void

  • Updates the details of a match.

    Throws an error if the match doesn't exist in the player's records.

    Only needs to contain properties that are being changed.

    Parameters

    • id: string

      The ID of the match

    • values: {
          bye?: boolean;
          color?: "w" | "b";
          draw?: number;
          loss?: number;
          opponent?: string;
          pairUpDown?: boolean;
          win?: number;
      }

      The match details being changed

      • Optional bye?: boolean
      • Optional color?: "w" | "b"
      • Optional draw?: number
      • Optional loss?: number
      • Optional opponent?: string
      • Optional pairUpDown?: boolean
      • Optional win?: number

    Returns void