Override and extend the basic :class:Item implementation

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

  • Parameters

    • Rest ...args: [data?: ItemDataConstructorData, context?: Context<ActorPF>]

    Returns ItemPF

Properties

_memoryVariables: undefined | null | {}

Type declaration

    actions: any

    A Collection of ItemActions.

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

    An object containing links to other items.

    scriptCalls: any
    system: Readonly<{
        hasActions: true;
        hasChanges: true;
        hasIdentifier: true;
        isPhysical: boolean;
    }> = ...

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

    Type declaration

    • hasActions: true

      Whether this item has actions.

    • hasChanges: true

      Whether this item has changes and change flags.

    • hasIdentifier: true

      Whether this item receives an identifier.

    • isPhysical: boolean

      Whether this item is a physical one, possessing properties like quantity or weight.

    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 isActive(): boolean
    • Is the item is fully functional.

      This returns composite result of if the item is equipped, has quantity, is not disabled, is not out of charges, etc. and is not representative if the item can be set active or not via setActive.

      Returns boolean

      See

      activeState

      Abstract

    • get memoryVariables(): string[]
    • Returns string[]

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

    Methods

    • Internal

      Test if specified link can be created.

      Parameters

      • type: string

        The type of link.

      • item: Item

        The target item to link to.

      Returns boolean

      Whether a link to the item is possible here.

    • Private

      Handle charge update sanity checking, constraining them to reasonable values, and propagating to parent items if charges are shared.

      Parameters

      • changed: object
      • context: object

      Returns Promise<void>

    • 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

    • Internal

      Parameters

      • data: object
      • context: object
      • user: User

      Returns Promise<void>

    • Internal

      Parameters

      • changed: object
      • context: object
      • user: User

      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

      Recharges item's uses, if any.

      Parameters

      • options: {
            exact: any;
            period: any;
            rollData: any;
        } = {}

        Options

        • exact: any
        • period: any
        • rollData: any

      Returns undefined | object

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

      Recharges item's uses, if any.

      Parameters

      • options: {
            exact: any;
            maximize: any;
            period: any;
            rollData: any;
            value: any;
        } = {}

        Options

        • exact: any
        • maximize: any
        • period: any
        • rollData: any
        • value: any

      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

      • Optional options: {
            recursive: undefined | boolean;
        } = {}

        Additional options

        • recursive: undefined | boolean

          Create data recursively, meant for the real item document.

      Returns object

      • Transformed update data

      Example

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

      Update this item's charges based on provided item.

      Parameters

      • item: Item

        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: "children" | "charges" | "supplement" | "classAssociatons"

        The type of link.

      • item: Item

        The target item to link into this.

      • Optional extraData: object

        Additional data to store int he link

      Returns boolean

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

      Parameters

      • Optional altChatData: object = {}

        Optional data that will be merged into the chat data object.

      • Optional options: {
            token: undefined | TokenDocument;
        } = {}

        Additional options.

        • token: undefined | TokenDocument

          Relevant token if any.

      Returns Promise<void | ChatMessage>

      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.

      • Optional extraParams: {} = {}

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

        • Optional shared: object = {}

          Shared data object

        Returns Promise<object>

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

      • Attack sources for a specific action.

        Parameters

        • actionId: string

          Action ID

        • Optional options: {
              rollData: undefined | object;
          } = {}

          Additional options

          • rollData: undefined | 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 {}

        A list of changes

        • Item specific conditional targets.

          Parameters

          • target: string

            Conditional target

          • result: Record<string, string>

            Result key to label mapping.

          Returns void

          Abstract

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

          Parameters

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

            The given context.

          Returns ItemChange[]

          • The matching changes.

          Remarks

          • Always returns empty array if no actor is present.
        • Private

          Retrieve stack of contexts related to the one given.

          Parameters

          • contexts: string[]

            Context subtarget ID array.

          Returns Set<string>

          • Modified context array.
        • Get default charge cost for all actions.

          Parameters

          • Optional options: {
                rollData: undefined | object;
            } = {}

            Additional options

            • rollData: undefined | object

              Roll data instance

          Returns number

          Number for default cost.

        • Get full description.

          Parameters

          • options: {
                body: undefined | boolean;
                chatcard: undefined | boolean;
                data: undefined | object;
                header: undefined | boolean;
                isolated: undefined | boolean;
                rollData: undefined | object;
            } = {}

            Item type dependant options for rendering the description.

            • body: undefined | boolean

              Include main description body if such exists.

            • chatcard: undefined | boolean

              Instruct template to render chat card in mind.

            • data: undefined | object

              Template data for rendering

            • header: undefined | boolean

              Include header if such exists.

            • isolated: undefined | boolean
            • rollData: undefined | object

              Roll data for transforming description

          Returns string

          • Full description.
        • Description Data

          Parameters

          • options: {
                isolated: undefined | boolean;
                rollData: undefined | object;
            } = {}

            Additional options

            • isolated: undefined | boolean

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

            • rollData: undefined | object

              Roll data instance

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

        • Returns labels for this item

          Parameters

          • Optional options: {
                actionId: undefined | string;
                rollData: undefined | object;
            } = {}

            Additional options

            • actionId: undefined | string

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

            • rollData: undefined | 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

          • Optional options: {
                _results: undefined | Set<any>;
                recursive: undefined | boolean;
            } = {}

            Additional options

            • _results: undefined | Set<any>

              Internal use only.

            • recursive: undefined | boolean

              Retrieved linked items recursively.

          Returns object[] | Item[]

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

          • Optional options: {
                _results: undefined | Set<string>;
                recursive: undefined | boolean;
            } = {}

            Additional options

            • _results: undefined | Set<string>

              Internal use only

            • recursive: undefined | boolean

              Retrieve links recursively.

          Returns object[] | Item[]

          Linked items or their compendium index data

          Example

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

          • Optional weapon: boolean = true

            Get proficiency as a weapon. Armor otherwise.

          Returns boolean

          • Whether or not the owner of the item is proficient.

          Abstract

          Throws

          • If item type does not support proficiency.

          Since

          PF1 v10

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

          Returns Promise<{
              disabled: boolean;
              duration: {
                  startTime: number;
              };
              img: null | string;
              name: null | string;
              origin: any;
          }>

        • Per item type chat data.

          Parameters

          • data: ChatData

            A partial of a chat data object that can be modified to add per item type data.

          • labels: {}

            The labels for this item.

            • props: string[]

              Additional property strings

            • rollData: object

              A rollData object to be used for checks

            • Optional options: {
                  actionId: undefined | string;
                  chatcard: undefined | boolean;
              } = {}

              Additional options

              • actionId: undefined | string

                Action this pertains to, if any.

              • chatcard: undefined | boolean

                Is this for a chat card?

            Returns void

          • 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: undefined | boolean;
                  context: undefined | object;
                  exact: undefined | boolean;
                  maximize: undefined | boolean;
                  period: undefined | "round" | "minute" | "hour" | "day" | "week" | "any";
                  rollData: undefined | object;
                  value: undefined | number;
              } = {}

              Options

              • commit: undefined | boolean

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

              • context: undefined | object

                Update context

              • exact: undefined | boolean

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

              • maximize: undefined | boolean

                Recharge to full regardless of recharge formula.

              • period: undefined | "round" | "minute" | "hour" | "day" | "week" | "any"

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

              • rollData: undefined | object

                Roll data instance to use for formulas.

              • value: undefined | 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.

            • Optional options: {
                  commit: undefined | boolean;
              } = {}

              Additional options

              • commit: undefined | boolean

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

            Returns Promise<undefined | object | Item>

          • Set item's active state.

            Parameters

            • active: boolean

              Active state

            • Optional context: object

              Optional update context

            Returns Promise<ItemPF>

            • Update promise if item type supports the operation.

            Abstract

            Throws

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

          • Protected

            Adjust temporary item before creation

            Parameters

            • Optional item: ItemPF

              Temporary document

            • Optional data: object

              Creation data

            • Optional override: boolean = false

              Override values even if defined

            Returns void

            Abstract

          • Internal

            Determine whether a given change set affect senses

            Parameters

            • changes: object

              An object containing changeFlags and changes to be inspected.

            Returns boolean

            Static

          • Internal

            Chat card actions

            Parameters

            • action: string
            • options: {
                  button: undefined | Element;
                  event: undefined | Event;
                  item: undefined | ItemPF;
              } = {}
              • button: undefined | Element

                Button element

              • event: undefined | Event

                Triggering event

              • item: undefined | ItemPF

                Item associated with card

            Returns Promise<undefined | boolean>

          • Private

            Handle toggling the visibility of chat card content when the name is clicked

            Parameters

            • event: Event

              The originating click event

            Returns void

          • Item create dialog.

            Parameters

            • data: object = {}

              Initial form data

            • Optional context: {
                  options: undefined | object;
                  pack: undefined | null | string;
                  parent: undefined | null | Actor;
              } = {}

              Additional options.

              • options: undefined | object

                Dialog context options.

              • pack: undefined | null | string

                Pack ID parameter passed to Item.create() options

              • parent: undefined | null | Actor

                Parent parameter passed to Item.create() options

            Returns Promise<null | Item>

            Synchronized with Foundry VTT v11.315

          Generated using TypeDoc