From 099d1c5d165b6c93d0c379f1c34a836231001714 Mon Sep 17 00:00:00 2001 From: macniel Date: Sun, 12 Oct 2025 10:49:37 +0200 Subject: [PATCH] tableized group sheet --- src/module/sheets/groupSheet.mjs | 64 +++++++++++++++++-------- src/templates/actor/group-sheet.hbs | 74 ++++++++++++++++------------- 2 files changed, 85 insertions(+), 53 deletions(-) diff --git a/src/module/sheets/groupSheet.mjs b/src/module/sheets/groupSheet.mjs index 6536d933..fafc86a7 100644 --- a/src/module/sheets/groupSheet.mjs +++ b/src/module/sheets/groupSheet.mjs @@ -28,13 +28,18 @@ export class GroupSheet extends ActorSheet { // update group - const settings = {...group.system.settings} + let settings = {...group.system.settings} character.items.filter((i) => i.type === "Advantage").forEach((advantage) => { - settings[this.#stringToKeyFieldName(advantage.name)] = false + if (!settings[sheet.#stringToKeyFieldName(advantage.name)]) { + settings[sheet.#stringToKeyFieldName(advantage.name)] = false + } }) character.items.filter((i) => i.type === "Skill").forEach((skill) => { - settings[this.#stringToKeyFieldName(skill.name)] = false - }), + if (!settings[sheet.#stringToKeyFieldName(skill.name)]) { + settings[sheet.#stringToKeyFieldName(skill.name)] = false + } + }) + await group.update({ system: { characters: [ @@ -55,7 +60,7 @@ export class GroupSheet extends ActorSheet { } #stringToKeyFieldName(s) { - return s.replace(/[ \[\]:]/g, "_").toLowerCase() + return s } /** @override */ @@ -74,14 +79,46 @@ export class GroupSheet extends ActorSheet { context.system = groupData.system; context.flags = groupData.flags; context.characters = [] + context.isGM = game.user.isGM; context.fields = []; const hiddenFields = Object.entries(groupData.system.settings).filter(([key, value]) => value === true).map(([key, value]) => key) + context.fields = {} + context.fields["head"] = {} + for (const field of hiddenFields) { + + context.fields[field] = {} + + for (const characterId of groupData.system.characters) { + const character = await game.actors.get(characterId) + context.fields[field][character.name] = "-" + + } + } + + for (const characterId of groupData.system.characters) { const character = await game.actors.get(characterId) - context.characters.push( + + character.items.filter((i) => i.type === "Advantage").filter((i) => hiddenFields.includes(this.#stringToKeyFieldName(i.name))).map((advantage) => { + const n = this.#stringToKeyFieldName(advantage.name) + if (!context.fields[n]) { + context.fields[n] = {} + } + context.fields[n][character.name] = advantage.system.value ?? "Ja" // TODO: Allow GM roll + }) + + character.items.filter((i) => i.type === "Skill").filter((i) => hiddenFields.includes(this.#stringToKeyFieldName(i.name))).map((skill) => { + const n = this.#stringToKeyFieldName(skill.name) + if (!context.fields[n]) { + context.fields[n] = {} + } + context.fields[n][character.name] = skill.system.taw ?? 0 // TODO: Allow GM roll + }) + + context.fields.head[character.name] = { img: character.img, name: character.name, @@ -96,25 +133,10 @@ export class GroupSheet extends ActorSheet { {name: "KO", value: character.system.attribute.ko.aktuell}, {name: "KK", value: character.system.attribute.kk.aktuell}, ], - advantages: character.items.filter((i) => i.type === "Advantage").filter((i) => hiddenFields.includes(this.#stringToKeyFieldName(i.name))).map((advantage) => { - return { - name: advantage.name, - id: advantage._id, - value: advantage.system.value, - } - }), - skills: character.items.filter((i) => i.type === "Skill").filter((i) => hiddenFields.includes(this.#stringToKeyFieldName(i.name))).map((skill) => { - return { - name: skill.name, - taw: skill.system.taw, - id: skill._id - } - }), isLimited: character.isOwner || !character.limited, isVisible: character.isOwner || character.visible, isOwner: character.isOwner } - ) } context.equipments = []; diff --git a/src/templates/actor/group-sheet.hbs b/src/templates/actor/group-sheet.hbs index 52327def..65d7ce0d 100644 --- a/src/templates/actor/group-sheet.hbs +++ b/src/templates/actor/group-sheet.hbs @@ -17,7 +17,7 @@ {{!-- Sheet Body --}}
- {{#if actor.limited}} + {{#unless isGM}}
{{#each characters}} {{#if this.isVisible}} @@ -33,14 +33,19 @@
{{else}}
- {{#each characters}} - {{#if this.isVisible}} -
-
- {{this.name}} - {{this.name}} -
+ + + + + {{#each this.fields.head}} + + {{/each}} + + + + {{#each this.fields}} + {{#unless (eq @key "head")}} + + + + {{#each this}} + + {{/each}} + + + {{/unless}} + {{/each}} + +
Charakter +
+
+ {{this.name}} + {{this.name}} +
{{#if this.isLimited}}
{{#each this.attributes}} @@ -51,32 +56,37 @@
{{/each}}
-
-
    - {{#each skills}} -
  • {{this.name}}: {{this.taw}}
  • {{/each}} -
-
    - {{#each advantages}} -
  • {{this.name}} {{#if this.value}} - [{{this.value}}]{{/if}}
  • {{/each}} -
-
{{/if}} - {{#if this.isOwner}} -
-
- {{/if}} - - {{/if}} - {{/each}} +
+ {{ @key}} + + {{#if (eq this "-")}} + + {{else}} + {{this}} + {{/if}} +
- {{/if}} + {{/unless}}
{{> 'systems/DSA_4-1/templates/ui/partial-equipment-group-button.hbs' equipments}}