Members
currentGame :Game
Current game
Type:
guest :Player
Player that joined the match
Type:
host :Player
Player that created the match
Type:
id :number
Unique ID of match object
Type:
- number
isOver :boolean
Is match over
Type:
- boolean
length :number
Match length - the score needed to win the match.
Type:
- number
players :Array
List of all players participating in the match
Type:
- Array
ruleName :string
Name of the rule used for current match.
Equals the class name of the rule (eg. 'RuleBgCasual').
Type:
- string
score :Array
Score of players for current match
Type:
- Array
Methods
(static) addGuestPlayer(match, player)
Add guest player
Parameters:
Name | Type | Description |
---|---|---|
match |
Match | Match to add player to |
player |
Player | Player to add |
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 |
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 |
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 |
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 |
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 |
Returns:
- True if there is a host player and their ID matches that of the player parameter
- Type
- boolean