From cbad6be67825fda59c6acc6a3bc354eda62ec529 Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Mon, 8 Aug 2022 03:36:10 -0400 Subject: [PATCH] feat: update for foundry v10, fix process macro image --- .prettierrc.js | 2 +- module.json | 8 ++++---- packs/pf2e-pd-macros.db/process-persistent-damage.json | 2 +- src/module/item-sheet.ts | 9 ++------- src/module/persistent-effect.ts | 8 ++++---- types/src/module/item/base.d.ts | 1 + types/src/module/item/effect/data.d.ts | 1 + 7 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.prettierrc.js b/.prettierrc.js index 4578653..afc47b5 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,6 +1,6 @@ module.exports = { trailingComma: 'all', - printWidth: 100, + printWidth: 120, tabWidth: 4, useTabs: false, requirePragma: false, diff --git a/module.json b/module.json index f36cfcb..dedf53e 100644 --- a/module.json +++ b/module.json @@ -3,9 +3,9 @@ "title": "pf2e Persistent Damage", "description": "Macros that create effects to handle persistent damage", "author": "Supe", - "version": "0.9.3", - "compatibleCoreVersion": "9", - "minimumCoreVersion": "9", + "version": "0.10.0", + "compatibleCoreVersion": "10", + "minimumCoreVersion": "10", "minimumSystemVersion": "3.1.0", "type": "module", "system": ["pf2e"], @@ -38,5 +38,5 @@ ], "url": "https://github.com/CarlosFdez/pf2e-persistent-damage", "manifest": "https://github.com/CarlosFdez/pf2e-persistent-damage/releases/latest/download/module.json", - "download": "https://github.com/CarlosFdez/pf2e-persistent-damage/releases/download/v0.9.3/module.zip" + "download": "https://github.com/CarlosFdez/pf2e-persistent-damage/releases/download/v0.10.0/module.zip" } diff --git a/packs/pf2e-pd-macros.db/process-persistent-damage.json b/packs/pf2e-pd-macros.db/process-persistent-damage.json index d6d362a..cad1114 100644 --- a/packs/pf2e-pd-macros.db/process-persistent-damage.json +++ b/packs/pf2e-pd-macros.db/process-persistent-damage.json @@ -4,7 +4,7 @@ "author": "j8qxwRz5RJ4kkzp9", "command": "PF2EPersistentDamage.processPersistentDamage(canvas.tokens.controlled);", "flags": {}, - "img": "systems/pf2e/icons/conditions/persistentDamage.webp", + "img": "systems/pf2e/icons/conditions/persistent-damage.webp", "name": "Process Persistent Damage", "permission": { "default": 1 diff --git a/src/module/item-sheet.ts b/src/module/item-sheet.ts index 81c1b5c..cc563d9 100644 --- a/src/module/item-sheet.ts +++ b/src/module/item-sheet.ts @@ -6,7 +6,7 @@ export function overrideItemSheet() { // unfortunately....pf2e does not override the item default sheet const baseSheet = Items.registeredSheets.find( - (s: any) => s.name === "ItemSheetPF2e", + (s: any) => s.name === "EffectSheetPF2e", ) as unknown as typeof ItemSheet; function setDetailsIfPersistent(data: any) { @@ -23,13 +23,8 @@ const original = baseSheet.prototype.getData; baseSheet.prototype.getData = function (...args) { - // NOTE: As of this writing, getData() is becoming async. We need to be backwards compatible for a while though const data = original.bind(this)(...args); - if (data instanceof Promise) { - return data.then((data) => setDetailsIfPersistent(data)); - } else { - return setDetailsIfPersistent(data); - } + return data.then((data) => setDetailsIfPersistent(data)); }; console.log("PF2E Persistent | Registered Item Sheet Modification"); diff --git a/src/module/persistent-effect.ts b/src/module/persistent-effect.ts index 8991cd3..1ad0539 100644 --- a/src/module/persistent-effect.ts +++ b/src/module/persistent-effect.ts @@ -68,7 +68,7 @@ export function getPersistentData(itemData: { Hooks.on("preUpdateItem", (item: ItemPF2e, update: Partial) => { if (update?.flags?.persistent) { // Merge the persistent flags. This also "migrates" the flags. - const previous = item.data.flags?.persistent as PersistentData; + const previous = item.flags?.persistent as PersistentData; const persistent = getPersistentData({ flags: { persistent: mergeObject({ ...previous }, update.flags.persistent), @@ -101,7 +101,7 @@ export function createPersistentEffect(persistent: PersistentData): DeepPartial< return { type: "effect", name: createPersistentTitle(persistent), - data: { + system: { slug: `persistent-damage-${persistent.damageType}`, description: { value: "Persistent Damage from some source. Deals damage at the end of each turn and needs a check to remove.", @@ -114,8 +114,8 @@ export function createPersistentEffect(persistent: PersistentData): DeepPartial< }, rules: [], tokenIcon: { - show: true - } + show: true, + }, }, flags: { persistent }, img: typeImages[persistent.damageType], diff --git a/types/src/module/item/base.d.ts b/types/src/module/item/base.d.ts index fef40a2..70ec976 100644 --- a/types/src/module/item/base.d.ts +++ b/types/src/module/item/base.d.ts @@ -131,6 +131,7 @@ export declare class ItemPF2e extends Item { } export interface ItemPF2e { readonly data: ItemDataPF2e; + flags: ItemDataPF2e["flags"]; // v10 shim, will be replaced when types update readonly parent: ActorPF2e | null; readonly _sheet: ItemSheetPF2e; } diff --git a/types/src/module/item/effect/data.d.ts b/types/src/module/item/effect/data.d.ts index afdefd3..b242950 100644 --- a/types/src/module/item/effect/data.d.ts +++ b/types/src/module/item/effect/data.d.ts @@ -9,6 +9,7 @@ export declare class EffectData extends BaseNonPhysicalItemData { export interface EffectData extends Omit { type: EffectSource["type"]; data: EffectSource["data"]; + system: EffectSource["data"]; // v10 shim, later this will be removed when the types are replaced readonly _source: EffectSource; } export interface EffectSystemData extends ItemSystemData {