Game

Game

The core Game instance which encapsulates the data, settings, and states relevant for managing the game experience. The singleton instance of the Game class is available as the global variable game.

Constructor

new Game(worldData, userId, socket)

Source:
Parameters:
Name Type Description
worldData Object

An object of all the World data vended by the server when the client first connects

userId String

The ID of the currently active user, retrieved from their session cookie

socket Socket

The open web-socket which should be used to transact game-state data

Members

activeTool :String

Source:

A convenient reference to the currently active canvas tool

Type:

audio :AudioHelper

Source:

A singleton instance of the Audio Helper class

Type:

combat :Combat

Source:

A convenience accessor for the currently active Combat encounter

Type:

data :Object

Source:

The object of world data passed from the server

Type:
  • Object

debug :Boolean

Source:

Whether the Game is running in debug mode

Type:
  • Boolean

i18n :Localization

Source:

Localization support

Type:

keyboard :KeyboardManager

Source:

The Keyboard Manager

Type:

modules :Array.<Object>

Source:

An Array of metadata for each Module which is active within this game World

Type:

paused :Boolean

Source:

A state variable which tracks whether or not the game session is currently paused

Type:
  • Boolean

ready :boolean

Source:

A flag for whether the Game has successfully reached the "ready" hook

Type:
  • boolean

settings :ClientSettings

Source:

Client settings which are used to configure application behavior

Type:

socket :WebSocket

Source:

A reference to the open Socket.io connection

Type:
  • WebSocket

system :Object

Source:

Metadata regarding the game System which powers this World

Type:
  • Object

user :User

Source:

The currently connected User

Type:

userId :String

Source:

The id of the active game user

Type:

video :VideoHelper

Source:

A singleton instance of the Video Helper class

Type:

world :Object

Source:

Metadata regarding the current game World

Type:
  • Object

Methods

(async, static) create() → {Promise}

Source:

Fetch World data and return a Game instance

Returns:

A Promise which resolves to the created Game instance

Type
Promise

(async, static) getSetupData() → {Promise}

Source:

Request setup data from server and return it

Returns:
Type
Promise

(async, static) getWorldData() → {Promise}

Source:

Request World data from server and return it

Returns:
Type
Promise

(static) socketListeners(socket)

Source:

General game-state socket listeners and event handlers

Parameters:
Name Type Description
socket

activateListeners()

Source:

Activate Event Listeners which apply to every Game View

(async) initialize()

Source:

Initialize the Game for the current window location

(async) initializeCanvas()

Source:

Initialize the game Canvas

initializeEntities()

Source:

Initialize game state data by creating Collections for all Entity types

initializeKeyboard()

Source:

Initialize Keyboard and Mouse controls

(async) initializePacks()

Source:

Initialization actions for compendium packs

initializeRTC()

Source:

Initialize the WebRTC implementation

initializeUI()

Source:

Initialize core UI elements

openSockets()

Source:

Open socket listeners which transact game state data

registerSettings()

Source:

Register core game settings

(async) setupGame()

Source:

Fully set up the game state, initializing Entities, UI applications, and the Canvas

(async) shutDown() → {Promise}

Source:

Shut down the currently active Game. Requires GameMaster user permission

Returns:
Type
Promise

togglePause(pause, pushopt)

Source:

Toggle the pause state of the game Trigger the pauseGame Hook when the paused state changes

Parameters:
Name Type Attributes Default Description
pause Boolean

The new pause state

push Boolean <optional>
false

Push the pause state change to other connected clients?