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, sessionId, socket)

Source:
Parameters:
Name Type Description
worldData Object

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

sessionId string

The ID of the currently active client session retrieved from the browser 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 viewed 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:

loading :boolean

Source:

A flag for whether texture assets for the game canvas are currently loading

Type:
  • boolean

modules :Map

Source:

A mapping of installed modules

Type:
  • Map

paused :Boolean

Source:

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

Type:
  • Boolean

permissions :Object

Source:

The user role permissions setting

Type:
  • Object

ready :boolean

Source:

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

Type:
  • boolean

sessionId :string

Source:

The client session id which is currently active

Type:
  • string

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|null

Source:

The currently connected User entity, or null if Users is not yet initialized

Type:

userId :string

Source:

The id of the active World user, if any

Type:
  • string

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) connect(sessionId) → {Promise}

Source:

Establish a live connection to the game server through the socket.io URL

Parameters:
Name Type Description
sessionId string

The client session ID with which to establish the connection

Returns:

A promise which resolves to the connected socket, if successful

Type
Promise

(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

(static) getCookies() → {Object}

Source:

Retrieve the cookies which are attached to the client session

Returns:

The session cookies

Type
Object

(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 EntityCollection instances for every Entity types

initializeKeyboard()

Source:

Initialize Keyboard and Mouse controls

(async) initializePacks()

Source:
See:

Initialize the Compendium packs which are present within this Game Create a Collection which maps each Compendium pack using it's collection ID

initializeRTC()

Source:

Initialize the WebRTC implementation

initializeUI()

Source:

Initialize core UI elements

logOut()

Source:

Log out of the game session by returning to the Join screen

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?