Skip to content

Commit

Permalink
3.3.x compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
PwQt committed Jul 25, 2024
1 parent 5c4a061 commit 58bde07
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 133 deletions.
8 changes: 4 additions & 4 deletions src/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "4.1.6",
"compatibility": {
"minimum": 11,
"verified": 12.327,
"verified": 12.330,
"maximum": 12.999
},
"authors": [
Expand Down Expand Up @@ -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"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/magic-item-entry/AbstractMagicItemEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}.`);
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/magic-item-entry/MagicItemTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
);
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/magic-item-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/magic-item-owned-entry/OwnedMagicItemFeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
10 changes: 5 additions & 5 deletions src/scripts/magic-item-owned-entry/OwnedMagicItemSpell.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/magic-item/MagicItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -182,7 +182,7 @@ export class MagicItem {
}

clear() {
mergeObject(this, this.defaultData());
foundry.utils.mergeObject(this, this.defaultData());
this.spells = [];
this.feats = [];
this.tables = [];
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/magicItemtab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand Down
118 changes: 60 additions & 58 deletions src/templates/magic-item-feat-sheet-v2.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,38 @@
data-item-id="{{feat.id}}"
data-item-uuid="{{feat.uuid}}"
data-entry-id="{{../id}}"
draggable="true"
>
<div class="item-name item-action item-tooltip rollable" role="button" aria-label="{{feat.displayName}}">
<img class="item-image gold-icon magic-item-image" src="{{feat.img}}" alt="{{feat.name}}">
<div class="name name-stacked">
<span class="title">{{ feat.displayName }}</span>
<span class="feat-subtitle subtitle">
{{ feat.featAction }}
</span>
</div>
<div class="tags"></div>
</div>
{{#if ../chargesPerSpell}}
<div class="item-detail spell-slots">
{{#if ../sheetEditable}}
<input
data-item-uses="magicitems.{{../id}}.{{feat.id}}.uses"
type="text"
value="{{feat.uses}}"
placeholder="0"
/>
<span class="sep"> / </span>
<input type="text" value="{{../charges}}" placeholder="0" />
{{else}}
{{feat.uses}} / {{../charges}}
draggable="true">
<div class="item-row">
<div class="item-name item-action item-tooltip rollable" role="button" aria-label="{{feat.displayName}}">
<img class="item-image gold-icon magic-item-image" src="{{feat.img}}" alt="{{feat.name}}">
<div class="name name-stacked">
<span class="title">{{ feat.displayName }}</span>
<span class="feat-subtitle subtitle">
{{ feat.featAction }}
</span>
</div>
<div class="tags"></div>
</div>
{{#if ../chargesPerSpell}}
<div class="item-detail spell-slots">
{{#if ../sheetEditable}}
<input
data-item-uses="magicitems.{{../id}}.{{feat.id}}.uses"
type="text"
value="{{feat.uses}}"
placeholder="0"
/>
<span class="sep"> / </span>
<input type="text" value="{{../charges}}" placeholder="0" />
{{else}}
{{feat.uses}} / {{../charges}}
{{/if}}
</div>
<div class="item-detail spell-rechargeable">-</div>
{{/if}}
</div>
<div class="item-detail spell-rechargeable">-</div>
{{/if}}
<div class="item-detail feat-consumption">
<span class="condensed">{{feat.consumptionLabel}}</span>
<div class="item-detail feat-consumption">
<span class="condensed">{{feat.consumptionLabel}}</span>
</div>
</div>
</li>
{{/each}}
Expand All @@ -82,36 +83,37 @@
data-item-id="{{table.id}}"
data-item-uuid="{{table.uuid}}"
data-entry-id="{{../id}}"
draggable="true"
>
<div class="item-name item-action item-tooltip rollable" role="button" aria-label="{{table.displayName}}">
<img class="item-image gold-icon magic-item-image" src="{{table.img}}" alt="{{table.name}}">
<div class="name name-stacked">
<span class="title">{{ table.displayName }}</span>
<span class="subtitle"></span>
</div>
<div class="tags"></div>
</div>
{{#if ../chargesPerSpell}}
<div class="item-detail spell-slots">
{{#if ../sheetEditable}}
<input
data-item-uses="magicitems.{{../id}}.{{table.id}}.uses"
type="text"
value="{{table.uses}}"
placeholder="0"
/>
<span class="sep"> / </span>
<input type="text" value="{{../charges}}" placeholder="0" />
{{else}}
{{feats.uses}} / {{../charges}}
draggable="true">
<div class="item-row">
<div class="item-name item-action item-tooltip rollable" role="button" aria-label="{{table.displayName}}">
<img class="item-image gold-icon magic-item-image" src="{{table.img}}" alt="{{table.name}}">
<div class="name name-stacked">
<span class="title">{{ table.displayName }}</span>
<span class="subtitle"></span>
</div>
<div class="tags"></div>
</div>
{{#if ../chargesPerSpell}}
<div class="item-detail spell-slots">
{{#if ../sheetEditable}}
<input
data-item-uses="magicitems.{{../id}}.{{table.id}}.uses"
type="text"
value="{{table.uses}}"
placeholder="0"
/>
<span class="sep"> / </span>
<input type="text" value="{{../charges}}" placeholder="0" />
{{else}}
{{feats.uses}} / {{../charges}}
{{/if}}
</div>
<div class="item-detail spell-rechargeable">-</div>
{{/if}}
<div class="item-detail feat-consumption">
<span class="condensed">{{table.consumption}}</span>
</div>
</div>
<div class="item-detail spell-rechargeable">-</div>
{{/if}}
<div class="item-detail feat-consumption">
<span class="condensed">{{table.consumption}}</span>
</div>
</li>
{{/each}} {{/if}}
</ol>
Expand Down
Loading

0 comments on commit 58bde07

Please sign in to comment.