Constructor
new Game(view, data, sessionId, socket)
- Source:
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
- Source:
A convenient reference to the currently active canvas tool
Type:
- string
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:
isAdmin :boolean
- Source:
Is the current session user authenticated as an application administrator?
Type:
- boolean
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|null
- Source:
A reference to the open Socket.io connection
Type:
- WebSocket | null
system :Object
- Source:
Metadata regarding the game System which powers this World
Type:
- Object
time :GameTime
- Source:
A singleton GameTime instance which manages the progression of time within the game world.
Type:
user :User|null
- Source:
The currently connected User entity, or null if Users is not yet initialized
Type:
- User | null
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:
view :string
- Source:
The named view which is currently active. Game views include: join, setup, players, license, game, stream
Type:
- string
world :Object
- Source:
Metadata regarding the current game World
Type:
- Object
Methods
(async, static) connect(sessionId) → {Promise.<object>}
- 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.<object>
(async, static) create() → {Promise.<Game>}
- Source:
Fetch World data and return a Game instance
Returns:
A Promise which resolves to the created Game instance
- Type
- Promise.<Game>
(static) getCookies() → {Object}
- Source:
Retrieve the cookies which are attached to the client session
Returns:
The session cookies
- Type
- Object
(async, static) getSetupData() → {Promise.<object>}
- Source:
Request setup data from server and return it
Returns:
- Type
- Promise.<object>
(async, static) getWorldData() → {Promise.<object>}
- Source:
Request World data from server and return it
Returns:
- Type
- Promise.<object>
(async, static) getWorldStatus() → {Promise.<boolean>}
- Source:
Get the current World status upon initial connection.
Returns:
- Type
- Promise.<boolean>
(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() → {Collection.<string, Compendium>}
- Source:
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, Compendium>
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() → {Promise.<void>}
- Source:
Fully set up the game state, initializing Entities, UI applications, and the Canvas
Returns:
- Type
- Promise.<void>
(async) shutDown() → {Promise.<Object>}
- Source:
Shut down the currently active Game. Requires GameMaster user permission.
Returns:
A Promise which resolves to the response object from the server
- Type
- Promise.<Object>
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? |