Options
All
  • Public
  • Public/Protected
  • All
Menu

The Ladder Tournament class and namespace. The Ladder Tournament namespace

Hierarchy

  • Tournament
    • Ladder

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

Private configLastModificationDate

configLastModificationDate: Date = new Date(0)

Last modification date of configs

Private configSyncInterval

configSyncInterval: any = null

Configuration synchronization interval. Periodically makes a request to the DB if there is one and syncs configs

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

matchQueue

matchQueue: Array<Tournament.QueuedMatch> = []

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

Private matchQueueLocked

matchQueueLocked: boolean = false

matches

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

Mapping match ids to active ongoing matches

name

name: string = ""

This Tournament's name

Private ranksystem

ranksystem: RankSystem<any, any>

The ranksystem object being used to update, initialize, etc. ranks

resultProcessingQueue

resultProcessingQueue: Array<{ mapAgentIDtoTournamentID: Map<ID, ID>; result: Results }> = []

Private runInterval

runInterval: any = null

tournament runner interval, periodically calls tourneyRunner to start up new matches

status

status: Tournament.Status = Tournament.Status.UNINITIALIZED

The current status of the tournament

type

type: TournamentType = Tournament.Type.LADDER

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>

Private checkMatchIntegrity

  • checkMatchIntegrity(matchInfo: Array<Player>): Promise<boolean>

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>

generateNextTournamentIDString

  • generateNextTournamentIDString(): string

getConfigs

Private getConfigsStrippedOfFunctionFields

getKeyName

  • getKeyName(): string

getLastVersionUsedOfPlayer

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

getMatchInfoFromQueuedMatch

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

getMaxListeners

  • getMaxListeners(): number

getPlayerStat

getRankings

  • getRankings(offset?: number, limit?: number): Promise<Array<LadderPlayerStat>>

getSafeName

  • getSafeName(): string

Private handleMatch

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

Private handleMatchResults

  • handleMatchResults(): Promise<void>

initialize

  • initialize(): Promise<void>

Private initializePlayerStats

  • initializePlayerStats(player: Player): Promise<void>

internalAddPlayer

  • internalAddPlayer(player: Player): Promise<void>

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

Private printTournamentStatus

  • printTournamentStatus(): Promise<void>

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>

resetRankings

  • resetRankings(): Promise<void>

resume

  • resume(primary?: boolean): Promise<void>

run

Protected runMatch

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

Private schedule

  • schedule(): Promise<void>

scheduleMatches

  • scheduleMatches(...matchInfos: Array<Tournament.QueuedMatch>): void

setConfigs

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

setStatus

  • setStatus(status: Tournament.Status): Promise<void>

Private setupConfigSyncInterval

  • setupConfigSyncInterval(): void

stop

  • stop(primary?: boolean): Promise<void>

Private syncConfigs

  • syncConfigs(): Promise<void>

Private tourneyRunner

  • tourneyRunner(): Promise<void>

Private updateDatabasePlayerStats

updateLastVersionUsedOfPlayer

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

updatePlayer

  • updatePlayer(player: Player): Promise<void>

Private updatePlayerStat

  • updatePlayerStat(currentStats: PlayerStat): 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 = "z3plg"

rankSystem

rankSystem: null = null

rankSystemConfigs

rankSystemConfigs: null = null

resultHandler

resultHandler: null = null

type

type: LADDER = TournamentType.LADDER

tournamentConfigs

tournamentConfigs: object

configSyncRefreshRate

configSyncRefreshRate: number = 6000

endDate

endDate: null = null

matchMake

matchMake: null = null

maxConcurrentMatches

maxConcurrentMatches: number = 1

maxTotalMatches

maxTotalMatches: null = null

selfMatchMake

selfMatchMake: true = true

storePastResults

storePastResults: true = true

syncConfigs

syncConfigs: true = true

state

state: object

currentRanks

currentRanks: undefined[] = []

playerStats

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

results

results: undefined[] = []

statistics

statistics: object

totalMatches

totalMatches: number = 0

Generated using TypeDoc