diff --git a/src/module/entities/TwodsixItem.ts b/src/module/entities/TwodsixItem.ts index f326d6ae1..3ecb635c5 100644 --- a/src/module/entities/TwodsixItem.ts +++ b/src/module/entities/TwodsixItem.ts @@ -6,15 +6,17 @@ import { TwodsixDiceRoll } from "../utils/TwodsixDiceRoll"; import { TwodsixRollSettings } from "../utils/TwodsixRollSettings"; import TwodsixActor from "./TwodsixActor"; import { DICE_ROLL_MODES } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/constants.mjs"; +import { Consumable, Gear, Skills, UsesConsumables, Weapon } from "../../types/template"; import { ItemDataConstructorData } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/itemData"; export default class TwodsixItem extends Item { + public static async create(data: ItemDataConstructorData, options?: DocumentModificationContext): Promise { const item = await super.create(data, options) as unknown as TwodsixItem; item?.setFlag('twodsix', 'newItem', true); if (item?.data.type === 'weapon' && (item.data.img === "" || item.data.img === foundry.data.ItemData.DEFAULT_ICON)) { - await item.update({'img': 'systems/twodsix/assets/icons/default_weapon.png'}); + await item.update({ 'img': 'systems/twodsix/assets/icons/default_weapon.png' }); } return item; @@ -65,7 +67,7 @@ export default class TwodsixItem extends Item { if (gear.consumables.includes(consumableId)) { console.error(`Twodsix | Consumable already exists for item ${this.id}`); } else { - await this.update({"data.consumables": gear.consumables.concat(consumableId)}, {}); + await this.update({ "data.consumables": gear.consumables.concat(consumableId) }, {}); } } else { ui.notifications.error(`Twodsix | Consumable can't be added to item ${this.id}`); @@ -76,7 +78,7 @@ export default class TwodsixItem extends Item { const updatedConsumables = gear.consumables.filter((cId: string) => { return (cId !== consumableId && cId !== null && this.actor?.items.get(cId) !== undefined); }); - const updateData = {"data.consumables": updatedConsumables}; + const updateData = { "data.consumables": updatedConsumables }; if (gear.useConsumableForAttack === consumableId) { updateData["data.useConsumableForAttack"] = ""; } @@ -107,7 +109,7 @@ export default class TwodsixItem extends Item { diceModifier: undefined }; if (skill) { - tmpSettings = {characteristic: (skill.data.data).characteristic || 'NONE'}; + tmpSettings = { characteristic: (skill.data.data).characteristic || 'NONE' }; } let usedAmmo = 1; @@ -228,7 +230,7 @@ export default class TwodsixItem extends Item { const damageFormula = weapon.damage + (bonusDamage ? "+" + bonusDamage : ""); const damageRoll = new Roll(damageFormula, this.actor?.data.data); - const damage: Roll = await damageRoll.evaluate({async: true}); // async: true will be default in foundry 0.10 + const damage: Roll = await damageRoll.evaluate({ async: true }); // async: true will be default in foundry 0.10 if (showInChat) { const results = damage.terms[0]["results"]; const contentData = { @@ -246,13 +248,13 @@ export default class TwodsixItem extends Item { } ); await damage.toMessage({ - speaker: this.actor ? ChatMessage.getSpeaker({actor: this.actor}) : "???", + speaker: this.actor ? ChatMessage.getSpeaker({ actor: this.actor }) : "???", content: html, flags: { "core.canPopout": true, "transfer": transfer } - }, {rollMode: rollMode}); + }, { rollMode: rollMode }); } return damage; } @@ -297,9 +299,9 @@ export default class TwodsixItem extends Item { public async consume(quantity: number): Promise { const consumableLeft = (this.data.data).currentCount - quantity; if (consumableLeft >= 0) { - await this.update({"data.currentCount": consumableLeft}, {}); + await this.update({ "data.currentCount": consumableLeft }, {}); } else { - throw {name: 'NoAmmoError'}; + throw { name: 'NoAmmoError' }; } } @@ -311,7 +313,7 @@ export default class TwodsixItem extends Item { "data.currentCount": consumable.max }, {}); } else { - throw {name: 'TooLowQuantityError'}; + throw { name: 'TooLowQuantityError' }; } } }