Update the ArmourSheets to allow for the equipped toggle to be present and work
This commit is contained in:
parent
b72c9d9739
commit
3c582c77bb
4 changed files with 45 additions and 6 deletions
|
|
@ -5,7 +5,7 @@ import { Logger } from "../../utils/Logger.mjs";
|
|||
import { requiredInteger } from "../helpers.mjs";
|
||||
|
||||
const { fields } = foundry.data;
|
||||
const { hasProperty, diffObject, mergeObject } = foundry.utils;
|
||||
const { getProperty, diffObject, mergeObject } = foundry.utils;
|
||||
|
||||
/** Used for Armour and Shields */
|
||||
export class ArmourData extends CommonItemData {
|
||||
|
|
@ -19,16 +19,16 @@ export class ArmourData extends CommonItemData {
|
|||
blank: false,
|
||||
trim: true,
|
||||
nullable: false,
|
||||
required: true,
|
||||
options: Object.values(gameTerms.Anatomy),
|
||||
}),
|
||||
{
|
||||
nullable: false,
|
||||
required: true,
|
||||
initial: [],
|
||||
},
|
||||
),
|
||||
equipped: new fields.BooleanField({
|
||||
initial: false,
|
||||
required: true,
|
||||
nullable: false,
|
||||
}),
|
||||
weight: new fields.StringField({
|
||||
|
|
@ -59,7 +59,7 @@ export class ArmourData extends CommonItemData {
|
|||
const diff = diffObject(this.parent._source, changes);
|
||||
let valid = await super._preUpdate(changes, options, user);
|
||||
|
||||
if (hasProperty(diff, `system.equipped`) && !this._canEquip()) {
|
||||
if (getProperty(diff, `system.equipped`) && !this._canEquip()) {
|
||||
ui.notifications.error(
|
||||
localizer(
|
||||
`RipCrypt.notifs.error.cannot-equip`,
|
||||
|
|
@ -80,7 +80,10 @@ export class ArmourData extends CommonItemData {
|
|||
return valid;
|
||||
};
|
||||
|
||||
/** Used to tell the preUpdate logic whether or not to prevent the */
|
||||
/**
|
||||
* Used to tell the preUpdate logic whether or not to prevent the item from
|
||||
* being equipped or not.
|
||||
*/
|
||||
_canEquip() {
|
||||
const parent = this.parent;
|
||||
if (!parent.isEmbedded || !(parent.parent instanceof Actor)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue