From 43fe433900cbc77bc4c09fb8ad8f3429a4dee283 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Sun, 16 Feb 2025 12:19:56 -0700 Subject: [PATCH] RC-103 | Add Access to the rest of the item types that require it --- module/data/Item/Ammo.mjs | 19 +++++++++++++++++++ module/data/Item/Armour.mjs | 18 ++++++++++++++++++ module/data/Item/Common.mjs | 9 +++++++++ module/data/Item/Good.mjs | 19 +++++++++++++++++++ module/data/Item/Weapon.mjs | 26 +++++++++++++++++++------- 5 files changed, 84 insertions(+), 7 deletions(-) diff --git a/module/data/Item/Ammo.mjs b/module/data/Item/Ammo.mjs index 8c937f7..79733cd 100644 --- a/module/data/Item/Ammo.mjs +++ b/module/data/Item/Ammo.mjs @@ -1,4 +1,5 @@ import { CommonItemData } from "./Common.mjs"; +import { gameTerms } from "../../gameTerms.mjs"; export class AmmoData extends CommonItemData { // MARK: Base Data @@ -25,6 +26,24 @@ export class AmmoData extends CommonItemData { value: this.quantity, min: 0, }, + { + id: `access`, + type: `dropdown`, + label: `Access`, + path: `system.access`, + value: this.access, + limited: false, + options: [ + { + label: `RipCrypt.common.empty`, + value: ``, + }, + ...gameTerms.Access.map(opt => ({ + label: `RipCrypt.common.access.${opt}`, + value: opt, + })), + ], + }, ]; return fields; }; diff --git a/module/data/Item/Armour.mjs b/module/data/Item/Armour.mjs index 34d964d..4883219 100644 --- a/module/data/Item/Armour.mjs +++ b/module/data/Item/Armour.mjs @@ -116,6 +116,24 @@ export class ArmourData extends CommonItemData { value: this.quantity, min: 0, }, + { + id: `access`, + type: `dropdown`, + label: `Access`, + path: `system.access`, + value: this.access, + limited: false, + options: [ + { + label: `RipCrypt.common.empty`, + value: ``, + }, + ...gameTerms.Access.map(opt => ({ + label: `RipCrypt.common.access.${opt}`, + value: opt, + })), + ], + }, { id: `location`, type: `string-set`, diff --git a/module/data/Item/Common.mjs b/module/data/Item/Common.mjs index d020cc4..fe60d96 100644 --- a/module/data/Item/Common.mjs +++ b/module/data/Item/Common.mjs @@ -1,10 +1,19 @@ +import { gameTerms } from "../../gameTerms.mjs"; import { requiredInteger } from "../helpers.mjs"; +const { fields } = foundry.data; + export class CommonItemData extends foundry.abstract.TypeDataModel { // MARK: Schema static defineSchema() { return { quantity: requiredInteger({ min: 0, initial: 1 }), + access: new fields.StringField({ + blank: true, + nullable: false, + trim: true, + choices: gameTerms.Access, + }), }; }; diff --git a/module/data/Item/Good.mjs b/module/data/Item/Good.mjs index 3973cc1..f5d9ead 100644 --- a/module/data/Item/Good.mjs +++ b/module/data/Item/Good.mjs @@ -1,4 +1,5 @@ import { CommonItemData } from "./Common.mjs"; +import { gameTerms } from "../../gameTerms.mjs"; const { fields } = foundry.data; @@ -40,6 +41,24 @@ export class GoodData extends CommonItemData { value: this.quantity, min: 0, }, + { + id: `access`, + type: `dropdown`, + label: `Access`, + path: `system.access`, + value: this.access, + limited: false, + options: [ + { + label: `RipCrypt.common.empty`, + value: ``, + }, + ...gameTerms.Access.map(opt => ({ + label: `RipCrypt.common.access.${opt}`, + value: opt, + })), + ], + }, { id: `description`, type: `prosemirror`, diff --git a/module/data/Item/Weapon.mjs b/module/data/Item/Weapon.mjs index 91c28ec..5f648a2 100644 --- a/module/data/Item/Weapon.mjs +++ b/module/data/Item/Weapon.mjs @@ -28,12 +28,6 @@ export class WeaponData extends CommonItemData { }), damage: requiredInteger({ min: 0, initial: 0 }), wear: barAttribute(0, 0, 4), - access: new fields.StringField({ - blank: true, - nullable: false, - trim: true, - choices: gameTerms.Access, - }), equipped: new fields.BooleanField({ initial: false, required: true, @@ -87,7 +81,7 @@ export class WeaponData extends CommonItemData { // #endregion // #region Sheet Data - getFormFields(_ctx) { + async getFormFields(_ctx) { const fields = [ { id: `quantity`, @@ -97,6 +91,24 @@ export class WeaponData extends CommonItemData { value: this.quantity, min: 0, }, + { + id: `access`, + type: `dropdown`, + label: `Access`, + path: `system.access`, + value: this.access, + limited: false, + options: [ + { + label: `RipCrypt.common.empty`, + value: ``, + }, + ...gameTerms.Access.map(opt => ({ + label: `RipCrypt.common.access.${opt}`, + value: opt, + })), + ], + }, { id: `traits`, type: `string-set`,