Rename the Armour data model to something shields can use as well

This commit is contained in:
Oliver-Akins 2025-01-19 00:16:56 -07:00
parent a95412ad2e
commit ba8bd472dc
2 changed files with 4 additions and 3 deletions

View file

@ -0,0 +1,71 @@
import { gameTerms } from "../../gameTerms.mjs";
import { requiredInteger } from "../helpers.mjs";
const { fields } = foundry.data;
/** Used for Armour and Shields */
export class ProtectorData extends foundry.abstract.TypeDataModel {
// MARK: Schema
static defineSchema() {
return {
protection: requiredInteger({ min: 0, initial: 1 }),
location: new fields.SetField(
new fields.StringField({
blank: false,
trim: true,
nullable: false,
options: Object.values(gameTerms.Anatomy),
}),
{
nullable: false,
required: true,
},
),
equipped: new fields.BooleanField({
initial: false,
required: true,
nullable: false,
}),
};
};
// MARK: Base Data
prepareBaseData() {
super.prepareBaseData();
};
// MARK: Derived Data
prepareDerivedData() {
super.prepareDerivedData();
};
// #region Getters
get locationString() {
return [...this.location].join(`, `);
};
// #endregion
// #region Sheet Data
getFormFields(ctx) {
const fields = [
{
id: `location`,
type: `string-set`,
label: `RipCrypt.common.location`,
placeholder: `RipCrypt.Apps.location-placeholder`,
path: `system.location`,
value: this.locationString,
},
{
id: `protection`,
type: `integer`,
label: `RipCrypt.common.protection`,
value: this.protection,
path: `system.protection`,
min: 0,
},
];
return fields;
};
// #endregion
};