From eb8d4f7c112074cea848db40bca8e1231863e975 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Mon, 15 Jan 2024 22:47:47 -0700 Subject: [PATCH] Work on creating more of the necessary data models --- module/config.mjs | 14 ++++++++++---- module/documents/Actor/Handler.mjs | 1 + module/documents/Item/Handler.mjs | 13 ++++++++----- module/documents/Item/Spell.mjs | 10 ++++++++++ module/models/Item/CommonItemData.mjs | 13 ++++++++++++- module/models/Item/Equipment.mjs | 15 +++++++++++++++ module/models/Item/Pet.mjs | 1 - module/models/Item/Transportation.mjs | 4 ---- 8 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 module/documents/Item/Spell.mjs create mode 100644 module/models/Item/Equipment.mjs diff --git a/module/config.mjs b/module/config.mjs index 5fb1c18..95150f6 100644 --- a/module/config.mjs +++ b/module/config.mjs @@ -8,10 +8,10 @@ const ammoTypes = [`quivers`, `mags`, `cells`]; const stats = [ `build`, `meta`, `presence`, `hands`, `tilt`, `rng` ]; -const buildSkills = [ "defense", "magic", "melee", "platforming", "strength", ]; -const metaSkills = [ "alchemy", "arcanum", "dreams", "lore", "navigation", ]; -const presenceSkills = [ "animal_handling", "perception", "sneak", "speech", "vibes", ]; -const handsSkills = [ "accuracy", "crafting", "engineering", "explosives", "piloting", ]; +const buildSkills = [ `defense`, `magic`, `melee`, `platforming`, `strength`, ]; +const metaSkills = [ `alchemy`, `arcanum`, `dreams`, `lore`, `navigation`, ]; +const presenceSkills = [ `animal_handling`, `perception`, `sneak`, `speech`, `vibes`, ]; +const handsSkills = [ `accuracy`, `crafting`, `engineering`, `explosives`, `piloting`, ]; const allSkills = [ ...buildSkills, @@ -27,6 +27,11 @@ const skills = { hands: handsSkills, }; +const itemTiers = [ + `simple`, `greater`, + `rare`, `legendary` +]; + export default { stats, statDice, @@ -39,4 +44,5 @@ export default { handsSkills, allSkills, skills, + itemTiers, }; \ No newline at end of file diff --git a/module/documents/Actor/Handler.mjs b/module/documents/Actor/Handler.mjs index 2ef30bb..201c360 100644 --- a/module/documents/Actor/Handler.mjs +++ b/module/documents/Actor/Handler.mjs @@ -1,5 +1,6 @@ import PlayerActor from "./Player.mjs"; +/** @extends {Actor} */ export class ActorHandler extends Actor { proxyTargets = { player: PlayerActor, diff --git a/module/documents/Item/Handler.mjs b/module/documents/Item/Handler.mjs index 4250471..5018d57 100644 --- a/module/documents/Item/Handler.mjs +++ b/module/documents/Item/Handler.mjs @@ -1,13 +1,11 @@ import AspectItem from "./Aspect.mjs"; +import SpellItem from "./Spell.mjs"; -/** - * @extends {Item} - */ +/** @extends {Item} */ export class ItemHandler extends Item { - /** @override */ - proxyTargets = { aspect: AspectItem, + spell: SpellItem }; constructor(data, ctx) { @@ -19,6 +17,11 @@ export class ItemHandler extends Item { return this.proxyTargets[this.type]; }; + async migrateSystemData() { + if (!this.fn?.migrateSystemData) return; + this.fn?.migrateSystemData.bind(this)(); + }; + async proxyFunction(funcName, ...args) { if (!this.fn?.[funcName]) return; return await this.fn?.[funcName].bind(this)(...args); diff --git a/module/documents/Item/Spell.mjs b/module/documents/Item/Spell.mjs new file mode 100644 index 0000000..ea7da45 --- /dev/null +++ b/module/documents/Item/Spell.mjs @@ -0,0 +1,10 @@ +import { ItemHandler } from "./Handler.mjs"; + +/** @this {ItemHandler} */ +async function migrateSystemData() { + this.system +}; + +export default { + migrateSystemData, +}; diff --git a/module/models/Item/CommonItemData.mjs b/module/models/Item/CommonItemData.mjs index 63f60a0..ef4b431 100644 --- a/module/models/Item/CommonItemData.mjs +++ b/module/models/Item/CommonItemData.mjs @@ -1,11 +1,22 @@ +import { itemTiers } from "../../config.mjs"; + export class CommonItemData extends foundry.abstract.TypeDataModel { static defineSchema() { const fields = foundry.data.fields; return { - cost: new fields.NumberField({ + buy: new fields.NumberField({ initial: null, nullable: true, }), + usage_cost: new fields.NumberField({ + initial: null, + nullable: true, + }), + tier: new fields.StringField({ + initial: `simple`, + nullable: false, + choices: itemTiers, + }), }; }; }; diff --git a/module/models/Item/Equipment.mjs b/module/models/Item/Equipment.mjs new file mode 100644 index 0000000..48e2f53 --- /dev/null +++ b/module/models/Item/Equipment.mjs @@ -0,0 +1,15 @@ +import { DescribedItemData } from "./DescribedItemData.mjs"; + +export class EquipmentItemData extends DescribedItemData { + static defineSchema() { + const fields = foundry.data.fields; + return mergeObject(super.defineSchema(), { + extra_inventory: new fields.NumberField({ + initial: null, + nullable: true, + required: false, + }), + material + }); + }; +}; diff --git a/module/models/Item/Pet.mjs b/module/models/Item/Pet.mjs index 4f38463..439449e 100644 --- a/module/models/Item/Pet.mjs +++ b/module/models/Item/Pet.mjs @@ -4,7 +4,6 @@ export class PetItemData extends DescribedItemData { static defineSchema() { const fields = foundry.data.fields; return mergeObject(super.defineSchema(), { - purchase: new fields.NumberField({ initial: 0, }), upkeep: new fields.NumberField({ intial: null, nullable: true }), pokeballd: new fields.BooleanField({ initial: false }), }); diff --git a/module/models/Item/Transportation.mjs b/module/models/Item/Transportation.mjs index 627a2a8..fd1f427 100644 --- a/module/models/Item/Transportation.mjs +++ b/module/models/Item/Transportation.mjs @@ -8,10 +8,6 @@ export class TransportationItemData extends DescribedItemData { initial: null, nullable: true, }), - purchase: new fields.NumberField({ - initial: null, - nullable: true, - }), upkeep: new fields.NumberField({ initial: null, nullable: true,