Options
All
  • Public
  • Public/Protected
  • All
Menu

The client-side Combat document which extends the common BaseCombat model.

mixes

ClientDocumentMixin

see

{@link documents.Combats} The world-level collection of Combat documents

see

Combatant The Combatant embedded document which exists within a Combat document

see

{@link CombatConfig} The Combat configuration application

Hierarchy

  • any
    • Combat

Index

Constructors

  • new Combat(data: any, context: any): Combat
  • Parameters

    • data: any
    • context: any

    Returns Combat

Properties

turns: Combatant[]

Track the sorted turn order of this combat encounter

Record the current round, turn, and tokenId to understand changes in the encounter state

Track the previous round, turn, and tokenId to understand changes in the encounter state

turn: any
debounceSetup: Function = ...

Debounce changes to the composition of the Combat encounter to de-duplicate multiple concurrent Combatant changes. If this is the currently viewed encounter, re-render the CombatTracker application.

CONFIG_SETTING: string = "combatTrackerConfig"

The configuration setting used to record Combat preferences

Accessors

  • Get the Combatant who has the current turn.

    Returns Combatant

  • Get the Combatant who has the next turn.

    Returns Combatant

  • get settings(): any
  • Return the object of settings which modify the Combat Tracker behavior

    Returns any

  • get started(): boolean
  • Has this combat encounter been started?

    Returns boolean

  • get visible(): boolean
  • inheritdoc

    Returns boolean

  • get isActive(): boolean
  • Is this combat active in the current scene?

    Returns boolean

