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

name: string

Name of the player

value: number

Numerical value for player, such as rating or seed

Accessors

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

      • Optionalbye?: boolean
      • Optionalcolor?: "w" | "b"
      • Optionaldraw?: number
      • id: string
      • Optionalloss?: number
      • opponent: string
      • OptionalpairUpDown?: boolean
      • Optionalwin?: 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

      • Optionalbye?: boolean
      • Optionalcolor?: "w" | "b"
      • Optionaldraw?: number
      • Optionalloss?: number
      • Optionalopponent?: string
      • OptionalpairUpDown?: boolean
      • Optionalwin?: number

    Returns void