From 8da6565aae10542c9bf89f324440ed1a839ba433 Mon Sep 17 00:00:00 2001 From: Joscha Maier Date: Wed, 2 Oct 2024 14:45:44 +0200 Subject: [PATCH] chore: more model stuff --- kidsonbrooms.mjs | 25 +++++++++++++++++++ lang/en.json | 1 - modules/dataModel/_system.mjs | 4 +++ modules/dataModel/baseActorModel.mjs | 2 +- modules/dataModel/dataModel.mjs | 10 ++++---- modules/dataModel/itemModel.mjs | 8 +++--- modules/dataModel/playerCharacterModel.mjs | 5 ++-- modules/documents/actor.mjs | 7 ++++++ .../{kidsonbrooms.mjs => documents/item.mjs} | 0 9 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 kidsonbrooms.mjs create mode 100644 modules/documents/actor.mjs rename modules/{kidsonbrooms.mjs => documents/item.mjs} (100%) diff --git a/kidsonbrooms.mjs b/kidsonbrooms.mjs new file mode 100644 index 0000000..adaee1d --- /dev/null +++ b/kidsonbrooms.mjs @@ -0,0 +1,25 @@ +import * as models from "./modules/dataModel/_system.mjs"; + +/* -------------------------------------------- */ +/* Foundry VTT Initialization */ +/* -------------------------------------------- */ + +const SYSTEM = { + id: "kidsonbrooms", + +} + +Hooks.once("init", async function() { + console.log("Initialising Kids on Brooms system"); + + globalThis.kidsonbrooms = game.system; + game.system.CONST = SYSTEM; + + Object.assign(CONFIG.Actor.dataModels, { + PC: models.PlayerCharacter + }) + + CONFIG.LOCALIZATION_PREFIXES = { + kidsonbrooms: "KidsOnBrooms" + } +}) \ No newline at end of file diff --git a/lang/en.json b/lang/en.json index 9633520..27f62b1 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1,5 +1,4 @@ { - "KIDSONBROOMS.EffectCreate": "Create Effect", "KIDSONBROOMS.EffectToggle": "Toggle Effect", "KIDSONBROOMS.EffectEdit": "Edit Effect", diff --git a/modules/dataModel/_system.mjs b/modules/dataModel/_system.mjs index e69de29..14a64d2 100644 --- a/modules/dataModel/_system.mjs +++ b/modules/dataModel/_system.mjs @@ -0,0 +1,4 @@ +export * from "./itemModel.mjs"; +export * from "./dataModel.mjs"; +export * from "./playerCharacterModel.mjs"; +export * from "./baseActorModel.mjs" \ No newline at end of file diff --git a/modules/dataModel/baseActorModel.mjs b/modules/dataModel/baseActorModel.mjs index d22b38f..4f425cf 100644 --- a/modules/dataModel/baseActorModel.mjs +++ b/modules/dataModel/baseActorModel.mjs @@ -4,7 +4,7 @@ import Stat from "./dataModel.mjs" /* Actor base Model */ /* -------------------------------------------- */ const fields = foundry.data.fields; -class ActorGeneral extends foundry.abstract.TypeDataModel +export default class ActorGeneral extends foundry.abstract.TypeDataModel { static defineSchema(){ return { diff --git a/modules/dataModel/dataModel.mjs b/modules/dataModel/dataModel.mjs index 10a29c3..c65c779 100644 --- a/modules/dataModel/dataModel.mjs +++ b/modules/dataModel/dataModel.mjs @@ -2,7 +2,7 @@ /* Base Models */ /* -------------------------------------------- */ const fields = foundry.data.fields; -class Stat extends foundry.abstract.DataModel +export default class Stat extends foundry.abstract.DataModel { static defineSchema() { return { @@ -15,7 +15,7 @@ class Stat extends foundry.abstract.DataModel } } -class Modifier extends foundry.abstract.DataModel +export class Modifier extends foundry.abstract.DataModel { static defineSchema() { return { @@ -35,7 +35,7 @@ class Modifier extends foundry.abstract.DataModel /* -------------------------------------------- */ /* Effect Models */ /* -------------------------------------------- */ -class Effect extends foundry.abstract.DataModel +export class Effect extends foundry.abstract.DataModel { static defineSchema() { return { @@ -45,7 +45,7 @@ class Effect extends foundry.abstract.DataModel } } -class Flaw extends foundry.abstract.DataModel +export class Flaw extends foundry.abstract.DataModel { static defineSchema() { return { @@ -55,7 +55,7 @@ class Flaw extends foundry.abstract.DataModel } } -class Strength extends Effect +export class Strength extends Effect { static defineSchema() { return { diff --git a/modules/dataModel/itemModel.mjs b/modules/dataModel/itemModel.mjs index cee95ed..1672dfb 100644 --- a/modules/dataModel/itemModel.mjs +++ b/modules/dataModel/itemModel.mjs @@ -5,7 +5,7 @@ import Effect from "./dataModel.mjs"; /* -------------------------------------------- */ /* How this will work is when we first load a sheet we load all the items we have and take their effects and apply them to our stats. */ const fields = foundry.data.fields; -class KidsOnBroomsItem extends foundry.abstract.TypeDataModel +export default class KidsOnBroomsItem extends foundry.abstract.TypeDataModel { static defineSchema() { return { @@ -23,7 +23,7 @@ class KidsOnBroomsItem extends foundry.abstract.TypeDataModel } } -class Wand extends KidsOnBroomsItem +export class Wand extends KidsOnBroomsItem { static defineSchema() { return { @@ -33,11 +33,11 @@ class Wand extends KidsOnBroomsItem } } -class Broom extends KidsOnBroomsItem +export class Broom extends KidsOnBroomsItem { static defineSchema(){ return { - look: new fields.StringField({requird: true, intial: "A broom"}), + look: new fields.StringField({required: true, initial: "A broom"}), mechanicalBenefit: new fields.EmbeddedDataField(Effect, {required: false}) } } diff --git a/modules/dataModel/playerCharacterModel.mjs b/modules/dataModel/playerCharacterModel.mjs index db05521..4f308e1 100644 --- a/modules/dataModel/playerCharacterModel.mjs +++ b/modules/dataModel/playerCharacterModel.mjs @@ -1,11 +1,12 @@ import ActorGeneral from "./baseActorModel.mjs"; -import {KidsOnBroomsItem, Wand, Broom} from "./itemModel.mjs" +import {Wand, Broom} from "./itemModel.mjs" +import KidsOnBroomsItem from "./itemModel.mjs" /* -------------------------------------------- */ /* PC Model */ /* -------------------------------------------- */ const fields = foundry.data.fields; -class PlayerCharacter extends ActorGeneral +export default class PlayerCharacter extends ActorGeneral { static defineSchema(){ return { diff --git a/modules/documents/actor.mjs b/modules/documents/actor.mjs new file mode 100644 index 0000000..e5563d5 --- /dev/null +++ b/modules/documents/actor.mjs @@ -0,0 +1,7 @@ +export default class KidsOnBroomsActor extends Actor { + constructor(data, context) { + super(data, context) + } + + +} \ No newline at end of file diff --git a/modules/kidsonbrooms.mjs b/modules/documents/item.mjs similarity index 100% rename from modules/kidsonbrooms.mjs rename to modules/documents/item.mjs