Options
All
  • Public
  • Public/Protected
  • All
Menu

The Elimination Tournament Class. Runs a single-elimination tournament. The Elimination Tournament namespace

Meant for single instance use only

Hierarchy

  • Tournament
    • Elimination

Index

Type aliases

Static QueuedMatch

QueuedMatch: Array<nanoid>

Queued match information, consisting of player IDs of players to compete

Constructors

constructor

Properties

anonymousCompetitors

anonymousCompetitors: Map<NanoID, Player> = new Map()

All competitors that are anonymous, local (no user), competitors and not registered in database. Used only when there is a DB

competitors

competitors: Map<NanoID, Player> = new Map()

Registered competitors in this tournament

Protected design

design: Design

dimension

dimension: Dimension

A reference to the dimension this tournament was spawned from

id

id: NanoID

This tournament's ID

initialAddPlayerPromises

initialAddPlayerPromises: Array<Promise<any>> = []

Promise array of which all resolves once every player added through constructor is finished adding

log

log: Logger = new Logger()

Logger

matchHashes

matchHashes: Array<string> = []

matchQueue

matchQueue: Array<Tournament.QueuedMatch> = []

A queue whose elements are each arrays of players that are to compete against each other

matches

matches: Map<NanoID, Match> = new Map()

Mapping match ids to active ongoing matches

name

name: string = ""

This Tournament's name

Private resolveStopPromise

resolveStopPromise: Function

Private resumePromise

resumePromise: Promise<void>

Private resumeResolver

resumeResolver: Function

Private shouldStop

shouldStop: boolean = false

status

status: Tournament.Status = Tournament.Status.UNINITIALIZED

The current status of the tournament

type

type: TournamentType = Tournament.Type.ELIMINATION

Static Elimination

Elimination: Elimination

Static Ladder

Ladder: Ladder

Static RankSystem

RankSystem: RankSystem

Static Scheduler

Scheduler: Scheduler

Static Status

Static Type

Static defaultMaxListeners

defaultMaxListeners: number

Methods

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

addplayer

  • addplayer(file: string | { botdir?: string; botkey?: string; existingID?: NanoID; file: string; name: string; zipFile?: string }, existingID?: NanoID, calledFromInitialization?: boolean): Promise<Player>
  • Add or update a player to the tournament

    If no existing ID is specified, this is treated as adding a completely new player.

    If existing ID is specified and that ID exists already, this will update the file for that player instead and effectively update the player. First time a player is added, if there is existing stats in a DB they won't be reset. Subsequent adds will change the stats.

    If the player is to exist beyond the tournament, an existingID must always be provided and generated somewhere else

    Resolves with the new player or updated player

    Parameters

    • file: string | { botdir?: string; botkey?: string; existingID?: NanoID; file: string; name: string; zipFile?: string }

      The file to the bot or an object with the file and a name for the player specified

    • Optional existingID: NanoID

      The optional id of the player. Can also be provided in the first arg in a object

    • Default value calledFromInitialization: boolean = false

      Whether or not the player was called from initialization. If true, player version does not increment

    Returns Promise<Player>

destroy

  • destroy(): Promise<void>

disablePlayer

  • disablePlayer(playerID: nanoid): Promise<void>

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

Private generateFirstRounds

  • generateFirstRounds(): void

generateNextTournamentIDString

  • generateNextTournamentIDString(): string

Private generateRound

  • generateRound(): void

getConfigs

getKeyName

  • getKeyName(): string

getLastVersionUsedOfPlayer

  • getLastVersionUsedOfPlayer(playerID: nanoid): Promise<number>

getMatchInfoFromQueuedMatch

  • getMatchInfoFromQueuedMatch(queuedMatchInfo: Tournament.QueuedMatch): Promise<Array<Player>>

getMaxListeners

  • getMaxListeners(): number

getPlayerStat

getRankings

  • getRankings(): Array<{ losses: number; matchesPlayed: number; player: Player; rank: number; seed: number; wins: number }>

getSafeName

  • getSafeName(): string

Private handleMatch

  • handleMatch(queuedMatchInfo: Tournament.QueuedMatch, matchHash: string): Promise<void>

Private initialize

  • initialize(): void

internalAddPlayer

  • internalAddPlayer(): Promise<void>

Protected internalRemovePlayer

  • internalRemovePlayer(playerID: nanoid): Promise<void>

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

Protected postInternalDestroy

  • postInternalDestroy(): Promise<void>

Protected preInternalDestroy

  • preInternalDestroy(): Promise<void>

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

removeMatch

  • removeMatch(matchID: NanoID): Promise<boolean>

removePlayer

  • removePlayer(playerID: nanoid): Promise<void>

resume

  • resume(): Promise<void>

run

Protected runMatch

  • runMatch(players: Array<Player>): Promise<{ err?: any; match: Match; results: any }>

setConfigs

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

Private shuffle

  • shuffle(arr: any[]): any[]

stop

  • stop(): Promise<void>

updateLastVersionUsedOfPlayer

  • updateLastVersionUsedOfPlayer(playerID: nanoid, version: number): Promise<void>

updatePlayer

  • updatePlayer(): Promise<void>

Static genTournamentClassID

  • genTournamentClassID(): string

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Object literals

configs

configs: object

agentsPerMatch

agentsPerMatch: number[] = [2]

consoleDisplay

consoleDisplay: true = true

defaultMatchConfigs

defaultMatchConfigs: {}

Type declaration

id

id: string = "z3Ap49"

rankSystem

rankSystem: null = null

rankSystemConfigs

rankSystemConfigs: null = null

resultHandler

resultHandler: null = null

type

type: ELIMINATION = Tournament.Type.ELIMINATION

tournamentConfigs

tournamentConfigs: object

lives

lives: 1 = 1

seeding

seeding: null = null

storePastResults

storePastResults: true = true

times

times: number = 1

state

state: object

currentRound

currentRound: null = null

playerStats

playerStats: Map<any, any> = new Map()

results

results: undefined[] = []

resultsMap

resultsMap: Map<any, any> = new Map()

statistics

statistics: object

totalMatches

totalMatches: number = 0

Generated using TypeDoc