Options
All
  • Public
  • Public/Protected
  • All
Menu

The client-side Token document which extends the common BaseToken document model.

mixes

ClientDocumentMixin

see

Scene The Scene document type which contains Token documents

see

TokenConfig The Token configuration application

Hierarchy

  • any
    • TokenDocument

Index

Constructors

  • Returns TokenDocument

Properties

actors: Collection<Actor> = ...

A singleton collection which holds a reference to the synthetic token actor by its base actor's ID.

alpha: any
delta: any
#sort: number = 0

Accessors

  • A reference to the Actor this Token modifies. If actorLink is true, then the document is the primary Actor document. Otherwise, the Actor document is a synthetic (ephemeral) document constructed using the Token's ActorDelta.

    Returns Actor

  • A reference to the base, World-level Actor this token represents.

    Returns Actor

  • get isOwner(): boolean
  • An indicator for whether the current User has full control over this Token document.

    Returns boolean

  • get isLinked(): boolean
  • A convenient reference for whether this TokenDocument is linked to the Actor it represents, or is a synthetic copy

    Returns boolean

  • Return a reference to a Combatant that represents this Token, if one is present in the current encounter.

    Returns Combatant

  • get inCombat(): boolean
  • An indicator for whether this Token is currently involved in the active combat encounter.

    Returns boolean

  • get sort(): number
  • set sort(value: number): void
  • Define a sort order for this TokenDocument. This controls its rendering order in the PrimaryCanvasGroup relative to siblings at the same elevation. In the future this will be replaced with a persisted database field for permanent adjustment of token stacking. In case of ties, Tokens will be sorted above other types of objects.

    Returns number

  • Define a sort order for this TokenDocument. This controls its rendering order in the PrimaryCanvasGroup relative to siblings at the same elevation. In the future this will be replaced with a persisted database field for permanent adjustment of token stacking. In case of ties, Tokens will be sorted above other types of objects.

    Parameters

    • value: number

    Returns void

Methods

  • _initialize(options?: {}): void
  • inheritdoc

    Parameters

    • options: {} = {}

      Returns void

    • prepareBaseData(): void
    • inheritdoc

      Returns void

    • prepareEmbeddedDocuments(): void
    • inheritdoc

      Returns void

    • getBarAttribute(barName: string, [options]?: { alternative: string }): any
    • A helper method to retrieve the underlying data behind one of the Token's attribute bars

      Parameters

      • barName: string

        The named bar to retrieve the attribute for

      • [options]: { alternative: string } = {}
        • alternative: string

      Returns any

      The attribute displayed on the Token bar, if any

    • toggleActiveEffect(effectData: { id: string; label: string; icon: string }, [options]?: { overlay: boolean; active: boolean }): Promise<boolean>
    • A helper function to toggle a status effect which includes an Active Effect template

      Parameters

      • effectData: { id: string; label: string; icon: string }

        The Active Effect data

        • id: string
        • label: string
        • icon: string
      • [options]: { overlay: boolean; active: boolean } = {}

        Options to configure application of the Active Effect

        • overlay: boolean
        • active: boolean

      Returns Promise<boolean>

      Whether the Active Effect is now on or off

    • hasStatusEffect(statusId: string): boolean
    • Test whether a Token has a specific status effect.

      Parameters

      • statusId: string

        The status effect ID as defined in CONFIG.statusEffects

      Returns boolean

      Does the Token have this status effect?

    • updateVisionMode(visionMode: string, defaults?: boolean): Promise<any>
    • Convenience method to change a token vision mode.

      Parameters

      • visionMode: string

        The vision mode to apply to this token.

      • defaults: boolean = true

      Returns Promise<any>

    • getEmbeddedCollection(embeddedName: any): any
    • inheritdoc

      Parameters

      • embeddedName: any

      Returns any

    • _preUpdate(data: any, options: any, user: any): Promise<void>
    • inheritdoc

      Parameters

      • data: any
      • options: any
      • user: any

      Returns Promise<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

    • _preCreateDescendantDocuments(parent: any, collection: any, data: any, options: any, userId: any): void
    • Support the special case descendant document changes within an ActorDelta. The descendant documents themselves are configured to have a synthetic Actor as their parent. We need this to ensure that the ActorDelta receives these events which do not bubble up.

      inheritdoc

      Parameters

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

      Returns void

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

      Parameters

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

      Returns void

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

      Parameters

      • parent: any
      • collection: any
      • ids: any
      • 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

    • _onUpdateBaseActor(update?: any, options?: any): void
    • When the base Actor for a TokenDocument changes, we may need to update its Actor instance

      internal

      Parameters

      • update: any = {}
      • options: any = {}

      Returns void

    • _prepareDetectionModes(): void
    • Prepare detection modes which are available to the Token. Ensure that every Token has the basic sight detection mode configured.

      Returns void

    • _onRelatedUpdate(update?: any, options?: DocumentModificationContext): void
    • Whenever the token's actor delta changes, or the base actor changes, perform associated refreshes.

      Parameters

      • update: any = {}
      • options: DocumentModificationContext = {}

      Returns void

    • Get an Array of attribute choices which could be tracked for Actors in the Combat Tracker

      Parameters

      • data: any
      • _path: string[] = []

      Returns TrackedAttributesDescription

    • getTrackedAttributeChoices(attributes: any): any
    • Inspect the Actor data model and identify the set of attributes which could be used for a Token Bar

      Parameters

      • attributes: any

        The tracked attributes which can be chosen from

      Returns any

      A nested object of attribute choices to display

    • Retrieve an Array of attribute choices from a plain object.

      Parameters

      • data: any

        The object to explore for attributes.

      • _path: string[] = []

      Returns TrackedAttributesDescription

    • Retrieve an Array of attribute choices from a SchemaField.

      Parameters

      • schema: SchemaField

        The schema to explore for attributes.

      • _path: string[] = []

      Returns TrackedAttributesDescription