From 3ffbc57546f4e8da5bf38ee68252255898bccca8 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Wed, 15 Jan 2025 20:16:32 -0700 Subject: [PATCH] RC-101 | Armour | Add Location Data --- langs/en-ca.json | 6 ++++-- module/data/Item/Armour.mjs | 26 ++++++++++++++++++++++++++ module/gameTerms.mjs | 8 +++++++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/langs/en-ca.json b/langs/en-ca.json index 5aaeccd..66c2ae8 100644 --- a/langs/en-ca.json +++ b/langs/en-ca.json @@ -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..." } } } diff --git a/module/data/Item/Armour.mjs b/module/data/Item/Armour.mjs index fe80576..2bcc23c 100644 --- a/module/data/Item/Armour.mjs +++ b/module/data/Item/Armour.mjs @@ -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`, diff --git a/module/gameTerms.mjs b/module/gameTerms.mjs index b1a1130..e65ca26 100644 --- a/module/gameTerms.mjs +++ b/module/gameTerms.mjs @@ -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`, + }), });