Update the preUpdate handling to not block the entire update, bringing it more inline with Armour/Shield
This commit is contained in:
parent
f29ab8bdaa
commit
08278655dc
1 changed files with 10 additions and 8 deletions
|
|
@ -67,19 +67,21 @@ export class WeaponData extends CommonItemData {
|
||||||
*/
|
*/
|
||||||
async _preUpdate(changes, options, user) {
|
async _preUpdate(changes, options, user) {
|
||||||
if (options.force && game.settings.get(`ripcrypt`, `devMode`)) { return };
|
if (options.force && game.settings.get(`ripcrypt`, `devMode`)) { return };
|
||||||
|
|
||||||
|
const diff = diffObject(this.parent._source, changes);
|
||||||
let valid = super._preUpdate(changes, options, user);
|
let valid = super._preUpdate(changes, options, user);
|
||||||
|
|
||||||
if (hasProperty(changes, `system.equipped`) && !this.parent.isEmbedded) {
|
if (getProperty(diff, `system.equipped`) && !this._canEquip()) {
|
||||||
ui.notifications.error(localizer(
|
ui.notifications.error(localizer(
|
||||||
`RipCrypt.notifs.error.cannot-equip-not-embedded`,
|
`RipCrypt.notifs.error.cannot-equip`,
|
||||||
{ itemType: `@TYPES.Item.${this.parent.type}` },
|
{ itemType: `@TYPES.Item.${this.parent.type}` },
|
||||||
));
|
));
|
||||||
mergeObject(
|
|
||||||
changes,
|
// Don't stop the update, but don't allow changing the equipped status
|
||||||
{ "-=system.equipped": null },
|
setProperty(changes, `system.equipped`, false);
|
||||||
{ inplace: true, performDeletions: true },
|
|
||||||
);
|
// Set a flag so that we can tell the sheet that it needs to rerender
|
||||||
return false;
|
this.forceRerender = true;
|
||||||
};
|
};
|
||||||
return valid;
|
return valid;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue