Override and extend the basic :class:Item implementation

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

Properties

_memoryVariables: undefined | null | {}

Type declaration

    actions: Collection<ItemAction>

    A Collection of ItemActions.

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

    An object containing links to other items.

    name: null | string
    scriptCalls: undefined | Collection<any>
    system: Readonly<{
        isPhysical: boolean;
    }> = ...

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

    Type declaration

    • 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 attackArray(): number[]
    • Get default action's attack array.

      Returns number[]

      Simple array describing the individual guaranteed attacks.

    • 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 hasAttack(): boolean
    • Returns true if any of this item's actions have an attack, see ItemAction#hasAttack.

      Returns boolean

    • get hasDamage(): boolean
    • Returns true if any of this item's actions have a damage roll, see ItemAction#hasDamage.

      Returns boolean

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

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

    • get subType(): null | string
    • The item's subtype, or null if the item has no subtype

      Returns null | string

    • get totalDurationSeconds(): null | number
    • Returns total duration in seconds or null.

      Returns null | number

      Seconds or null.

    • get defaultContextNote(): {
          subTarget: string;
          text: string;
      }
    • Returns {
          subTarget: string;
          text: string;
      }

      • subTarget: string
      • text: string

    Methods

    • Private

      Prepare .system.duration

      Parameters

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

        Additional options

        • rollData: undefined | object

          Roll data instance. New instance is generated if undefined and needed.

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

      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.

    • Parameters

      • linkType: string

        The type of link.

      • dataType: string

        Either "compendium", "data" or "world".

      • targetItem: object

        The target item to link to.

      • itemLink: string

        The link identifier for the item.

      Returns boolean

      Whether a link to the item is possible here.

    • Creates a link to another item.

      Parameters

      • linkType: string

        The type of link. e.g. "children", "charges", "classAssociations" or "ammunition".

      • dataType: string

        Either "compendium", "data" or "world".

      • targetItem: object

        The target item to link to.

      • itemLink: string

        The link identifier for the item. e.g. UUID for items external to the actor, and item ID for same actor items.

      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: Object = {}

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

      Returns Promise<object>

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

    • Parameters

      • linkType: string

        The type of link.

      • dataType: string

        Either "compendium", "data" or "world".

      • targetItem: object

        The target item to link to.

      • itemLink: string

        The link identifier for the item.

      Returns any[]

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

    • Returns Promise<(Document<any, any, Metadata<any>> | ItemPF | {
          item: undefined | null | Document<any, any, Metadata<any>> | ItemPF;
          linkData: any;
      })[]>

    • Attack sources for a specific action.

      Parameters

      • actionId: string

        Action ID

      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 ChatData for this item, either in a default configuration or for a specific action.

      Parameters

      • Optional enrichOptions: any = {}

        Options affecting how descriptions are enriched. rollData defaults to ItemAction#getRollData/getRollData. secrets defaults to Item#isOwner.

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

        Additional options affecting the chat data generation

        • actionId: undefined | string

          The ID of an action on this item to generate chat data for, defaults to firstAction

        • chatcard: undefined | boolean

          Is this actually for chat card.

      Returns ChatData

      The chat data for this item (+action)

    • 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: {
            chatcard: undefined | boolean;
            data: undefined | object;
        }

        Item type dependant options for rendering the description.

        • chatcard: undefined | boolean

          Instruct template to render chat card in mind.

        • data: undefined | object

          Template data for rendering

      Returns string

      Full description.

    • Returns labels for this item

      Parameters

      • __namedParameters: {
            actionId: any;
            rollData: any;
        } = {}

        Additional options

        • actionId: any
        • rollData: any

      Returns Record<string, string>

      This item's labels

    • Parameters

      • linkData: any
      • extraData: boolean = false

      Returns Promise<undefined | null | Document<any, any, Metadata<any>> | ItemPF | {
          item: undefined | null | Document<any, any, Metadata<any>> | ItemPF;
          linkData: any;
      }>

    • Retrieve item referred to by a link in .system.links data

      Parameters

      • linkData: object = {}

        Link data

      Returns undefined | object | Item

      Linked item, undefined, or compendium index data

      Example

      const items = (item.system.links?.children ?? [])
      .map(link => item.getLinkedItemSync(link));
    • Parameters

      • type: any
      • extraData: boolean = false

      Returns Promise<(Document<any, any, Metadata<any>> | ItemPF | {
          item: undefined | null | Document<any, any, Metadata<any>> | ItemPF;
          linkData: any;
      })[]>

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

      Returns object[] | Item[]

      Linked items or their compendium index data

      Example

      const childItems = item.getLinkedItemsSync("children");
      
    • Returns {
          disabled: boolean;
          duration: {};
          flags: {
              pf1: {
                  origin: {
                      item: null | string;
                  };
              };
          };
          icon: null | string;
          label: null | string;
          origin: string;
      }

      • disabled: boolean
      • duration: {}
        • flags: {
              pf1: {
                  origin: {
                      item: null | string;
                  };
              };
          }
          • pf1: {
                origin: {
                    item: null | string;
                };
            }
            • origin: {
                  item: null | string;
              }
              • item: null | string
        • icon: null | string
        • label: null | string
        • origin: string
      • 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: Object

          The labels for this item.

        • props: string[]

          Additional property strings

        • rollData: object

          A rollData object to be used for checks

        Returns void

      • Returns the displayed value of an item according to multiple options

        Parameters

        • Optional options: {
              forceUnidentified: undefined | boolean;
              inLowestDenomination: undefined | boolean;
              recursive: undefined | boolean;
              sellValue: undefined | number;
          } = {}

          Various optional parameters affecting value calculations

          • forceUnidentified: undefined | boolean

            Override whether the value should use the unidentified price

          • inLowestDenomination: undefined | boolean

            Whether the value should be returned in the lowest denomination

          • recursive: undefined | boolean

            Whether the value of contained items should be included

          • sellValue: undefined | number

            The sell value multiplier

        Returns number

        The item's value

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

      • 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

        • __namedParameters: {
              noCreate: undefined | boolean;
          } = {}
          • noCreate: undefined | boolean

        Returns Promise<undefined | ActiveEffect>

      • Parameters

        • action: any
        • __namedParameters: {
              button: undefined | null;
              item: undefined | null;
          } = {}
          • button: undefined | null
          • item: undefined | null

        Returns Promise<undefined | boolean>

      Generated using TypeDoc