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", "Rare": "Rare",
"Scarce": "Scarce" "Scarce": "Scarce"
}, },
"protection": "Protection" "protection": "Protection",
"location": "Location"
}, },
"setting": { "setting": {
"abbrAccess": { "abbrAccess": {
@ -87,7 +88,8 @@
"short-range": "Short @RipCrypt.common.range", "short-range": "Short @RipCrypt.common.range",
"long-range": "Long @RipCrypt.common.range", "long-range": "Long @RipCrypt.common.range",
"current-wear": "Current @RipCrypt.common.wear", "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"; import { requiredInteger } from "../helpers.mjs";
const { fields } = foundry.data; const { fields } = foundry.data;
@ -7,6 +8,18 @@ export class ArmourData extends foundry.abstract.TypeDataModel {
static defineSchema() { static defineSchema() {
return { return {
protection: requiredInteger({ min: 0, initial: 1 }), 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(); super.prepareDerivedData();
}; };
// #region Getters
get locationString() {
return [...this.location].join(`, `);
};
// #endregion
// #region Sheet Data // #region Sheet Data
getFormFields(ctx) { getFormFields(ctx) {
const fields = [ const fields = [
{
type: `string-set`,
label: `RipCrypt.common.location`,
placeholder: `RipCrypt.Apps.location-placeholder`,
path: `system.location`,
value: this.locationString,
},
{ {
type: `integer`, type: `integer`,
label: `RipCrypt.common.protection`, label: `RipCrypt.common.protection`,

View file

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