From 58bde07291f3f6389443decc37e274afb43ba712 Mon Sep 17 00:00:00 2001 From: PwQt Date: Thu, 25 Jul 2024 17:40:09 +0200 Subject: [PATCH] 3.3.x compatibility --- src/module.json | 8 +- .../AbstractMagicItemEntry.js | 2 +- .../magic-item-entry/MagicItemTable.js | 2 +- src/scripts/magic-item-helpers.js | 2 +- .../AbstractOwnedMagicItemEntry.js | 2 +- .../OwnedMagicItemFeat.js | 4 +- .../OwnedMagicItemSpell.js | 10 +- src/scripts/magic-item/MagicItem.js | 4 +- src/scripts/magicItemtab.js | 2 +- src/templates/magic-item-feat-sheet-v2.hbs | 118 +++++++++--------- src/templates/magic-item-spell-sheet-v2.hbs | 118 +++++++++--------- 11 files changed, 139 insertions(+), 133 deletions(-) diff --git a/src/module.json b/src/module.json index 49b8d5a..dfc46a4 100644 --- a/src/module.json +++ b/src/module.json @@ -5,7 +5,7 @@ "version": "4.1.6", "compatibility": { "minimum": 11, - "verified": 12.327, + "verified": 12.330, "maximum": 12.999 }, "authors": [ @@ -149,9 +149,9 @@ "type": "system", "manifest": "https://raw.githubusercontent.com/foundryvtt/dnd5e/master/system.json", "compatibility": { - "minimum": "3.0.0", - "verified": "3.2.1", - "maximum": "3.2.999" + "minimum": "3.3.0", + "verified": "3.3.1", + "maximum": "3.3.999" } } ], diff --git a/src/scripts/magic-item-entry/AbstractMagicItemEntry.js b/src/scripts/magic-item-entry/AbstractMagicItemEntry.js index f66dc80..aa4955d 100644 --- a/src/scripts/magic-item-entry/AbstractMagicItemEntry.js +++ b/src/scripts/magic-item-entry/AbstractMagicItemEntry.js @@ -5,7 +5,7 @@ import { MagicItemHelpers } from "../magic-item-helpers"; export class AbstractMagicItemEntry { constructor(data) { - mergeObject(this, data); + foundry.utils.mergeObject(this, data); // Patch retrocompatbility if (this.pack?.startsWith("magic-items")) { this.pack = this.pack.replace("magic-items-2.", `${CONSTANTS.MODULE_ID}.`); diff --git a/src/scripts/magic-item-entry/MagicItemTable.js b/src/scripts/magic-item-entry/MagicItemTable.js index 835d9f4..bc535a0 100644 --- a/src/scripts/magic-item-entry/MagicItemTable.js +++ b/src/scripts/magic-item-entry/MagicItemTable.js @@ -29,7 +29,7 @@ export class MagicItemTable extends AbstractMagicItemEntry { if (!game.modules.get("ready-set-roll-5e")?.active) { ChatMessage.create( - mergeObject(chatData, { + foundry.utils.mergeObject(chatData, { "flags.dnd5e.itemData": item, }), ); diff --git a/src/scripts/magic-item-helpers.js b/src/scripts/magic-item-helpers.js index c45b4c0..8816f26 100644 --- a/src/scripts/magic-item-helpers.js +++ b/src/scripts/magic-item-helpers.js @@ -4,7 +4,7 @@ import { isRealNumber, isEmptyObject } from "./lib/lib.js"; export class MagicItemHelpers { static isUsingNew5eSheet(sheet) { - return sheet?.constructor?.name === "ActorSheet5eCharacter2"; + return sheet?.constructor?.name === "ActorSheet5eCharacter2" || sheet?.constructor?.name === "ActorSheet5eNPC2"; } static isMidiItemEffectWorkflowOn() { diff --git a/src/scripts/magic-item-owned-entry/AbstractOwnedMagicItemEntry.js b/src/scripts/magic-item-owned-entry/AbstractOwnedMagicItemEntry.js index 7696592..0f0e804 100644 --- a/src/scripts/magic-item-owned-entry/AbstractOwnedMagicItemEntry.js +++ b/src/scripts/magic-item-owned-entry/AbstractOwnedMagicItemEntry.js @@ -195,7 +195,7 @@ export class AbstractOwnedMagicItemEntry { existingEffect.update({ disabled: !existingEffect.disabled }); return; } - effect = mergeObject(effect, { + effect = foundry.utils.mergeObject(effect, { disabled: false, transfer: false, origin: item.uuid, diff --git a/src/scripts/magic-item-owned-entry/OwnedMagicItemFeat.js b/src/scripts/magic-item-owned-entry/OwnedMagicItemFeat.js index 1967dc4..59b9c63 100644 --- a/src/scripts/magic-item-owned-entry/OwnedMagicItemFeat.js +++ b/src/scripts/magic-item-owned-entry/OwnedMagicItemFeat.js @@ -8,11 +8,11 @@ export class OwnedMagicItemFeat extends AbstractOwnedMagicItemEntry { if (!this.ownedItem) { let data = await this.item.data(); - data = mergeObject(data, { + data = foundry.utils.mergeObject(data, { "system.uses": null, }); - data = mergeObject(data, { + data = foundry.utils.mergeObject(data, { "flags.core": { sourceId: this.item.uuid, }, diff --git a/src/scripts/magic-item-owned-entry/OwnedMagicItemSpell.js b/src/scripts/magic-item-owned-entry/OwnedMagicItemSpell.js index 1f0fc02..dd4bb04 100644 --- a/src/scripts/magic-item-owned-entry/OwnedMagicItemSpell.js +++ b/src/scripts/magic-item-owned-entry/OwnedMagicItemSpell.js @@ -12,29 +12,29 @@ export class OwnedMagicItemSpell extends AbstractOwnedMagicItemEntry { let data = await this.item.data(); if (typeof data.system.save.scaling === "undefined") { - data = mergeObject(data, { + data = foundry.utils.mergeObject(data, { "system.save.scaling": "spell", }); } if (this.item.flatDc) { - data = mergeObject(data, { + data = foundry.utils.mergeObject(data, { "system.save.scaling": "flat", "system.save.dc": this.item.dc, }); } if (!MagicItemHelpers.isLevelScalingSettingOn()) { - data = mergeObject(data, { + data = foundry.utils.mergeObject(data, { "system.scaling": "none", }); } - data = mergeObject(data, { + data = foundry.utils.mergeObject(data, { "system.preparation": { mode: "magicitems" }, }); - data = mergeObject(data, { + data = foundry.utils.mergeObject(data, { "flags.core": { sourceId: this.item.uuid, }, diff --git a/src/scripts/magic-item/MagicItem.js b/src/scripts/magic-item/MagicItem.js index 38b3dce..b3d6567 100644 --- a/src/scripts/magic-item/MagicItem.js +++ b/src/scripts/magic-item/MagicItem.js @@ -7,7 +7,7 @@ import { NumberUtils } from "../utils/number.js"; export class MagicItem { constructor(flagsData) { - const data = mergeObject(this.defaultData(), flagsData || {}, { inplace: false }); + const data = foundry.utils.mergeObject(this.defaultData(), flagsData || {}, { inplace: false }); this.enabled = data.enabled; this.equipped = data.equipped; @@ -182,7 +182,7 @@ export class MagicItem { } clear() { - mergeObject(this, this.defaultData()); + foundry.utils.mergeObject(this, this.defaultData()); this.spells = []; this.feats = []; this.tables = []; diff --git a/src/scripts/magicItemtab.js b/src/scripts/magicItemtab.js index 9fdc455..2bd47d1 100644 --- a/src/scripts/magicItemtab.js +++ b/src/scripts/magicItemtab.js @@ -168,7 +168,7 @@ export class MagicItemTab { if (entity && magicItem.compatible(entity)) { magicItem.addEntity(entity, pack); - item.update({ + await item.update({ flags: { [CONSTANTS.MODULE_ID]: magicItem.serializeData(), }, diff --git a/src/templates/magic-item-feat-sheet-v2.hbs b/src/templates/magic-item-feat-sheet-v2.hbs index 1536b09..158aaee 100644 --- a/src/templates/magic-item-feat-sheet-v2.hbs +++ b/src/templates/magic-item-feat-sheet-v2.hbs @@ -40,37 +40,38 @@ data-item-id="{{feat.id}}" data-item-uuid="{{feat.uuid}}" data-entry-id="{{../id}}" - draggable="true" - > -
- {{feat.name}} -
- {{ feat.displayName }} - - {{ feat.featAction }} - -
-
-
- {{#if ../chargesPerSpell}} -
- {{#if ../sheetEditable}} - - / - - {{else}} - {{feat.uses}} / {{../charges}} + draggable="true"> +
+
+ {{feat.name}} +
+ {{ feat.displayName }} + + {{ feat.featAction }} + +
+
+
+ {{#if ../chargesPerSpell}} +
+ {{#if ../sheetEditable}} + + / + + {{else}} + {{feat.uses}} / {{../charges}} + {{/if}} +
+
-
{{/if}} -
-
-
- {{/if}} -
- {{feat.consumptionLabel}} +
+ {{feat.consumptionLabel}} +
{{/each}} @@ -82,36 +83,37 @@ data-item-id="{{table.id}}" data-item-uuid="{{table.uuid}}" data-entry-id="{{../id}}" - draggable="true" - > -
- {{table.name}} -
- {{ table.displayName }} - -
-
-
- {{#if ../chargesPerSpell}} -
- {{#if ../sheetEditable}} - - / - - {{else}} - {{feats.uses}} / {{../charges}} + draggable="true"> +
+
+ {{table.name}} +
+ {{ table.displayName }} + +
+
+
+ {{#if ../chargesPerSpell}} +
+ {{#if ../sheetEditable}} + + / + + {{else}} + {{feats.uses}} / {{../charges}} + {{/if}} +
+
-
{{/if}} +
+ {{table.consumption}} +
-
-
- {{/if}} -
- {{table.consumption}} -
{{/each}} {{/if}} diff --git a/src/templates/magic-item-spell-sheet-v2.hbs b/src/templates/magic-item-spell-sheet-v2.hbs index 94bb82e..4951d66 100644 --- a/src/templates/magic-item-spell-sheet-v2.hbs +++ b/src/templates/magic-item-spell-sheet-v2.hbs @@ -41,44 +41,46 @@ data-entry-id="{{../id}}" draggable="true" > -
- {{spell.name}} -
- {{ spell.displayName }} - {{ spell.componentsVSM }} +
+
+ {{spell.name}} +
+ {{ spell.displayName }} + {{ spell.componentsVSM }} +
+
+ {{#each spell.componentsALL}} + {{#if tag}} + + + + {{/if}} + {{/each}} +
-
- {{#each spell.componentsALL}} - {{#if tag}} - - - + {{#if ../chargesPerSpell}} +
+ {{#if ../sheetEditable}} + + / + + {{else}} + {{spell.uses}} / {{../charges}} {{/if}} - {{/each}}
-
- {{#if ../chargesPerSpell}} -
- {{#if ../sheetEditable}} - - / - {{else}} - {{spell.uses}} / {{../charges}} +
-
{{/if}} +
-
+
{{spell.level}}
+
{{spell.consumption}}
+
{{spell.canUpcastLabel}}
- {{else}} -
-
- {{/if}} -
-
-
{{spell.level}}
-
{{spell.consumption}}
-
{{spell.canUpcastLabel}}
{{/each}} {{#if hasTableAsSpells}} {{#each tableAsSpells as |table|}} @@ -87,35 +89,37 @@ data-item-id="{{table.id}}" data-item-uuid="{{table.uuid}}" draggable="true"> -
- {{table.name}} -
- {{ table.displayName }} - {{localize "MAGICITEMS.RandomResult"}} +
+
+ {{table.name}} +
+ {{ table.displayName }} + {{localize "MAGICITEMS.RandomResult"}} +
+
+ {{#if ../chargesPerSpell}} +
+ {{#if ../sheetEditable}} + + / + + {{else}} + {{spell.uses}} / {{../charges}} + {{/if}}
-
- {{#if ../chargesPerSpell}} -
- {{#if ../sheetEditable}} - - / - {{else}} - {{spell.uses}} / {{../charges}} +
-
{{/if}} +
-
+
-
+
{{table.consumption}}
+
-
- {{else}} -
-
- {{/if}} -
-
-
-
-
{{table.consumption}}
-
-
{{/each}} {{/if}}