Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TTMatch<T>

The match

The match is often an tournament or a competition in table tennis. It should not be confused with a set or game.

This type is intended to be (re-)created whenever data needs to be updated. It should not be used as a way of storing match data.

Type parameters

  • T

    A type to associate the players. Can be a string or an object.

Hierarchy

  • TTMatch

Index

Constructors

constructor

  • Type parameters

    • T

    Returns TTMatch<T>

Properties

Private Readonly players

players: T[] = ...

Private Readonly sets

sets: TTMatchSet[] = ...

Methods

addPlayer

  • addPlayer(player: T): number
  • Adds a player (or team) to the match. A match can have multiple players (unlike a set that has two).

    Parameters

    • player: T

      The information about a player

    Returns number

    A number to be used as homePlayerId or awayPlayerId

addSet

  • addSet(homePlayerId: number, awayPlayerId: number, set: TTSet): number
  • Adds a played set to the game.

    Parameters

    • homePlayerId: number

      The id of the home player (must be associated with this match)

    • awayPlayerId: number

      The id of the away player (must be associated with this match)

    • set: TTSet

      The state of the set

    Returns number

    An number to identify the added set.

getPlayerById

  • getPlayerById(id: number): T
  • Retrieves an previously added player.

    Parameters

    • id: number

      The id of the player when it was added to the match.

    Returns T

getPlayers

  • getPlayers(): { id: number; player: T }[]
  • Retrieves all previously added players.

    Returns { id: number; player: T }[]

getSetById

  • Retrieves an previously added set.

    Parameters

    • id: number

      The id of a set when it was added to the match

    Returns TTMatchSet

getSets

Private isPlayerIdKnown

  • isPlayerIdKnown(id: number): boolean

Private isSetKnown

  • isSetKnown(set: TTSet): boolean

Generated using TypeDoc