Constructor
new Game(view, data, sessionId, socket)
Parameters:
Name | Type | Description |
---|---|---|
view |
string | The named view which is active for this game instance. |
data |
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
A convenient reference to the currently active canvas tool
Type:
- string
audio :AudioHelper
A singleton instance of the Audio Helper class
Type:
canvas :Canvas
A singleton reference to the Canvas object which may be used.
Type:
collections :Collection.<string, WorldCollection>
A mapping of WorldCollection instances, one per primary Document type.
Type:
- Collection.<string, WorldCollection>
combat :Combat
A convenience accessor for the currently viewed Combat encounter
Type:
data :Object
The object of world data passed from the server
Type:
- Object
debug :boolean
Whether the Game is running in debug mode
Type:
- boolean
i18n :Localization
Localization support
Type:
isAdmin :boolean
Is the current session user authenticated as an application administrator?
Type:
- boolean
keyboard :KeyboardManager
The Keyboard Manager
Type:
loading :boolean
A flag for whether texture assets for the game canvas are currently loading
Type:
- boolean
modules :Map
A mapping of installed modules
Type:
- Map
modules :Map.<string, Object>
A Map of active modules which are currently enabled in this World
Type:
- Map.<string, Object>
packs :Collection.<string, CompendiumCollection>
A mapping of CompendiumCollection instances, one per Compendium pack.
Type:
- Collection.<string, CompendiumCollection>
paused :boolean
A state variable which tracks whether or not the game session is currently paused
Type:
- boolean
permissions :Object
The user role permissions setting
Type:
- Object
ready :boolean
A flag for whether the Game has successfully reached the "ready" hook
Type:
- boolean
sessionId :string
The client session id which is currently active
Type:
- string
settings :ClientSettings
Client settings which are used to configure application behavior
Type:
socket :WebSocket|null
A reference to the open Socket.io connection
Type:
- WebSocket | null
time :GameTime
A singleton GameTime instance which manages the progression of time within the game world.
Type:
user :User|null
The currently connected User entity, or null if Users is not yet initialized
Type:
- User | null
userId :string
The id of the active World user, if any
Type:
- string
video :VideoHelper
A singleton instance of the Video Helper class
Type:
view :string
The named view which is currently active. Game views include: join, setup, players, license, game, stream
Type:
- string
Methods
(async, static) connect(sessionId) → {Promise.<object>}
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.<object>
(async, static) create(view, sessionId) → {Promise.<Game>}
Fetch World data and return a Game instance
Parameters:
Name | Type | Description |
---|---|---|
view |
string | The named view being created |
sessionId |
string | null | The current sessionId of the connecting client |
Returns:
A Promise which resolves to the created Game instance
- Type
- Promise.<Game>
(static) getCookies() → {Object}
Retrieve the cookies which are attached to the client session
Returns:
The session cookies
- Type
- Object
(async, static) getData() → {Promise.<object>}
Request World data from server and return it
Returns:
- Type
- Promise.<object>
(async, static) getWorldStatus() → {Promise.<boolean>}
Get the current World status upon initial connection.
Returns:
- Type
- Promise.<boolean>
activateListeners()
Activate Event Listeners which apply to every Game View
activateSocketListeners()
Activate Socket event listeners which are used to transact game state data with the server
getPackageScopes() → {Array.<string>}
Return the named scopes which can exist for packages. Scopes are returned in the prioritization order that their content is loaded.
Returns:
An array of string package scopes
- Type
- Array.<string>
(async) initialize()
Initialize the Game for the current window location
(async) initializeCanvas() → {Promise.<void>}
Initialize the game Canvas
Returns:
- Type
- Promise.<void>
initializeEntities()
Initialize game state data by creating WorldCollection instances for every primary Document type
initializeKeyboard()
Initialize Keyboard and Mouse controls
initializePacks() → {Collection.<string, CompendiumCollection>}
Initialize the Compendium packs which are present within this Game Create a Collection which maps each Compendium pack using it's collection ID
Returns:
- Type
- Collection.<string, CompendiumCollection>
initializeRTC()
Initialize the WebRTC implementation
initializeUI()
Initialize core UI elements
logOut()
Log out of the game session by returning to the Join screen
registerSettings()
Register core game settings
(async) setupGame() → {Promise.<void>}
Fully set up the game state, initializing Entities, UI applications, and the Canvas
Returns:
- Type
- Promise.<void>
setupPackages()
Configure package data that is currently enabled for this world
(async) shutDown() → {Promise.<void>}
Shut down the currently active Game. Requires GameMaster user permission.
Returns:
- Type
- Promise.<void>
togglePause(pause, pushopt)
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 desired pause state. When true, the game will be paused, when false the game will be un-paused. |
||
push |
boolean |
<optional> |
false
|
Push the pause state change to other connected clients? Requires an GM user. |