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 slotCost(): number
    • Number of slots the spell takes to prepare.

      Quick access to .system.slotCost with additional considerations such as at-will toggle.

      Defaults to 1 if the data is not present, 0 if the spell is at-will.

      Returns number

    • get spellDescriptionData(): {
          data: any;
          label: {
              school: any;
              subschool: any;
              types: string;
          };
      }
    • Returns {
          data: any;
          label: {
              school: any;
              subschool: any;
              types: string;
          };
      }

      • data: any
      • label: {
            school: any;
            subschool: any;
            types: string;
        }
        • school: any
        • subschool: any
        • types: string
    • 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

    • Protected

      Assign spell level according to spellbook class if present.

      Parameters

      • data: object

        Item data

      • options: object

        Creation options

      Returns void

    • Private

      Constrains and alters prepared slot updates to result in meaningful end results.

      Parameters

      • changed: object

        Change data in pre-update

      Returns void

    • Add charges to the spell or its relevant resource pool (spell points or spontaneous spells).

      Parameters

      • value: number

        Number of charges to add

      • Optional data: object = null

        Additional data to pass to the update

      Returns Promise<void | ItemSpellPF>

      Updated document or undefined if no update is possible or required.

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

      Parameters

      • __namedParameters: {
            chatcard: undefined | boolean;
            data: undefined | {};
        } = {}

        Item type dependant options for rendering the description.

        • chatcard: undefined | boolean
        • data: undefined | {}

      Returns string

      Full description.

    • Returns the spell's effective caster level, after counting in offsets.

      Parameters

      • Optional bonus: number = 0

        Another bonus to account for.

      Returns number

      The spell's effective caster level.

    • Returns the spell's effective spell level, after counting in offsets.

      Parameters

      • Optional bonus: number = 0

        Another bonus to account for.

      Returns number

      The spell's effective spell level.

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

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

        • labels: any

          The labels for this item.

        • props: any

          Additional property strings

        • rollData: any

          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

      • Recharges item's uses, if any.

        Parameters

        • __namedParameters: {
              commit: undefined | boolean;
              context: any;
              exact: undefined | boolean;
              maximize: undefined | boolean;
              period: undefined | string;
              rollData: any;
              value: any;
          } = {}

          Options

          • commit: undefined | boolean
          • context: any
          • exact: undefined | boolean
          • maximize: undefined | boolean
          • period: undefined | string
          • rollData: any
          • value: any

        Returns Promise<undefined | {
            system: {
                preparation: {};
            };
        }>

        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.

      • Set item's active state.

        Parameters

        • active: boolean

          Active state

        • context: object

          Optional update context

        Returns Promise<ItemSpellPF>

        Update promise if item type supports the operation.

        Abstract

        Throws

        Error 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

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

        Returns Promise<undefined | boolean>

      • Parameters

        • itemData: object

          A spell item's data.

        Returns number[]

        An array containing the spell level and caster level.

      • Parameters

        • origData: any
        • type: any

        Returns Promise<PropertiesToSource<ItemDataBaseProperties>>

      Generated using TypeDoc