60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
// SPDX-FileCopyrightText: 2021 Gesina Schwalbe
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import { getGame } from "../../utils/utils";
|
|
|
|
import type { ItemType } from "./item-data-source";
|
|
|
|
declare global {
|
|
interface DocumentClassConfig {
|
|
Item: typeof DS4Item;
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
namespace Hooks {
|
|
interface StaticCallbacks {
|
|
"ds4.rollItem": (item: DS4Item) => void;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* The Item class for DS4
|
|
*/
|
|
export class DS4Item extends Item {
|
|
/** An object that tracks the changes to the data model which were applied by active effects */
|
|
overrides: Record<string, unknown> = {};
|
|
|
|
override prepareDerivedData(): void {
|
|
this.data.data.rollable = false;
|
|
}
|
|
|
|
isNonEquippedEuipable(): boolean {
|
|
return "equipped" in this.data.data && !this.data.data.equipped;
|
|
}
|
|
|
|
/**
|
|
* The number of times that active effect changes originating from this item should be applied.
|
|
*/
|
|
get activeEffectFactor(): number | undefined {
|
|
return 1;
|
|
}
|
|
|
|
/**
|
|
* The list of item types that are rollable.
|
|
*/
|
|
static get rollableItemTypes(): ItemType[] {
|
|
return ["weapon", "spell"];
|
|
}
|
|
|
|
/**
|
|
* Roll a check for an action with this item.
|
|
* @param options - Additional options to customize the roll
|
|
*/
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
async roll(options: { speaker?: { token?: TokenDocument; alias?: string } } = {}): Promise<void> {
|
|
throw new Error(getGame().i18n.format("DS4.ErrorRollingForItemTypeNotPossible", { type: this.data.type }));
|
|
}
|
|
}
|