Skip to content

Commit

Permalink
feat: update for foundry v10, fix process macro image
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosFdez committed Aug 8, 2022
1 parent 9ec89a7 commit cbad6be
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
trailingComma: 'all',
printWidth: 100,
printWidth: 120,
tabWidth: 4,
useTabs: false,
requirePragma: false,
Expand Down
8 changes: 4 additions & 4 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packs/pf2e-pd-macros.db/process-persistent-damage.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions src/module/item-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions src/module/persistent-effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function getPersistentData(itemData: {
Hooks.on("preUpdateItem", (item: ItemPF2e, update: Partial<ItemDataPF2e>) => {
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),
Expand Down Expand Up @@ -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.",
Expand All @@ -114,8 +114,8 @@ export function createPersistentEffect(persistent: PersistentData): DeepPartial<
},
rules: [],
tokenIcon: {
show: true
}
show: true,
},
},
flags: { persistent },
img: typeImages[persistent.damageType],
Expand Down
1 change: 1 addition & 0 deletions types/src/module/item/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export declare class ItemPF2e extends Item<ActorPF2e> {
}
export interface ItemPF2e {
readonly data: ItemDataPF2e;
flags: ItemDataPF2e["flags"]; // v10 shim, will be replaced when types update
readonly parent: ActorPF2e | null;
readonly _sheet: ItemSheetPF2e<this>;
}
Expand Down
1 change: 1 addition & 0 deletions types/src/module/item/effect/data.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export declare class EffectData extends BaseNonPhysicalItemData<EffectPF2e> {
export interface EffectData extends Omit<EffectSource, "_id" | "effects"> {
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 {
Expand Down

0 comments on commit cbad6be

Please sign in to comment.