From 3b768ca44cdd350f96666953a71c4586a67480af Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 25 Sep 2025 19:26:26 +0200 Subject: [PATCH 01/24] initial skill data and dialog test --- src/module/items/skill.mjs | 18 +++++++++++ src/module/items/skillItemSheet.mjs | 43 +++++++++++++++++++++++++ src/templates/character/character.hbs | 27 ++++++++++++++++ src/templates/items/skillItem-sheet.hbs | 28 ++++++++++++++++ 4 files changed, 116 insertions(+) create mode 100644 src/module/items/skill.mjs create mode 100644 src/module/items/skillItemSheet.mjs create mode 100644 src/templates/character/character.hbs create mode 100644 src/templates/items/skillItem-sheet.hbs diff --git a/src/module/items/skill.mjs b/src/module/items/skill.mjs new file mode 100644 index 00000000..2c7a1815 --- /dev/null +++ b/src/module/items/skill.mjs @@ -0,0 +1,18 @@ +const { BooleanField, NumberField, SchemaField, SetField, StringField } = foundry.data.fields; + +export default class Skill extends foundry.abstract.TypeDataModel { + + static defineSchema() { + return { + name: StringField({required: true}), + category: StringField({required: true}), + attributeReference1: StringField(), // References one of the eight attributes by name + attributeReference2: StringField(), // References one of the eight attributes by name + attributeReference3: StringField(), // References one of the eight attributes by name + skillValue: NumberField(), // TaW + handicapValue: NumberField(), // BE-X + complexity: NumberField(), // In case of languages + } + } + +} \ No newline at end of file diff --git a/src/module/items/skillItemSheet.mjs b/src/module/items/skillItemSheet.mjs new file mode 100644 index 00000000..50a2e2e8 --- /dev/null +++ b/src/module/items/skillItemSheet.mjs @@ -0,0 +1,43 @@ +export class SkillItemSheet extends ItemSheet { + /**@override */ + static get defaultOptions() { + return foundry.utils.mergeObject(super.defaultOptions, { + classes: ['dsa41', 'sheet', 'item', 'skill'], + width: 520, + height: 480, + tabs: [ + { + navSelector: '.sheet-tabs', + contentSelector: '.sheet-body', + initial: 'description', + }, + ], + }); + } + + /** @override */ + get template() { + return `${path}/item-${this.item.type}-sheet.hbs`; + } + + /** @override */ + getData() { + // Retrieve base data structure. + const context = super.getData(); + + // Use a safe clone of the item data for further operations. + const itemData = context.data; + + // Retrieve the roll data for TinyMCE editors. + context.rollData = this.item.getRollData(); + + // Add the item's data to context.data for easier access, as well as flags. + context.system = itemData.system; + context.flags = itemData.flags; + + // Prepare active effects for easier access + context.effects = prepareActiveEffectCategories(this.item.effects); + + return context; + } +} \ No newline at end of file diff --git a/src/templates/character/character.hbs b/src/templates/character/character.hbs new file mode 100644 index 00000000..c2b820a7 --- /dev/null +++ b/src/templates/character/character.hbs @@ -0,0 +1,27 @@ +
+ + {{!-- Sheet Header --}} +
+ {{!-- Header stuff goes here --}} + +
+

+
+
+ + {{!-- Sheet Tab Navigation --}} + + + {{!-- Sheet Body --}} +
+
+ + + + +
+
+
\ No newline at end of file diff --git a/src/templates/items/skillItem-sheet.hbs b/src/templates/items/skillItem-sheet.hbs new file mode 100644 index 00000000..e0996ec5 --- /dev/null +++ b/src/templates/items/skillItem-sheet.hbs @@ -0,0 +1,28 @@ +
+ + {{!-- Sheet Header --}} +
+ {{!-- Header stuff goes here --}} + +
+ + {{!-- Sheet Tab Navigation --}} + + + {{!-- Sheet Body --}} +
+
+ + + + + + + + +
+ +
+
\ No newline at end of file -- 2.43.0 From 1ba672680ebc5bb575eceb9b883ff6181ba097f9 Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 25 Sep 2025 19:29:53 +0200 Subject: [PATCH 02/24] missed initial declaration --- src/system.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/system.json b/src/system.json index 3e21f581..b70dd199 100644 --- a/src/system.json +++ b/src/system.json @@ -41,7 +41,10 @@ "documentTypes": { "Actor": { "character": {} - } + }, + "Item": { + "skill": {} + } }, "socket": false, "initiative": "1d6", -- 2.43.0 From 32e44a5cf926145c6cc3294fafa94836f64f7b2f Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 25 Sep 2025 19:50:13 +0200 Subject: [PATCH 03/24] update naming and directory structure --- src/main.mjs | 5 +++++ src/module/{items/skill.mjs => Items/Skill.mjs} | 11 +++++++---- .../skillItemSheet.mjs => Items/SkillSheet.mjs} | 2 +- src/templates/{character => actor}/character.hbs | 0 src/templates/{items => item}/skillItem-sheet.hbs | 0 5 files changed, 13 insertions(+), 5 deletions(-) rename src/module/{items/skill.mjs => Items/Skill.mjs} (67%) rename src/module/{items/skillItemSheet.mjs => Items/SkillSheet.mjs} (96%) rename src/templates/{character => actor}/character.hbs (100%) rename src/templates/{items => item}/skillItem-sheet.hbs (100%) diff --git a/src/main.mjs b/src/main.mjs index 6cdd43a4..bba2c509 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -1,5 +1,6 @@ import {PlayerCharacterDataModel} from "./module/character/character.mjs"; import {DsaActor} from "./module/Actors/dsa-actor.mjs"; +import {Skill} from "./module/Items/Skill.mjs" Hooks.once("init", () => { // Configure custom Document implementations. @@ -10,5 +11,9 @@ Hooks.once("init", () => { character: PlayerCharacterDataModel, }; + CONFIG.Item.dataModels = { + skills: Skill + } + console.log("DSA 4.1 is ready for development!") }) \ No newline at end of file diff --git a/src/module/items/skill.mjs b/src/module/Items/Skill.mjs similarity index 67% rename from src/module/items/skill.mjs rename to src/module/Items/Skill.mjs index 2c7a1815..84c617b6 100644 --- a/src/module/items/skill.mjs +++ b/src/module/Items/Skill.mjs @@ -4,15 +4,18 @@ export default class Skill extends foundry.abstract.TypeDataModel { static defineSchema() { return { - name: StringField({required: true}), - category: StringField({required: true}), + name: StringField({ required: true }), + category: StringField({ required: true }), attributeReference1: StringField(), // References one of the eight attributes by name attributeReference2: StringField(), // References one of the eight attributes by name attributeReference3: StringField(), // References one of the eight attributes by name - skillValue: NumberField(), // TaW handicapValue: NumberField(), // BE-X complexity: NumberField(), // In case of languages + derivedAttribute1: NumberField(), + derivedAttribute2: NumberField(), + derivedAttribute3: NumberField(), + derivedSkillValue: NumberField(), // TaW + } } - } \ No newline at end of file diff --git a/src/module/items/skillItemSheet.mjs b/src/module/Items/SkillSheet.mjs similarity index 96% rename from src/module/items/skillItemSheet.mjs rename to src/module/Items/SkillSheet.mjs index 50a2e2e8..07c68a42 100644 --- a/src/module/items/skillItemSheet.mjs +++ b/src/module/Items/SkillSheet.mjs @@ -1,4 +1,4 @@ -export class SkillItemSheet extends ItemSheet { +export class SkillSheet extends ItemSheet { /**@override */ static get defaultOptions() { return foundry.utils.mergeObject(super.defaultOptions, { diff --git a/src/templates/character/character.hbs b/src/templates/actor/character.hbs similarity index 100% rename from src/templates/character/character.hbs rename to src/templates/actor/character.hbs diff --git a/src/templates/items/skillItem-sheet.hbs b/src/templates/item/skillItem-sheet.hbs similarity index 100% rename from src/templates/items/skillItem-sheet.hbs rename to src/templates/item/skillItem-sheet.hbs -- 2.43.0 From e91fe82e9544b9529e29cd4ed43d673babe46b0d Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 25 Sep 2025 19:57:52 +0200 Subject: [PATCH 04/24] register sheets --- src/main.mjs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main.mjs b/src/main.mjs index bba2c509..700d15e2 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -1,8 +1,10 @@ -import {PlayerCharacterDataModel} from "./module/character/character.mjs"; -import {DsaActor} from "./module/Actors/dsa-actor.mjs"; -import {Skill} from "./module/Items/Skill.mjs" +import { PlayerCharacterDataModel } from "./module/character/character.mjs"; +import { DsaActor } from "./module/Actors/dsa-actor.mjs"; +import { Skill } from "./module/Items/Skill.mjs" +import { SkillSheet } from "./module/Items/SkillSheet.mjs"; Hooks.once("init", () => { + // Configure custom Document implementations. CONFIG.Actor.documentClass = DsaActor; @@ -16,4 +18,13 @@ Hooks.once("init", () => { } console.log("DSA 4.1 is ready for development!") + + // Register sheet application classes + Items.registerSheet('dsa41.skill', SkillSheet, { + makeDefault: true, + label: 'DSA41.SheetLabels.Item', + }); + + return preloadHandlebarsTemplates(); + }) \ No newline at end of file -- 2.43.0 From 48c6d1123d28a38645e0a4c76a44770e2c1226f8 Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 25 Sep 2025 19:59:47 +0200 Subject: [PATCH 05/24] fix export --- src/module/Items/Skill.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/Items/Skill.mjs b/src/module/Items/Skill.mjs index 84c617b6..2b64e807 100644 --- a/src/module/Items/Skill.mjs +++ b/src/module/Items/Skill.mjs @@ -1,6 +1,6 @@ const { BooleanField, NumberField, SchemaField, SetField, StringField } = foundry.data.fields; -export default class Skill extends foundry.abstract.TypeDataModel { +export class Skill extends foundry.abstract.TypeDataModel { static defineSchema() { return { -- 2.43.0 From 192b1b4252a71cd82c1f61965f942245ea948e4e Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 25 Sep 2025 20:02:38 +0200 Subject: [PATCH 06/24] invoking constructors --- src/main.mjs | 3 --- src/module/Items/Skill.mjs | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main.mjs b/src/main.mjs index 700d15e2..ad979844 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -24,7 +24,4 @@ Hooks.once("init", () => { makeDefault: true, label: 'DSA41.SheetLabels.Item', }); - - return preloadHandlebarsTemplates(); - }) \ No newline at end of file diff --git a/src/module/Items/Skill.mjs b/src/module/Items/Skill.mjs index 2b64e807..c93cb16b 100644 --- a/src/module/Items/Skill.mjs +++ b/src/module/Items/Skill.mjs @@ -4,17 +4,17 @@ export class Skill extends foundry.abstract.TypeDataModel { static defineSchema() { return { - name: StringField({ required: true }), - category: StringField({ required: true }), - attributeReference1: StringField(), // References one of the eight attributes by name - attributeReference2: StringField(), // References one of the eight attributes by name - attributeReference3: StringField(), // References one of the eight attributes by name - handicapValue: NumberField(), // BE-X - complexity: NumberField(), // In case of languages - derivedAttribute1: NumberField(), - derivedAttribute2: NumberField(), - derivedAttribute3: NumberField(), - derivedSkillValue: NumberField(), // TaW + name: new StringField({ required: true }), + category: new StringField({ required: true }), + attributeReference1: new StringField(), // References one of the eight attributes by name + attributeReference2: new StringField(), // References one of the eight attributes by name + attributeReference3: new StringField(), // References one of the eight attributes by name + handicapValue: new NumberField(), // BE-X + complexity: new NumberField(), // In case of languages + derivedAttribute1: new NumberField(), + derivedAttribute2: new NumberField(), + derivedAttribute3: new NumberField(), + derivedSkillValue: new NumberField(), // TaW } } -- 2.43.0 From 4eedb1527b2cd23f0833a53b342ad9409e30d85c Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 25 Sep 2025 20:05:00 +0200 Subject: [PATCH 07/24] just blank version please --- src/module/Items/SkillSheet.mjs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/module/Items/SkillSheet.mjs b/src/module/Items/SkillSheet.mjs index 07c68a42..5d1ee832 100644 --- a/src/module/Items/SkillSheet.mjs +++ b/src/module/Items/SkillSheet.mjs @@ -19,25 +19,4 @@ export class SkillSheet extends ItemSheet { get template() { return `${path}/item-${this.item.type}-sheet.hbs`; } - - /** @override */ - getData() { - // Retrieve base data structure. - const context = super.getData(); - - // Use a safe clone of the item data for further operations. - const itemData = context.data; - - // Retrieve the roll data for TinyMCE editors. - context.rollData = this.item.getRollData(); - - // Add the item's data to context.data for easier access, as well as flags. - context.system = itemData.system; - context.flags = itemData.flags; - - // Prepare active effects for easier access - context.effects = prepareActiveEffectCategories(this.item.effects); - - return context; - } } \ No newline at end of file -- 2.43.0 From fe9fe0328280c5259a26b38f31f07b49faa59079 Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 25 Sep 2025 20:08:23 +0200 Subject: [PATCH 08/24] naming --- src/templates/item/{skillItem-sheet.hbs => item-skill-sheet.hbs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/templates/item/{skillItem-sheet.hbs => item-skill-sheet.hbs} (100%) diff --git a/src/templates/item/skillItem-sheet.hbs b/src/templates/item/item-skill-sheet.hbs similarity index 100% rename from src/templates/item/skillItem-sheet.hbs rename to src/templates/item/item-skill-sheet.hbs -- 2.43.0 From 4a35a24d43b8198471ded747776b26d4242f3928 Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 25 Sep 2025 20:12:54 +0200 Subject: [PATCH 09/24] once more with feelings --- src/module/Items/SkillSheet.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/Items/SkillSheet.mjs b/src/module/Items/SkillSheet.mjs index 5d1ee832..4f803eb2 100644 --- a/src/module/Items/SkillSheet.mjs +++ b/src/module/Items/SkillSheet.mjs @@ -17,6 +17,6 @@ export class SkillSheet extends ItemSheet { /** @override */ get template() { - return `${path}/item-${this.item.type}-sheet.hbs`; + return `systems/DSA_4-1/templates/item-${this.item.type}-sheet.hbs`; } } \ No newline at end of file -- 2.43.0 From 2972bc2cf71d7407f2a44ca50c7dd3be60ec4746 Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 25 Sep 2025 20:14:50 +0200 Subject: [PATCH 10/24] once more again with feelings --- src/module/Items/SkillSheet.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/Items/SkillSheet.mjs b/src/module/Items/SkillSheet.mjs index 4f803eb2..90b766d4 100644 --- a/src/module/Items/SkillSheet.mjs +++ b/src/module/Items/SkillSheet.mjs @@ -17,6 +17,6 @@ export class SkillSheet extends ItemSheet { /** @override */ get template() { - return `systems/DSA_4-1/templates/item-${this.item.type}-sheet.hbs`; + return `systems/DSA_4-1/templates/item/item-${this.item.type}-sheet.hbs`; } } \ No newline at end of file -- 2.43.0 From 81da5320745b636a9a82424b4cbca94738e8dd31 Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 25 Sep 2025 20:20:10 +0200 Subject: [PATCH 11/24] labeling --- src/templates/item/item-skill-sheet.hbs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/templates/item/item-skill-sheet.hbs b/src/templates/item/item-skill-sheet.hbs index e0996ec5..88fb854f 100644 --- a/src/templates/item/item-skill-sheet.hbs +++ b/src/templates/item/item-skill-sheet.hbs @@ -15,12 +15,21 @@
+ + + + +
-- 2.43.0 From 2414f3b8f34edf1fd7fb1f28c7b75f0e03b724dd Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 25 Sep 2025 20:37:44 +0200 Subject: [PATCH 12/24] register fields for database structur --- src/module/Items/SkillSheet.mjs | 27 +++++++++++++++++++++++++ src/system.json | 5 ++++- src/templates/item/item-skill-sheet.hbs | 4 ++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/module/Items/SkillSheet.mjs b/src/module/Items/SkillSheet.mjs index 90b766d4..483145a9 100644 --- a/src/module/Items/SkillSheet.mjs +++ b/src/module/Items/SkillSheet.mjs @@ -19,4 +19,31 @@ export class SkillSheet extends ItemSheet { get template() { return `systems/DSA_4-1/templates/item/item-${this.item.type}-sheet.hbs`; } + + /** @override */ + getData() { + // Retrieve the data structure from the base sheet. You can inspect or log + // the context variable to see the structure, but some key properties for + // sheets are the actor object, the data object, whether or not it's + // editable, the items array, and the effects array. + const context = super.getData(); + + // Use a safe clone of the actor data for further operations. + const skillData = context.data; + + // Add the actor's data to context.data for easier access, as well as flags. + context.system = skillData.system; + context.flags = skillData.flags; + + return context; + } + + activateListeners(html) { + super.activateListeners(html); + + // Everything below here is only needed if the sheet is editable + if (!this.isEditable) return; + + } + } \ No newline at end of file diff --git a/src/system.json b/src/system.json index b70dd199..94336b79 100644 --- a/src/system.json +++ b/src/system.json @@ -43,7 +43,10 @@ "character": {} }, "Item": { - "skill": {} + "skill": { + "StringField": ["name", "category", "attributeReference1", "attributeReference2", "attributeReference3"], + "NumberField": ["handicapValue", "complexity"] + } } }, "socket": false, diff --git a/src/templates/item/item-skill-sheet.hbs b/src/templates/item/item-skill-sheet.hbs index 88fb854f..341bf472 100644 --- a/src/templates/item/item-skill-sheet.hbs +++ b/src/templates/item/item-skill-sheet.hbs @@ -18,10 +18,10 @@ -