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

Mixes

CanvasDocumentMixin

See

  • Scene The Scene document type which contains Token documents
  • TokenConfig The Token configuration application

Hierarchy

  • any
    • TokenDocument

Properties

actors: Collection<Actor> = ...

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

regions: Set<RegionDocument> = ...

The Regions this Token is currently in.

Accessors

  • get actor(): Actor
  • 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

  • get baseActor(): 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

  • get isSecret(): boolean
  • Does this TokenDocument have the SECRET disposition and is the current user lacking the necessary permissions that would reveal this secret?

    Returns boolean

  • get combatant(): Combatant
  • 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

Methods

  • Parameters

    • options: {} = {}

      Returns void

      Inherit Doc

    • Returns void

    • Returns void

      Inherit Doc

    • Returns void

      Inherit Doc

    • 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

      • Optional options: {
            alternative: string;
        } = {}
        • alternative: string

          An alternative attribute path to get instead of the default one

      Returns any

      The attribute displayed on the Token bar, if any

    • 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 Actor of the Token have this status effect?

    • Add or remove this Token from a Combat encounter.

      Parameters

      • Optional options: {
            active: boolean;
        } = {}

        Additional options passed to TokenDocument.createCombatants or TokenDocument.deleteCombatants

        • active: boolean

          Require this token to be an active Combatant or to be removed. Otherwise, the current combat state of the Token is toggled.

      Returns Promise<boolean>

      Is this Token now an active Combatant?

    • Convenience method to change a token vision mode.

      Parameters

      • visionMode: string

        The vision mode to apply to this token.

      • Optional defaults: boolean = true

        If the vision mode should be updated with its defaults.

      Returns Promise<any>

    • Parameters

      • embeddedName: any

      Returns any

      Inherit Doc

    • Parameters

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

      Returns void

      Inherit Doc

    • Parameters

      • changed: any
      • options: any
      • user: any

      Returns Promise<boolean>

      Inherit Doc

    • Parameters

      • changed: any
      • options: any
      • userId: any

      Returns void

      Inherit Doc

    • Parameters

      • options: any
      • userId: any

      Returns void

      Inherit Doc

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

      Parameters

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

      Returns void

      Inherit Doc

    • Parameters

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

      Returns void

      Inherit Doc

    • Parameters

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

      Returns void

      Inherit Doc

    • Parameters

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

      Returns void

      Inherit Doc

    • Parameters

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

      Returns void

      Inherit Doc

    • Parameters

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

      Returns void

      Inherit Doc

    • Internal

      When the base Actor for a TokenDocument changes, we may need to update its Actor instance

      Parameters

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

      Returns void

    • Protected

      Infer the subject texture path to use for a token ring.

      Returns string

    • Protected

      Prepare detection modes which are available to the Token. Ensure that every Token has the basic sight detection mode configured.

      Returns void

    • Protected

      Is to Token document updated such that the Regions the Token is contained in may change? Called as part of the preUpdate workflow.

      Parameters

      • changes: any

        The changes.

      Returns boolean

      Could this Token update change Region containment?

    • Protected

      Whenever the token's actor delta changes, or the base actor changes, perform associated refreshes.

      Parameters

      • Optional update: any = {}

        The update delta.

      • Optional operation: DatabaseUpdateOperation = {}

        The database operation that was performed

      Returns void

    • Handle changes to the regions this token is in.

      Parameters

      • priorRegionIds: string[]

        The IDs of the prior regions

      Returns void

    • Trigger TOKEN_MOVE, TOKEN_MOVE_IN, and TOKEN_MOVE_OUT events.

      Parameters

      • Optional origin: {
            x: number;
            y: number;
            elevation: number;
        }

        The origin of movement

        • x: number
        • y: number
        • elevation: number
      • teleport: boolean

        Teleporation?

      • forced: boolean

        Forced movement?

      Returns void

    • Identify the Regions the Token currently is or is going to be in after the changes are applied.

      Parameters

      • Optional changes: any = {}

        The changes.

      Returns void | string[]

      The Region IDs the token is (sorted), if it could be determined.

    • Create or remove Combatants for an array of provided Token objects.

      Parameters

      • tokens: TokenDocument[]

        The tokens which should be added to the Combat

      • Optional options: {
            combat: Combat;
        } = {}

        Options which modify the toggle operation

        • combat: Combat

          A specific Combat instance which should be modified. If undefined, the current active combat will be modified if one exists. Otherwise, a new Combat encounter will be created if the requesting user is a Gamemaster.

      Returns Promise<Combatant[]>

      An array of created Combatant documents

    • Remove Combatants for the array of provided Tokens.

      Parameters

      • tokens: TokenDocument[]

        The tokens which should removed from the Combat

      • Optional options: {
            combat: Combat;
        } = {}

        Options which modify the operation

        • combat: Combat

          A specific Combat instance from which Combatants should be deleted

      Returns Promise<Combatant[]>

      An array of deleted Combatant documents

    • Parameters

      • documents: any
      • operation: any
      • user: any

      Returns Promise<boolean>

      Inherit Doc

    • Parameters

      • documents: any
      • operation: any
      • user: any

      Returns Promise<boolean>

      Inherit Doc

    • Parameters

      • documents: any
      • operation: any
      • user: any

      Returns Promise<void>

    • Parameters

      • documents: any
      • operation: any
      • user: any

      Returns Promise<void>

    • Parameters

      • documents: any
      • operation: any
      • user: any

      Returns Promise<void>

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

      Parameters

      • Optional data: any

        The object to explore for attributes, or an Actor type.

      • Optional _path: string[] = []

      Returns TrackedAttributesDescription

    • 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

    • Handle Regions potentially stopping movement.

      Parameters

      • documents: TokenDocument[]

        Document instances to be updated

      • operation: DatabaseUpdateOperation

        Parameters of the database update operation

      • user: User

        The User requesting the update operation

      Returns Promise<void>

    • Identify and update the regions this Token is going to be in if necessary.

      Parameters

      • documents: TokenDocument[]

        Document instances to be updated

      • operation: DatabaseUpdateOperation

        Parameters of the database update operation

      Returns void