# addEventListener(type, callback)
Add a new event callback method for an existing or new event type.
Parameters
Name | Types | Description |
---|---|---|
type |
|
- An event type. |
callback |
|
- An asynchronous callback method used to make edits directly to a data source. |
# createGame()
private method
Creates a game. > NOTE: Calling this function will also run any events with the type createGame.
# createPlayer(gameId, name, avatar)
private method
Creates a player in a game. Player will be assigned as admin if they are the first in the game. > NOTE: Calling this function will also run any events with the type createPlayer.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to create a player for. |
name |
|
- Optional name for player. |
avatar |
|
- Optional avatar ID or URL for player. |
# createSpectator(gameId)
private method
Creates a spectator in a game. > NOTE: Calling this function will also run any events with the type createSpectator.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to create a spectator for. |
# createTurn(gameId)
private method
Creates a new turn in a game. > NOTE: Calling this function will also run any events with the type createTurn.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game in which to create a turn. |
# currentTurn(gameId)
Find the current turn in a game using a UUID.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to look up. |
# editCurrentTurn(gameId, callback)
Edit current turn data.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to look up. |
callback |
|
- An asynchronous callback method used to make edits directly to the current turn and other data sources. |
# editGame(gameId, callback)
Edit game data.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to edit. |
callback |
|
- An asynchronous callback method used to make edits directly to the game and other data sources. |
# editPlayer(gameId, playerId, callback)
Edit player data.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to look up. |
playerId |
|
- A UUID representing the player to edit. |
callback |
|
- An asynchronous callback method used to make edits directly to the player and other data sources. |
# editSpectator(gameId, spectatorId, callback)
Edit player data.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to look up. |
spectatorId |
|
- A UUID representing the spectator to edit. |
callback |
|
- An asynchronous callback method used to make edits directly to the spectator and other data sources. |
# editTurn(gameId, turnId, callback)
Edit turn data.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to look up. |
turnId |
|
- A UUID representing the turn to edit. |
callback |
|
- An asynchronous callback method used to make edits directly to the turn and other data sources. |
# endCurrentTurn(gameId)
Ends current turn and creates a new turn in a game. > NOTE: Calling this function will also run any events with the type endCurrentTurn.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game in which to end the current turn. |
# endGame(gameId)
private method
End game.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to end. |
# findGame(gameId)
Find a game using a UUID.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to look up. |
# findGameWithCode(gameCode)
Find a game using a game code.
Parameters
Name | Types | Description |
---|---|---|
gameCode |
|
- A unique four letter game code representing the game to look up. |
# findPlayer(gameId, playerId)
Find player in a game using a UUID.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to look up. |
playerId |
|
- A UUID representing the player to look up. |
# findSpectator(gameId, spectatorId)
Find spectator in a game using a UUID.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to look up. |
spectatorId |
|
- A UUID representing the spectator to look up. |
# findTurn(gameId, turnId)
Find turn in a game using a UUID.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to look up. |
turnId |
|
- A UUID representing the turn to look up. |
# isAdmin()
A flag indicating if the player is the admin. This is true if they are the first player to join the game.
# leaveGame(gameId, playerId)
private method
Leave game. > NOTE: Calling this function will also run any events with the type leaveGame.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to leave. |
playerId |
|
- A UUID representing the player or spectator to leave. |
# removeEventListener(type, callback)
Remove an existing event callback method.
Parameters
Name | Types | Description |
---|---|---|
type |
|
- An event type. |
callback |
|
- Reference to an asynchronous callback method used to make edits directly to a data source. |
# startGame(gameId)
private method
Start game. > NOTE: Calling this function will also run any events with the type startGame.
Parameters
Name | Types | Description |
---|---|---|
gameId |
|
- A UUID representing the game to start. |
# tore(type, data, datastore)
private method
Run all existing event callback methods for a specific event type.
Parameters
Name | Types | Description |
---|---|---|
type |
|
- An event type. |
data |
|
- Data specific to the event type. |
datastore |
|
- Reference to the current datastore. |