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

  • Parameters

    • data: any
    • context: {} = {}

      Returns TokenDocument

    Properties

    _actor: Actor

    A cached reference to the Actor document that this Token modifies. This may be a "synthetic" unlinked Token Actor which does not exist in the World.

    alpha: any
    #sort: number = 0

    Accessors

    • A lazily evaluated 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 actorData.

      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

    • prepareBaseData(): void
    • inheritdoc

      Returns void

    • clone(data?: {}, options?: {}): any
    • inheritdoc

      Parameters

      • data: {} = {}
        • options: {} = {}

          Returns any

        • Create a synthetic Actor using a provided Token instance If the Token data is linked, return the true Actor document If the Token data is not linked, create a synthetic Actor using the Token's actorData override

          Returns Actor

        • getBarAttribute(barName: string, 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

          • alternative: string = {}

            An alternative attribute path to get instead of the default one

          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, including statusId

            • 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>

        • modifyActorDocument(update: any, options: any): Promise<Actor[]>
        • Redirect updates to a synthetic Token Actor to instead update the tokenData override object. Once an attribute in the Token has been overridden, it must always remain overridden.

          Parameters

          • update: any

            The provided differential update data which should update the Token Actor

          • options: any

            Provided options which modify the update request

          Returns Promise<Actor[]>

          The updated un-linked Actor instance

        • getEmbeddedCollection(embeddedName: any): any
        • inheritdoc

          Parameters

          • embeddedName: any

          Returns any

        • createActorEmbeddedDocuments(embeddedName: string, data: any[], options: any): Promise<Document[]>
        • Redirect creation of Documents within a synthetic Token Actor to instead update the tokenData override object.

          Parameters

          • embeddedName: string

            The named embedded Document type being modified

          • data: any[]

            The provided initial data with which to create the embedded Documents

          • options: any

            Provided options which modify the creation request

          Returns Promise<Document[]>

          The created Embedded Document instances

        • updateActorEmbeddedDocuments(embeddedName: string, updates: any[], options: any): Promise<Document[]>
        • Redirect updating of Documents within a synthetic Token Actor to instead update the tokenData override object.

          Parameters

          • embeddedName: string

            The named embedded Document type being modified

          • updates: any[]

            The provided differential data with which to update the embedded Documents

          • options: any

            Provided options which modify the update request

          Returns Promise<Document[]>

          The updated Embedded Document instances

        • deleteActorEmbeddedDocuments(embeddedName: string, ids: string[], options: any): Promise<Document[]>
        • Redirect deletion of Documents within a synthetic Token Actor to instead update the tokenData override object.

          Parameters

          • embeddedName: string

            The named embedded Document type being deleted

          • ids: string[]

            The IDs of Documents to delete

          • options: any

            Provided options which modify the deletion request

          Returns Promise<Document[]>

          The deleted Embedded Document instances

        • _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): any
        • inheritdoc

          Parameters

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

          Returns any

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

          Returns void

        • _preUpdateTokenActor(data: any, options: any, user: User): Promise<void>
        • When the Actor data overrides change for an un-linked Token Actor, simulate the pre-update process.

          Parameters

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

          Returns Promise<void>

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

          Parameters

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

          Returns void

        • _onUpdateTokenActor(data: any, options: any, userId: string): void
        • When the Actor data overrides change for an un-linked Token Actor, simulate the post-update process.

          Parameters

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

          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