Override and extend the basic :class:Item implementation

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

Properties

_memoryVariables: undefined | null | {}

Type declaration

    actions: undefined | Map<string, ItemAction>
    changes: undefined | Collection<any>
    scriptCalls: any
    system: Readonly<{
        hasIdentifier: false;
        isPhysical: boolean;
    }> = ...

    Type declaration

    • hasIdentifier: false
    • isPhysical: boolean

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

    Accessors

    • get addonMaterial(): null | string[]
    • The item's material addons, or null if the item has no subtype

      Returns null | string[]

    • get alignments(): null | string
    • The item's alignment attributes, or null if the item has no alignment attributes

      Returns null | string

    • 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 memoryVariables(): string[]
    • Returns string[]

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

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

      Returns null | string

    • 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 totalDurationSeconds(): null | number
    • Returns total duration in seconds or null.

      Returns null | number

      Seconds or null.

    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

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

    • Test if specified link can be created.

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

        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.

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

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

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

        Parameters

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

          Item type dependant options for rendering the description.

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

        Returns string

        • Full description.
      • Parameters

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

        Returns {
            data: any;
            label: {
                descriptors: string;
                school: any;
                subschool: any;
            };
        }

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

          Link data

        • Optional extraData: boolean = false

          Deprecated: Include link data in return value

        Returns null | Item

        • Linked item if it exists

        Deprecated

      • 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

        Deprecated

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

        Throws

        • If item type does not support proficiency.
      • Determines the starting data for an ActiveEffect based off this item.

        Returns {
            disabled: boolean;
            duration: {};
            icon: null | string;
            name: null | string;
            origin: any;
        }

        • disabled: boolean
        • duration: {}
          • icon: null | string
          • name: null | string
          • origin: any
        • Parameters

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

          Returns any[]

        • 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

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

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

        • 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;
                event: any;
                item: undefined | null;
            } = {}
            • button: undefined | null
            • event: any
            • item: undefined | null

          Returns Promise<undefined | boolean>

        • 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

        • Parameters

          • itemData: object

            A spell item's data.

          Returns number[]

          An array containing the spell level and caster level.

        • Convert spell into a consumable item.

          Parameters

          • origData: object

            Spell item data

          • type: "wand" | "scroll" | "potion"

            Consumable type

          • Optional options: {
                spellType: undefined | string;
            } = {}

            Additional options

            • spellType: undefined | string

              Spell type

          Returns null | object

          • Item data for appropriate consumable, or null if dialog option was used and it was cancelled.
        • Open Consumable conversion dialog.

          Automatically calls this.toConsumable as appropriate.

          Parameters

          • itemData: object

            Spell item data

          • Optional options: {
                actor: undefined | object;
                allowSpell: undefined | boolean;
                spellType: undefined | string;
            } = {}

            Additional options

            • actor: undefined | object

              The actor the consumable is being created on.

            • allowSpell: undefined | boolean

              Allow spell creation

            • spellType: undefined | string

              Spell type

          Returns Promise<null | false | object>

          • Returns null if cancelled, false if no conversion is to take place, or converted data.

        Generated using TypeDoc