Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Hierarchy

  • Game

Index

Constructors

  • new Game(view: string, data: any, sessionId: string, socket: Socket): Game
  • Parameters

    • view: string

      The named view which is active for this game instance.

    • data: any

      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

    Returns Game

Properties

permissions: any

The user role permissions setting

debug: boolean

Whether the Game is running in debug mode

loading: boolean

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

ready: boolean

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

world: World

The game World which is currently active.

system: System

The System which is used to power this game World.

modules: Map<string, Module>

A Map of active Modules which are currently eligible to be enabled in this World. The subset of Modules which are designated as active are currently enabled.

documentTypes: any
template: any
model: any
_documentsReady: boolean
webrtc: AVMaster

Accessors

  • get version(): string
  • Returns the current version of the Release, usable for comparisons using isNewerVersion

    Returns string

  • get isAdmin(): boolean
  • Is the current session user authenticated as an application administrator?

    Returns boolean

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

    Returns User

  • A convenience accessor for the currently viewed Combat encounter

    Returns Combat

  • get paused(): boolean
  • A state variable which tracks whether the game session is currently paused

    Returns boolean

  • get activeTool(): string
  • A convenient reference to the currently active canvas tool

    Returns string

Methods

  • setupPackages(data: any): void
  • Configure package data that is currently enabled for this world

    Parameters

    • data: any

      Game data provided by the server socket

    Returns void

  • getPackageScopes(): string[]
  • Return the named scopes which can exist for packages. Scopes are returned in the prioritization order that their content is loaded.

    Returns string[]

    An array of string package scopes

  • initialize(): Promise<void>
  • Initialize the Game for the current window location

    Returns Promise<void>

  • shutDown(): Promise<void>
  • Shut down the currently active Game. Requires GameMaster user permission.

    Returns Promise<void>

  • setupGame(): Promise<void>
  • Fully set up the game state, initializing Documents, UI applications, and the Canvas

    Returns Promise<void>

  • initializeDocuments(): void
  • Initialize game state data by creating WorldCollection instances for every primary Document type

    Returns void

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

    Returns Collection<string, CompendiumCollection>

  • initializeRTC(): Promise<boolean>
  • Initialize the WebRTC implementation

    Returns Promise<boolean>

  • initializeUI(): void
  • Initialize core UI elements

    Returns void

  • initializeCanvas(): Promise<void>
  • Initialize the game Canvas

    Returns Promise<void>

  • initializeKeyboard(): void
  • Initialize Keyboard controls

    Returns void

  • initializeMouse(): void
  • Initialize Mouse controls

    Returns void

  • initializeGamepads(): void
  • Initialize Gamepad controls

    Returns void

  • registerSettings(): void
  • Register core game settings

    Returns void

  • registerTours(): Promise<void>
  • Register core Tours

    Returns Promise<void>

  • togglePause(pause: boolean, push?: boolean): boolean
  • Toggle the pause state of the game Trigger the pauseGame Hook when the paused state changes

    Parameters

    • pause: boolean

      The desired pause state; true for paused, false for un-paused

    • push: boolean = false

    Returns boolean

    The new paused state

  • Open Character sheet for current token or controlled actor

    Returns ActorSheet

    The ActorSheet which was toggled, or null if the User has no character

  • logOut(): void
  • Log out of the game session by returning to the Join screen

    Returns void

  • scaleFonts(index: number): void
  • Scale the base font size according to the user's settings.

    Parameters

    • index: number

    Returns void

  • activateSocketListeners(): void
  • Activate Socket event listeners which are used to transact game state data with the server

    Returns void

  • activateListeners(): void
  • Activate Event Listeners which apply to every Game View

    Returns void

  • _onWindowPopState(event: any): void
  • Parameters

    • event: any

    Returns void

  • Handle a hot reload request from the server

    Parameters

    Returns void

  • Handle hot reloading of CSS files

    Parameters

    Returns void

  • Handle hot reloading of HTML files, such as Handlebars templates

    Parameters

    Returns void

  • Handle hot reloading of JSON files, such as language files

    Parameters

    Returns void

  • _onClickHyperlink(event: MouseEvent): void
  • On left mouse clicks, check if the element is contained in a valid hyperlink and open it in a new tab.

    Parameters

    • event: MouseEvent

    Returns void

  • _onPreventDragstart(event: DragEvent): boolean
  • Prevent starting a drag and drop workflow on elements within the document unless the element has the draggable attribute explicitly defined or overrides the dragstart handler.

    Parameters

    • event: DragEvent

      The initiating drag start event

    Returns boolean

  • _onPreventDragover(event: DragEvent): void
  • Disallow dragging of external content onto anything but a file input element

    Parameters

    • event: DragEvent

      The requested drag event

    Returns void

  • _onPreventDrop(event: DragEvent): void
  • Disallow dropping of external content onto anything but a file input element

    Parameters

    • event: DragEvent

      The requested drag event

    Returns void

  • _onPointerDown(event: PointerEvent): void
  • On a left-click event, remove any currently displayed inline roll tooltip

    Parameters

    • event: PointerEvent

      The mousedown pointer event

    Returns void

  • _onPointerUp(event: PointerEvent): void
  • Fallback handling for mouse-up events which aren't handled further upstream.

    Parameters

    • event: PointerEvent

      The mouseup pointer event

    Returns void

  • _onWindowResize(event: Event): any
  • Handle resizing of the game window by adjusting the canvas and repositioning active interface applications.

    Parameters

    • event: Event

      The window resize event which has occurred

    Returns any

  • _onWindowBeforeUnload(event: Event): any
  • Handle window unload operations to clean up any data which may be pending a final save

    Parameters

    • event: Event

      The window unload event which is about to occur

    Returns any

  • _onWindowBlur(event: Event): void
  • Handle cases where the browser window loses focus to reset detection of currently pressed keys

    Parameters

    • event: Event

      The originating window.blur event

    Returns void

  • _initializeView(): Promise<void>
  • Initialize elements required for the current view

    Returns Promise<void>

  • _initializeGameView(): Promise<void>
  • Initialization steps for the primary Game view

    Returns Promise<void>

  • _initializeStreamView(): Promise<void>
  • Initialization steps for the Stream helper view

    Returns Promise<void>

  • create(view: string, sessionId: string): Promise<Game>
  • Fetch World data and return a Game instance

    Parameters

    • view: string

      The named view being created

    • sessionId: string

      The current sessionId of the connecting client

    Returns Promise<Game>

    A Promise which resolves to the created Game instance

  • connect(sessionId: string): Promise<any>
  • Establish a live connection to the game server through the socket.io URL

    Parameters

    • sessionId: string

      The client session ID with which to establish the connection

    Returns Promise<any>

    A promise which resolves to the connected socket, if successful

  • getCookies(): any
  • Retrieve the cookies which are attached to the client session

    Returns any

    The session cookies

  • getData(socket: Socket, view: string): Promise<any>
  • Request World data from server and return it

    Parameters

    • socket: Socket

      The active socket connection

    • view: string

      The view for which data is being requested

    Returns Promise<any>

  • getWorldStatus(socket: Socket): Promise<boolean>
  • Get the current World status upon initial connection.

    Parameters

    • socket: Socket

      The active client socket connection

    Returns Promise<boolean>

  • _handleMouseWheelInputChange(event: WheelEvent): void
  • Support mousewheel control for range type input elements

    Parameters

    • event: WheelEvent

      A Mouse Wheel scroll event

    Returns void