Pathfinder 1e for Foundry VTT
    Preparing search index...

    Override and extend the basic :class:Item implementation

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    • Parameters

      • data: CreateData

        Initial data from which to construct the Item

      • Optionalcontext: ConstructionContext

        Construction context options

      Returns ItemPF

    Properties

    _memoryVariables: undefined | null | {}
    actions: undefined | Collection<ItemAction, Methods<ItemAction>>

    A Collection of ItemActions.

    changes: undefined | Collection<any, Methods<any>>
    links: undefined | Record<string, ItemPF>

    An object containing links to other items.

    scriptCalls: undefined | Collection<string, ItemScriptCall>
    system: Readonly<
        {
            hasActions: true;
            hasChanges: true;
            hasIdentifier: true;
            isPhysical: boolean;
            subtypeName: false;
        },
    > = ...

    A static object holding system-specific metadata applicable to all instances of this Document class.

    Accessors

    • get allDamageSources(): undefined | ItemChange[]

      Generic damage source retrieval for default action, includes default conditionals and other item specific modifiers.

      Returns undefined | ItemChange[]

      All relevant changes, or undefined if action was not found.

    • get attackSources(): undefined | object[]

      Return attack sources for default action.

      Returns undefined | object[]

      Array of value and label pairs for attack bonus sources on the main attack.

    • get defaultAmmo(): undefined | Item<"base" | ModuleSubType>

      Linked ammunition item if any.

      Returns undefined | Item<"base" | ModuleSubType>

    • get effect(): null | ActiveEffect<"base" | ModuleSubType>

      An active effect associated with this item.

      Returns null | ActiveEffect<"base" | ModuleSubType>

      • Most item types don't have associated effect.
    • get hasChanges(): any

      Whether the item is tangible physical object in reality.

      Returns any

      • You can utilize this with raw data via CONFIG.Item.documentClasses[type]?.isPhysical
    • get isPhysical(): any

      Whether the item is tangible physical object in reality.

      Returns any

      • You can utilize this with raw data via CONFIG.Item.documentClasses[type]?.isPhysical
    • get maxCharges(): number

      Maximum possible charges this item can have.

      Returns number

      • Can return zero. Usually signifying something has reduced the potential uses below usability.
      • Can return infinity, signifying lack of limits.
    • get memoryVariables(): string[]

      Returns string[]

      The keys of data variables to memorize between updates, for e.g. determining the difference in update.

    • get rootItem(): Item<"base" | ModuleSubType>
      Internal

      Root item.

      Specifically the item at bottom of the container tree.

      Returns Item<"base" | ModuleSubType>

    • get isPhysical(): boolean

      Whether the item is tangible physical object in reality.

      Returns boolean

      • You can utilize this with raw data via CONFIG.Item.documentClasses[type]?.isPhysical

    Methods

    • Internal Experimental

      Return active state change from data if present

      This is a hack to allow item-type agnostic active state change detection.

      Parameters

      • changed: object

      Returns any

    • Parameters

      • config: any
      • options: {} = {}

      Returns Promise<HTMLElement | HTMLCollection | DocumentFragment>

    • Internal

      Test if specified link can be created.

      Parameters

      • type: string

        The type of link.

      • item: Item<"base" | ModuleSubType>

        The target item to link to.

      • Optionaloptions: object = {}

        Additional options

      Returns Promise<boolean>

      Whether a link to the item is possible here.

    • Configure item before data preparation.

      Parameters

      • options: object = {}

        Data model options

      Returns void

    • Parameters

      • content: any
      • config: any
      • options: any

      Returns Promise<null | HTMLElement>

    • Copy from foundry.documents.JournalEntryPage#_embedTextPage

      Parameters

      • config: any
      • options: {} = {}

      Returns Promise<DocumentFragment>

      foundry.documents.JournalEntryPage#_embedTextPage

    • Internal

      Parameters

      • type: string

        The type of link.

      • item: object

        The target item to link to.

      • uuid: string

        The link identifier for the item.

      Returns any[]

      An array to insert into this item's link data.

    • Parameters

      • data: object

        Creation data

      • context: object

        Creation context options

      • userId: string

        Triggering user ID

      Returns void

    • Parameters

      • context: object

        Delete context options

      • userId: string

        Triggering user

      Returns void

    • Parameters

      • changed: object

        Changed data

      • context: object

        Context

      • userId: string

        Triggering user ID

      Returns void

    • Parameters

      • data: any
      • context: any
      • user: any

      Returns Promise<void>

    • Prepare data potentially dependent on other items.

      This should be run at in Item.prepareDerivedData() if no actor is present, or in actor's prepareDerivedData after document preparation is done.

      Parameters

      • final: boolean = false

        Is this final call to this?

      Returns void

    • Internal

      Parameters

      • changed: object

        Changed data

      • context: object

        Context

      • user: User

        Triggering user

      Returns Promise<void>

    • Internal

      Fake DataModel-like behaviour

      Ensure numeric bits remain numbers

      Parameters

      • system: object

        System data

      Returns void

    • Internal

      Recharges item's uses, if any.

      Parameters

      • options: { exact: boolean; period?: string; rollData?: object } = {}

        Options

        • exact: boolean

          Exact time period only

        • Optionalperiod?: string

          Recharge only if matching this time period

        • OptionalrollData?: object

          Roll data

      Returns undefined | object

      • Update data or undefined if no update is needed.
    • Internal

      Recharges item's uses, if any.

      Parameters

      • options: {
            exact?: boolean;
            maximize?: boolean;
            period?: string;
            rollData?: object;
            value?: number;
        } = {}

        Options

        • Optionalexact?: boolean

          Match only exact time period

        • Optionalmaximize?: boolean

          Maximize instead of using recharge formula

        • Optionalperiod?: string

          Recharge only if it matches this time period

        • OptionalrollData?: object

          Roll data instance

        • Optionalvalue?: number

          Set charges to specific value

      Returns Promise<undefined | object>

      • Update data or undefined if no update is necessary.
    • Internal

      Transform given data so it becomes valid update data within parent item.

      This can, for example, be used to generate batched update to the real item.

      Parameters

      • data: object

        Update data

      • Optionaloptions: { recursive?: boolean } = {}

        Additional options

        • Optionalrecursive?: boolean

          Create data recursively, meant for the real item document.

      Returns object

      • Transformed update data
      _transformContainerUpdateData({ name: "new name" })
      // => { system: { items: { [itemID]: { name: "new name" } } } }
    • Internal

      Update this item's charges based on provided item.

      Parameters

      • source: Item<"base" | ModuleSubType>

        Charge source

      Returns void

    • Generic charge addition (or subtraction) function that either adds charges or quantity, based on item data.

      Parameters

      • value: number

        The amount of charges to add.

      Returns Promise<void | ItemPF>

      Updated document or undefined if no update is possible.

    • Sets a boolean flag on this item.

      Parameters

      • flagName: string

        The name/key of the flag to set.

      • context: object = {}

        Update context

      Returns Promise<boolean>

      Whether something was changed.

    • Creates a link to another item.

      Parameters

      • type: "charges" | "children" | "supplement" | "classAssociations"

        The type of link.

      • item: Item<"base" | ModuleSubType>

        The target item to link into this.

      • OptionalextraData: object

        Additional data to store int he link

      • Optionaloptions: object = {}

        Additional options

      Returns Promise<boolean>

      • Whether a link was created.
    • Display the chat card for an Item as a message in chat

      Parameters

      • OptionalmessageData: object = {}

        Optional data that will be merged into the message data.

      • Optionaloptions: { token?: TokenDocument } = {}

        Additional options.

        • Optionaltoken?: TokenDocument

          Relevant token if any.

      Returns Promise<void | ChatMessage<"base" | ModuleSubType>>

      Chat message instance if one was created.

    • Executes all script calls on this item of a specified category.

      Parameters

      • category: string

        The category of script calls to call.

      • OptionalextraParams: Record<string, any> = {}

        A dictionary of extra parameters to pass as variables for use in the script.

      • Optionalshared: object = {}

        Shared data object

      Returns Promise<object>

      The shared object between calls which may have been given data.

    • Get all items linked by any means.

      Returns Promise<Item<"base" | ModuleSubType>[]>

      • Linked items
    • Attack sources for a specific action.

      Parameters

      • actionId: string

        Action ID

      • Optionaloptions: { rollData?: object } = {}

        Additional options

        • OptionalrollData?: object

          Roll data instance

      Returns undefined | object[]

      Array of value and label pairs for attack bonus sources on the main attack, or undefined if the action is missing.

    • Generates lists of change targets this item can have.

      Parameters

      • target: string

        The target key, as defined in PF1.buffTargets.

      Returns Record<string, string>

      A list of changes

    • Generates ChatData for this item, either in a default configuration or for a specific action.

      Parameters

      • Optionaloptions: {
            actionId?: string;
            body?: boolean;
            chatcard?: boolean;
            extended?: boolean;
            footer?: boolean;
            header?: boolean;
            interactive?: boolean;
            rollData?: object;
        } = {}

        Options affecting how descriptions are enriched. rollData

        • OptionalactionId?: string

          The ID of an action on this item to generate chat data for, defaults to ItemPF.defaultAction

        • Optionalbody?: boolean

          Include main description

        • Optionalchatcard?: boolean

          Is this actually for chat card.

        • Optionalextended?: boolean

          Include extended information that may not be useful in all circumstances.

        • Optionalfooter?: boolean

          Include footer if it exists

        • Optionalheader?: boolean

          Include header if it exists

        • Optionalinteractive?: boolean

          Was this from user interaction (allowing farther interactions)

        • OptionalrollData?: object

          Defaults to ItemAction#getRollData/ItemPF#getRollData.

      Returns Promise<ChatData>

      The chat data for this item (+action)

    • Item specific conditional sub targets.

      Parameters

      • result: object

        Result key to label mapping.

      Returns void

    • Item specific conditional targets.

      Parameters

      • results: Record<string, object>

        Key to target mapping.

      Returns void

    • Finds, filters and alters changes relevant to a context, and returns the result (as an array)

      Parameters

      • context:
            | "mwdamage"
            | "twdamage"
            | "rwdamage"
            | "sdamage"
            | "mattack"
            | "wdamage"
            | "nattack"
            | "rattack"
            | "tattack"
            | "rdamage"
            | "mdamage"
            | "ndamage"
            | "tdamage" = ...

        The given context.

      Returns ItemChange[]

      • The matching changes.
      • Always returns empty array if no actor is present.
    • Get default charge cost for all actions.

      Parameters

      • Optionaloptions: { rollData?: object } = {}

        Additional options

        • OptionalrollData?: object

          Roll data instance

      Returns number

      Number for default cost.

    • Get full description.

      Parameters

      • options: {
            actionId: any;
            body?: boolean;
            chatcard?: boolean;
            data?: object;
            header?: boolean;
            identified?: boolean;
            isolated?: boolean;
            rollData?: object;
        } = {}

        Item type dependant options for rendering the description.

        • actionId: any
        • Optionalbody?: boolean

          Include main description body if such exists.

        • Optionalchatcard?: boolean

          Instruct template to render chat card in mind.

        • Optionaldata?: object

          Template data for rendering

        • Optionalheader?: boolean

          Include header if such exists.

        • Optionalidentified?: boolean

          Enforce identified description retrieval

        • Optionalisolated?: boolean
        • OptionalrollData?: object

          Roll data for transforming description

      Returns Promise<string>

      • Full description.
    • Description Data

      Required to be async due to spell associated class map building.

      Parameters

      • options: { actionId?: string; isolated?: boolean; rollData?: object } = {}

        Additional options

        • OptionalactionId?: string

          ID of an action. Default action is used if undefined.

        • Optionalisolated?: boolean

          Include extra data to reflect it not being so easily available in context.

        • OptionalrollData?: object

          Roll data instance

      Returns Promise<object>

      • Description context data
    • Parameters

      • flagName: string

        The name/key of the flag to get.

      Returns undefined | string | number

      The value stored in the flag.

    • Get all item dictionary flags as array of objects.

      Returns Record<string, any>

      • All dictionary flags
    • Returns labels for this item

      Parameters

      • Optionaloptions: { actionId?: string; isolated?: boolean; rollData?: object } = {}

        Additional options

        • OptionalactionId?: string

          ID of one of this item's actions to get labels for; defaults to first action

        • Optionalisolated?: boolean

          Is this isolated use? If true, more data is included.

        • OptionalrollData?: object

          Roll data to use.

      Returns Record<string, string>

      This item's labels

    • Get item links of type

      Parameters

      • type: string

        Link type

      • includeLinkData: boolean = false

        Include link data, return value changes from item array to object array

      • Optionaloptions: { _results?: Set<any>; recursive?: boolean } = {}

        Additional options

        • Optional_results?: Set<any>

          Internal use only.

        • Optionalrecursive?: boolean

          Retrieved linked items recursively.

      Returns Promise<object[] | Item<"base" | ModuleSubType>[]>

      • Linked items, or objects with linked items and additional data
    • Retrieve list of linked items for a type, synchronously. Intended mainly for fetching child or charge links quickly.

      Parameters

      • type: string

        Link type, e.g. "children", "charges", or "classAssociations"

      • Optionaloptions: { _results?: Set<string>; recursive?: boolean } = {}

        Additional options

        • Optional_results?: Set<string>

          Internal use only

        • Optionalrecursive?: boolean

          Retrieve links recursively.

      Returns object[] | Item<"base" | ModuleSubType>[]

      Linked items or their compendium index data

      const childItems = item.getLinkedItemsSync("children");
      
    • Parameters

      • Optionalweapon: boolean = true

        Get proficiency as a weapon. Armor otherwise.

      Returns boolean

      • Whether or not the owner of the item is proficient.
      • If item type does not support proficiency.

      PF1 v10

    • Determines the starting data for an ActiveEffect based off this item.

      Parameters

      • options: { rollData: object } = {}

        Additional options

        • rollData: object

          Roll data

      Returns Promise<object>

      • Active Effect creation data
    • Parameters

      • flagName: string

        The name/key of the flag on this item.

      Returns boolean

      Whether the flag was found on this item.

    • Recharges item's uses, if any.

      Parameters

      • options: {
            commit?: boolean;
            context?: object;
            exact?: boolean;
            maximize?: boolean;
            period?: "round" | "minute" | "hour" | "day" | "week" | "any";
            rollData?: object;
            value?: number;
        } = {}

        Options

        • Optionalcommit?: boolean

          Commit update directly. If false, returns the update data instead.

        • Optionalcontext?: object

          Update context

        • Optionalexact?: boolean

          Use exact time period. Otherwise "week" for example will also recharge items with "day" period.

        • Optionalmaximize?: boolean

          Recharge to full regardless of recharge formula.

        • Optionalperiod?: "round" | "minute" | "hour" | "day" | "week" | "any"

          Recharge period. Use "any" to ignore item's configuration.

        • OptionalrollData?: object

          Roll data instance to use for formulas.

        • Optionalvalue?: number

          Recharge to specific value, respecting maximum and minimum bounds.

      Returns Promise<undefined | object | ItemPF>

      • Promise for the update, update data object, or undefined (no update needed).
    • Removes a boolean flag from this item.

      Parameters

      • flagName: string

        The name/key of the flag to remove.

      • context: object = {}

        Update context

      Returns Promise<boolean>

      Whether something was changed.

    • Removes a dictionary flag from this item.

      Parameters

      • flagName: string

        The name/key of the flag to remove.

      • context: object = {}

        Update context

      Returns Promise<boolean>

      Whether something was changed.

    • Removes all link references to an item.

      Parameters

      • uuid: string

        The UUID of the item to remove links to.

      • Optionaloptions: { commit?: boolean } = {}

        Additional options

        • Optionalcommit?: boolean

          Commit changes to database. If false, resulting update data is returned instead.

      Returns Promise<undefined | object | Item<"base" | ModuleSubType>>

      • Updated document, update data, or undefined
    • Set item's active state.

      Parameters

      • active: boolean

        Active state

      • Optionalcontext: object

        Optional update context

      Returns Promise<ItemPF>

      • Update promise if item type supports the operation.
      • If item does not support the operation.
    • Sets a dictionary flag value on this item.

      Parameters

      • flagName: string

        The name/key of the flag to set.

      • value: string | number

        The flag's new value.

      • context: object = {}

        Update context

      Returns Promise<boolean>

      Whether something was changed.

    • Parameters

      • data: object

        Update data

      • context: object = {}

        Context

      Returns Promise<Item<"base" | ModuleSubType>>

      • Updated item
    • Use an attack, using SharedActionData

      Parameters

      • options: {
            actionId?: string;
            chatMessage?: boolean;
            cost?: number;
            dice?: string;
            ev?: null | Event;
            options?: UseOptions;
            rollMode?: string;
            skipDialog?: boolean;
            token?: TokenDocument;
        } = {}

        Options

        • OptionalactionId?: string

          The ID of the action to use, defaults to the first action

        • OptionalchatMessage?: boolean

          Whether to send a chat message for this action

        • Optionalcost?: number

          Cost override. Replaces charge cost or slot cost as appropriate.

        • Optionaldice?: string

          The base dice to roll for this action

        • Optionalev?: null | Event

          The event that triggered the use, if any

        • Optionaloptions?: UseOptions

          Additional use options.

        • OptionalrollMode?: string

          The roll mode to use for the chat message

        • OptionalskipDialog?: boolean

          Whether to skip the dialog for this action

        • Optionaltoken?: TokenDocument

          Token this action is for, if any.

      Returns Promise<void | ActionUse | SharedActionData>

      • Action use, shared data, or nothing.
      • On some invalid inputs.
    • Protected

      Adjust temporary item before creation

      Parameters

      • Optionalitem: ItemPF

        Temporary document

      • Optionaldata: object

        Creation data

      • Optionaloverride: boolean = false

        Override values even if defined

      Returns void

    • Internal

      Collect information on supplemental items and create them

      Parameters

      • items: Item<"base" | ModuleSubType>[]

        Array of items to draw supplemental data from

      • actor: Actor<"base" | ModuleSubType>

        Owner

      Returns Promise<void>

    • Internal

      Determine whether a given change set affects size

      Parameters

      • data: object

        Item data

      Returns boolean

      • Contains size targeting change
    • Internal

      Determine whether a given change set affect senses

      Parameters

      • changes: object

        An object containing changeFlags and changes to be inspected.

      Returns boolean

      • Vision alteration detected
    • On-Create Operation

      Post-create processing so awaiting the original operation has all secondary updates completed when it returns.

      Parameters

      • documents: Document[]

        Documents

      • operation: any

        Operations and context data

      • user: User

        Triggering user

      Returns Promise<void>

    • On-Delete Operation

      Post-delete processing so awaiting the original operation has all secondary updates completed when it returns.

      Parameters

      • documents: Document[]

        Documents

      • operation: any

        Operations and context data

      • user: User

        Triggering user

      Returns Promise<void>

    • On-Update Operation

      Post-update processing so awaiting the original operation has all secondary updates completed when it returns.

      Parameters

      • documents: Document[]

        Documents

      • operation: any

        Operations and context data

      • user: User

        Triggering user

      Returns Promise<void>

    • Item create dialog.

      Parameters

      • data: object = {}

        Initial item data

      • createOptions: {} = {}
      • __namedParameters: {} = {}

      Returns Promise<null | Item<"base" | ModuleSubType>>

      Synchronized with Foundry VTT v13.347

    • Override to provide naming by subType potential.

      Parameters

      • context: {
            pack?: null | string;
            parent?: null | Document;
            subType?: string;
            type?: string;
        } = {}

        Context where the name would be used

        • Optionalpack?: null | string

          Pack this would be within

        • Optionalparent?: null | Document

          Parent document

        • OptionalsubType?: string

          Document subtype. Nonstandard option.

        • Optionaltype?: string

          Type

      Returns string

      Synced with Foundry v12.331