Class: Tournament

Tournament

Class representing a tournament.


new Tournament(id, options)

Create a new tournament.

Parameters:
Name Type Description
id String

String to be the event ID.

options Object

Options that can be defined for a tournament.

Members


active :Boolean

If the tournament is active.

Type:
  • Boolean
Default Value:
  • false

drawValue :Number

The value of a draw/tie.
Must be 0 or greater.

Type:
  • Number
Default Value:
  • 0.5

eventID :String

Alphanumeric string ID.

Type:
  • String

format :'elim'|'robin'|'swiss'

Format for the first stage of the tournament.

Type:
  • 'elim' | 'robin' | 'swiss'
Default Value:
  • 'elim'

lossValue :Number

The value of a loss.
Must be an integer.

Type:
  • Number
Default Value:
  • 0

<nullable> maxPlayers :Number

Maximum number of players allowed to register for the tournament (minimum 4).
If null, there is no maximum.

Type:
  • Number
Default Value:
  • null

<nullable> name :String

Name of the tournament.

Type:
  • String
Default Value:
  • null

players :Array.<Player>

Array of all players in the tournament.

Type:
Default Value:
  • []

rounds :Array.<Pairings>

Array of all pairings in the tournament.

Type:
Default Value:
  • []

seededPlayers :Boolean

Whether or not to organize players by seed when pairing.

Type:
  • Boolean
Default Value:
  • false

seedOrder :'asc'|'des'

If the seeding should be sorted in ascending or descending order.

Type:
  • 'asc' | 'des'
Default Value:
  • 'asc'

startTime :Date

Creation date and time of the tournament.

Type:
  • Date

winValue :Number

The value of a win.
Must be a positive integer.

Type:
  • Number
Default Value:
  • 1

Methods


activeMatches(round)

Get the active matches in the tournament.
If no round is specified, it returns all active matches for all rounds.

Parameters:
Name Type Argument Default Description
round Number <nullable>
null

Optional round selector.

Returns:
Type
Array.<Match>

addPlayer(alias, id, seed)

Create a new player and add them to the tournament.

Parameters:
Name Type Default Description
alias String

The name of the new player.

id String null

The ID of the new player. If null, one will be randomly generated.

seed Number null

The seed value of the player. Mandatory if seededPlayers is true.

Returns:

If the player was created and added.

Type
Boolean

removePlayer(player)

Remove a player from the tournament.
If the tournament hasn't started, they are removed entirely.
If the tournament has started, they are dropped and marked inactive.

Parameters:
Name Type Description
player Player

The player to be removed.

Returns:

If the player was removed or dropped.

Type
Boolean

standings( [active])

Get the current standings of the tournament.

Parameters:
Name Type Argument Default Description
active Boolean <optional>
true

Filtering only active players.

Returns:
Type
Array.<Player>