Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
Updates to 0.8.x compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Rughalt committed May 2, 2021
1 parent e9adf60 commit 85e0866
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
13 changes: 8 additions & 5 deletions module/item/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ export class ItemPF extends Item {
data["data.weight"] = this.data.data.weight * weightChange;
}


console.log("D35E Item Update", data)
if (data["data.convertedWeight"]) {
const conversion = game.settings.get("D35E", "units") === "metric" ? 2 : 1;
data["data.weight"] = data["data.convertedWeight"] * conversion;
Expand Down Expand Up @@ -634,15 +634,18 @@ export class ItemPF extends Item {

this._updateMaxUses(data, {srcData: srcData});

console.log("Item DATA", flattenObject(this.data), data)
const diff = diffObject(flattenObject(this.data), data);
console.log("Item DIFF", diff, flattenObject(this.data), data)
let updatedItem = null;
if (Object.keys(diff).length) {
await super.update(diff, options);
updatedItem = await super.update(diff, options);
}

if (this.actor !== null)
this.actor.refresh(options); //We do not want to update actor again if we are in first update loop
// if (this.actor !== null)
// await this.actor.refresh(options); //We do not want to update actor again if we are in first update loop

return false;
return Promise.resolve(updatedItem ? updatedItem : this);
}

_updateAlignmentEnhancement(data, enhancements, type, srcData) {
Expand Down
16 changes: 9 additions & 7 deletions module/item/sheets/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,8 @@ export class ItemSheetPF extends ItemSheet {
formData['data.container'] = "None"
formData['data.containerWeightless'] = false
}

console.log("IM IN _UPDATE OBJECT FIXING THINGS", formData)
return super._updateObject(event, formData);
}

Expand Down Expand Up @@ -1247,8 +1249,8 @@ export class ItemSheetPF extends ItemSheet {
// Add new change
if (a.classList.contains("add-change")) {
//await this._onSubmit(event); // Submit any unsaved changes
const changes = this.item.data.data.changes || [];
return this.item.update({"data.changes": changes.concat([["", "", "", "", 0]])});
let _changes = duplicate(this.item.data.data.changes) || [];
return this.item.update({"data.changes": _changes.concat([["", "", "", "", 0]])});
}

// Remove a change
Expand All @@ -1268,7 +1270,7 @@ export class ItemSheetPF extends ItemSheet {
// Add new change
if (a.classList.contains("add-change")) {
//await this._onSubmit(event); // Submit any unsaved changes
const changes = this.item.data.data.combatChanges || [];
const changes = duplicate(this.item.data.data.combatChanges) || [];
// Combat Changes are
return this.item.update({"data.combatChanges": changes.concat([["", "", "", "", "", ""]])});
}
Expand All @@ -1290,7 +1292,7 @@ export class ItemSheetPF extends ItemSheet {
// Add new change
if (a.classList.contains("add-change")) {
//await this._onSubmit(event); // Submit any unsaved changes
const changes = this.item.data.data.requirements || [];
const changes = duplicate(this.item.data.data.requirements) || [];
// Combat Changes are
return this.item.update({"data.requirements": changes.concat([["", "", ""]])});
}
Expand All @@ -1312,7 +1314,7 @@ export class ItemSheetPF extends ItemSheet {
// Add new change
if (a.classList.contains("add-change")) {
//await this._onSubmit(event); // Submit any unsaved changes
const changes = this.item.data.data.resistances || [];
const changes = duplicate(this.item.data.data.resistances) || [];
// Combat Changes are
return this.item.update({"data.resistances": changes.concat([["", "", false, false, false]])});
}
Expand All @@ -1334,7 +1336,7 @@ export class ItemSheetPF extends ItemSheet {
// Add new change
if (a.classList.contains("add-change")) {
//await this._onSubmit(event); // Submit any unsaved changes
const changes = this.item.data.data.damageReduction || [];
const changes = duplicate(this.item.data.data.damageReduction) || [];
// Combat Changes are
return this.item.update({"data.damageReduction": changes.concat([["", "", false]])});
}
Expand All @@ -1356,7 +1358,7 @@ export class ItemSheetPF extends ItemSheet {
// Add new note
if (a.classList.contains("add-note")) {
//await this._onSubmit(event); // Submit any unsaved changes
const contextNotes = this.item.data.data.contextNotes || [];
const contextNotes = duplicate(this.item.data.data.contextNotes) || [];
return this.item.update({"data.contextNotes": contextNotes.concat([["", "", "", 0]])});
}

Expand Down

0 comments on commit 85e0866

Please sign in to comment.