Class: Match

Match

new Match()

Match
Source:

Members

currentGame :Game

Current game
Type:
Source:

guest :Player

Player that joined the match
Type:
Source:

host :Player

Player that created the match
Type:
Source:

id :number

Unique ID of match object
Type:
  • number
Source:

isOver :boolean

Is match over
Type:
  • boolean
Source:

length :number

Match length - the score needed to win the match.
Type:
  • number
Source:

players :Array

List of all players participating in the match
Type:
  • Array
Source:

ruleName :string

Name of the rule used for current match. Equals the class name of the rule (eg. 'RuleBgCasual').
Type:
  • string
Source:

score :Array

Score of players for current match
Type:
  • Array
Source:

Methods

(static) addGuestPlayer(match, player)

Add guest player
Parameters:
Name Type Description
match Match Match to add player to
player Player Player to add
Source:
Throws:
Throws error if the match already has a guest player

(static) addHostPlayer(match, player)

Add host player to match
Parameters:
Name Type Description
match Match Match to add player to
player Player Player to add
Source:
Throws:
Throws error if the match already has a host player

(static) createNew(rule) → {Match}

Create new match object with unique ID and initialize it. Match object is not saved in database.
Parameters:
Name Type Description
rule Rule Rule object to use
Source:
Returns:
- A new match object with unique ID
Type
Match

(static) createNewGame(rule) → {Match}

Create new game for this match. Fill game object with data from match Game object is not saved in database.
Parameters:
Name Type Description
rule Rule Rule object to use
Source:
Returns:
- A new match object with unique ID
Type
Match

(static) hasGuestJoined(match) → {boolean}

Check if another player has joined the match
Parameters:
Name Type Description
match Match Match
Source:
Returns:
- True if a another player has joined the match
Type
boolean

(static) isHost(match, player) → {boolean}

Check if specified player is the host of the match
Parameters:
Name Type Description
match Match Match
player Player Specified player
Source:
Returns:
- True if there is a host player and their ID matches that of the player parameter
Type
boolean