RC-101 | Armour | Add Location Data

This commit is contained in:
Oliver-Akins 2025-01-15 20:16:32 -07:00
parent 4948c7e755
commit 3ffbc57546
3 changed files with 37 additions and 3 deletions

View file

@ -63,7 +63,8 @@
"Rare": "Rare",
"Scarce": "Scarce"
},
"protection": "Protection"
"protection": "Protection",
"location": "Location"
},
"setting": {
"abbrAccess": {
@ -87,7 +88,8 @@
"short-range": "Short @RipCrypt.common.range",
"long-range": "Long @RipCrypt.common.range",
"current-wear": "Current @RipCrypt.common.wear",
"max-wear": "Maximum @RipCrypt.common.wear"
"max-wear": "Maximum @RipCrypt.common.wear",
"location-placeholder": "New Location..."
}
}
}

View file

@ -1,3 +1,4 @@
import { gameTerms } from "../../gameTerms.mjs";
import { requiredInteger } from "../helpers.mjs";
const { fields } = foundry.data;
@ -7,6 +8,18 @@ export class ArmourData extends foundry.abstract.TypeDataModel {
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,
},
),
};
};
@ -20,9 +33,22 @@ export class ArmourData extends foundry.abstract.TypeDataModel {
super.prepareDerivedData();
};
// #region Getters
get locationString() {
return [...this.location].join(`, `);
};
// #endregion
// #region Sheet Data
getFormFields(ctx) {
const fields = [
{
type: `string-set`,
label: `RipCrypt.common.location`,
placeholder: `RipCrypt.Apps.location-placeholder`,
path: `system.location`,
value: this.locationString,
},
{
type: `integer`,
label: `RipCrypt.common.protection`,

View file

@ -15,6 +15,12 @@ export const gameTerms = Object.preventExtensions({
NOVICE: `Novice`,
ADEPT: `Adept`,
EXPERT: `Expert`,
Master: `Master`,
MASTER: `Master`,
},
Anatomy: Object.freeze({
HEAD: `head`,
BODY: `body`,
ARMS: `arms`,
LEGS: `legs`,
}),
});