Methods

  • activate(options: any): Promise<Combat>
  • Set the current Combat encounter as active within the Scene. Deactivate all other Combat encounters within the viewed Scene and set this one as active

    Parameters

    • options: any

    Returns Promise<Combat>

  • prepareDerivedData(): void
  • override

    Returns void

  • getCombatantByToken(tokenId: string): Combatant
  • Get a Combatant using its Token id

    Parameters

    • tokenId: string

      The id of the Token for which to acquire the combatant

    Returns Combatant

  • Get a Combatant that represents the given Actor or Actor ID.

    Parameters

    • actorOrId: string | Actor

      An Actor ID or an Actor instance.

    Returns Combatant

  • startCombat(): Promise<Combat>
  • Begin the combat encounter, advancing to round 1 and turn 1

    Returns Promise<Combat>

  • Advance the combat to the next round

    Returns Promise<Combat>

  • previousRound(): Promise<Combat>
  • Rewind the combat to the previous round

    Returns Promise<Combat>

  • Advance the combat to the next turn

    Returns Promise<Combat>

  • previousTurn(): Promise<Combat>
  • Rewind the combat to the previous turn

    Returns Promise<Combat>

  • Display a dialog querying the GM whether they wish to end the combat encounter and empty the tracker

    Returns Promise<Combat>

  • toggleSceneLink(): Promise<Combat>
  • Toggle whether this combat is linked to the scene or globally available.

    Returns Promise<Combat>

  • Reset all combatant initiative scores, setting the turn back to zero

    Returns Promise<Combat>

  • rollInitiative(ids: string | string[], [options={}]?: { formula: string; updateTurn: boolean; messageOptions: any }): Promise<Combat>
  • Roll initiative for one or multiple Combatants within the Combat document

    Parameters

    • ids: string | string[]

      A Combatant id or Array of ids for which to roll

    • [options={}]: { formula: string; updateTurn: boolean; messageOptions: any } = {}

      Additional options which modify how initiative rolls are created or presented.

      • formula: string
      • updateTurn: boolean
      • messageOptions: any

    Returns Promise<Combat>

    A promise which resolves to the updated Combat document once updates are complete.

  • rollAll(options: any): Promise<Combat>
  • Roll initiative for all combatants which have not already rolled

    Parameters

    • options: any

    Returns Promise<Combat>

  • rollNPC(options?: any): Promise<Combat>
  • Roll initiative for all non-player actors who have not already rolled

    Parameters

    • options: any = {}

    Returns Promise<Combat>

  • setInitiative(id: string, value: number): Promise<void>
  • Assign initiative for a single Combatant within the Combat encounter. Update the Combat turn order to maintain the same combatant as the current turn.

    Parameters

    • id: string

      The combatant ID for which to set initiative

    • value: number

      A specific initiative value to set

    Returns Promise<void>

  • Return the Array of combatants sorted into initiative order, breaking ties alphabetically by name.

    Returns Combatant[]

  • updateCombatantActors(): void
  • Update active effect durations for all actors present in this Combat encounter.

    Returns void

  • _onCreate(data: any, options: any, userId: any): void
  • inheritdoc

    Parameters

    • data: any
    • options: any
    • userId: any

    Returns void

  • _onUpdate(data: any, options: any, userId: any): void
  • inheritdoc

    Parameters

    • data: any
    • options: any
    • userId: any

    Returns void

  • _onDelete(options: any, userId: any): void
  • inheritdoc

    Parameters

    • options: any
    • userId: any

    Returns void

  • _onCreateDescendantDocuments(parent: any, collection: any, documents: any, data: any, options: any, userId: any): void
  • inheritdoc

    Parameters

    • parent: any
    • collection: any
    • documents: any
    • data: any
    • options: any
    • userId: any

    Returns void

  • _onUpdateDescendantDocuments(parent: any, collection: any, documents: any, changes: any, options: any, userId: any): void
  • inheritdoc

    Parameters

    • parent: any
    • collection: any
    • documents: any
    • changes: any
    • options: any
    • userId: any

    Returns void

  • _onDeleteDescendantDocuments(parent: any, collection: any, documents: any, ids: any, options: any, userId: any): void
  • inheritdoc

    Parameters

    • parent: any
    • collection: any
    • documents: any
    • ids: any
    • options: any
    • userId: any

    Returns void

  • _playCombatSound(announcement: string): void
  • Loads the registered Combat Theme (if any) and plays the requested type of sound. If multiple exist for that type, one is chosen at random.

    Parameters

    • announcement: string

      The announcement that should be played: "startEncounter", "nextUp", or "yourTurn".

    Returns void

  • Define how the array of Combatants is sorted in the displayed list of the tracker. This method can be overridden by a system or module which needs to display combatants in an alternative order. The default sorting rules sort in descending order of initiative using combatant IDs for tiebreakers.

    Parameters

    Returns number

  • _refreshTokenHUD(documents: Combatant[]): void
  • Refresh the Token HUD under certain circumstances.

    Parameters

    • documents: Combatant[]

      A list of Combatant documents that were added or removed.

    Returns void

  • _manageTurnEvents(adjustedTurn: number): Promise<void>
  • Manage the execution of Combat lifecycle events. This method orchestrates the execution of four events in the following order, as applicable:

    1. End Turn
    2. End Round
    3. Begin Round
    4. Begin Turn Each lifecycle event is an async method, and each is awaited before proceeding.

    Parameters

    • adjustedTurn: number

    Returns Promise<void>

  • _onEndTurn(combatant: Combatant): Promise<void>
  • A workflow that occurs at the end of each Combat Turn. This workflow occurs after the Combat document update, prior round information exists in this.previous. This can be overridden to implement system-specific combat tracking behaviors. This method only executes for one designated GM user. If no GM users are present this method will not be called.

    Parameters

    • combatant: Combatant

      The Combatant whose turn just ended

    Returns Promise<void>

  • _onEndRound(): Promise<void>
  • A workflow that occurs at the end of each Combat Round. This workflow occurs after the Combat document update, prior round information exists in this.previous. This can be overridden to implement system-specific combat tracking behaviors. This method only executes for one designated GM user. If no GM users are present this method will not be called.

    Returns Promise<void>

  • _onStartRound(): Promise<void>
  • A workflow that occurs at the start of each Combat Round. This workflow occurs after the Combat document update, new round information exists in this.current. This can be overridden to implement system-specific combat tracking behaviors. This method only executes for one designated GM user. If no GM users are present this method will not be called.

    Returns Promise<void>

  • _onStartTurn(combatant: Combatant): Promise<void>
  • A workflow that occurs at the start of each Combat Turn. This workflow occurs after the Combat document update, new turn information exists in this.current. This can be overridden to implement system-specific combat tracking behaviors. This method only executes for one designated GM user. If no GM users are present this method will not be called.

    Parameters

    • combatant: Combatant

      The Combatant whose turn just started

    Returns Promise<void>

  • Update the previous turn data. Compare the state with the new current state. Only update the previous state if there is a difference.

    Parameters

    • priorState: CombatHistoryData

      A cloned copy of the current history state before changes

    Returns void