From 692867f2ac70d5784d9a27c6c80699b0ec7e7539 Mon Sep 17 00:00:00 2001 From: macniel Date: Sun, 16 Nov 2025 11:41:35 +0100 Subject: [PATCH] finalises missing sidebutton tabs --- package-lock.json | 8 +- package.json | 2 +- .../sheets/character-standalone/liturgies.mjs | 152 +++++++++++++ .../sheets/character-standalone/spells.mjs | 98 +++++++++ src/module/sheets/characterSheet.mjs | 6 +- .../organisms/character-tabs/_spells.scss | 57 +++++ src/templates/actor/character/main-sheet.hbs | 4 +- .../actor/character/standalone/liturgies.hbs | 204 ++++++++++++++++++ .../actor/character/standalone/spells.hbs | 51 +++++ 9 files changed, 574 insertions(+), 8 deletions(-) create mode 100644 src/module/sheets/character-standalone/liturgies.mjs create mode 100644 src/module/sheets/character-standalone/spells.mjs create mode 100644 src/templates/actor/character/standalone/liturgies.hbs create mode 100644 src/templates/actor/character/standalone/spells.hbs diff --git a/package-lock.json b/package-lock.json index 653f0089..f782fa7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "gulp-json-modify": "^1.0.2" }, "devDependencies": { - "@foundryvtt/foundryvtt-cli": "^3.0.0", + "@foundryvtt/foundryvtt-cli": "^3.0.2", "cb": "^0.1.1", "del": "^8.0.1", "fvtt-types": "npm:@league-of-foundry-developers/foundry-vtt-types@^13.346.0-beta.20250812191140", @@ -209,9 +209,9 @@ } }, "node_modules/@foundryvtt/foundryvtt-cli": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@foundryvtt/foundryvtt-cli/-/foundryvtt-cli-3.0.0.tgz", - "integrity": "sha512-OiF4HtnYg5An1ivVxB68mOj5LO5gMHd4uHmC5nWdD8IYxpK0pSYw3t+cHrUYDp+Tic78uwFuHxLyc+ZNeZXulA==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@foundryvtt/foundryvtt-cli/-/foundryvtt-cli-3.0.2.tgz", + "integrity": "sha512-coh4Cf4FD/GHxk2QMsd+3wLMivNeih4rfkbZy8CaYjdlpo6iciFQwxLqznZWtn+5p06zekvS2xLUF55NnbXQDw==", "dev": true, "dependencies": { "chalk": "^5.4.1", diff --git a/package.json b/package.json index 5d99859c..3071030a 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "installToFoundry": "node installToFoundry.mjs" }, "devDependencies": { - "@foundryvtt/foundryvtt-cli": "^3.0.0", + "@foundryvtt/foundryvtt-cli": "^3.0.2", "cb": "^0.1.1", "del": "^8.0.1", "fvtt-types": "npm:@league-of-foundry-developers/foundry-vtt-types@^13.346.0-beta.20250812191140", diff --git a/src/module/sheets/character-standalone/liturgies.mjs b/src/module/sheets/character-standalone/liturgies.mjs new file mode 100644 index 00000000..e88459df --- /dev/null +++ b/src/module/sheets/character-standalone/liturgies.mjs @@ -0,0 +1,152 @@ +import {LiturgyData} from "../../data/miracle/liturgyData.mjs"; + +const {HandlebarsApplicationMixin, DocumentSheetV2} = foundry.applications.api +const {ActorSheetV2} = foundry.applications.sheets + +export class StandaloneLiturgies extends HandlebarsApplicationMixin(ActorSheetV2) { + + /** @inheritDoc */ + static DEFAULT_OPTIONS = { + position: {width: 520, height: 480}, + classes: ['dsa41', 'sheet', 'actor', 'character', 'standalone', 'liturgies'], + tag: 'form', + actions: { + openEmbeddedDocument: StandaloneLiturgies.#openEmbeddedDocument, + openLiturgyDialog: StandaloneLiturgies.#openLiturgyDialog, + + } + } + + /** @inheritDoc */ + static PARTS = { + form: { + template: `systems/DSA_4-1/templates/actor/character/standalone/liturgies.hbs` + } + } + + _actor = null + + constructor(actor) { + super(actor) + this._actor = actor + this.render(true) + } + + static async #openEmbeddedDocument(event, target) { + this._actor?.sheet.options.actions.openEmbeddedDocument.bind(this)(event, target) + } + + static async #openLiturgyDialog(event, target) { + this._actor?.sheet.options.actions.openLiturgyDialog.bind(this)(event, target) + } + + _configureRenderOptions(options) { + super._configureRenderOptions(options) + + options.window.title = `${this.document.name}: Segnungen und Liturgien` + + return options + } + + async _prepareContext(context, options, object) { + + const actorData = this.document + context.system = actorData.system + context.flags = actorData.flags + context.derived = this.document.system + context.originalName = actorData.name + context.name = context.derived.name ?? actorData.name + + context.effects = actorData.effects ?? [] + context.liturgies = []; + context.blessings = []; + + actorData.itemTypes.Blessing.forEach((item, index) => { + context.blessings.push({ + deity: item.system.gottheit, + value: item.system.wert + }) + }) + actorData.itemTypes.Liturgy.forEach((item, index) => { + + context.blessings.forEach(({deity, value}) => { + let insertObject = context.liturgies.find(p => p.deity === deity); + if (!insertObject) { + insertObject = { + deity: deity, + lkp: value, + O: [], + I: [], + II: [], + III: [], + IV: [], + V: [], + VI: [], + VII: [], + VIII: [], + "NA": [], + countO: 1, + countI: 1, + countII: 1, + countIII: 1, + countIV: 1, + countV: 1, + countVI: 1, + countVII: 1, + countVIII: 1, + countNA: 0, + total: 3, + + } + context.liturgies.push(insertObject); + } + + // sort by rank + const rankData = LiturgyData.getRankOfLiturgy(item.system, deity) + if (rankData) { + console.log(rankData) + let {index, name, lkp, mod, costKaP} = rankData; + + insertObject["count" + name] = insertObject["count" + name] + 1; + + insertObject[name]?.push({ + id: item._id, + name: item.name, + lkpReq: lkp, + lkpMod: mod, + costKaP, + fav: item.getFlag("DSA_4-1", "favourite"), + rank: index, // get effective liturgy rank based on deity + liturgiekenntnis: deity, + }) + insertObject.total = insertObject.total + 2; + + } + }) + }) + + + // clean up counter + Object.values(context.liturgies).forEach((litObject) => { + + if (litObject.I.length === 0) litObject.countI = false; + if (litObject.II.length === 0) litObject.countII = false; + if (litObject.III.length === 0) litObject.countIII = false; + if (litObject.IV.length === 0) litObject.countIV = false; + if (litObject.V.length === 0) litObject.countV = false; + if (litObject.VI.length === 0) litObject.countVI = false; + if (litObject.VII.length === 0) litObject.countVII = false; + if (litObject.VIII.length === 0) litObject.countVIII = false; + if (litObject.NA.length === 0) litObject.countNA = false; + + + }) + + context.hasLiturgies = context.blessings.length > 0; + + return context + } + + _onRender(context, options) { + } +} \ No newline at end of file diff --git a/src/module/sheets/character-standalone/spells.mjs b/src/module/sheets/character-standalone/spells.mjs new file mode 100644 index 00000000..57b822e8 --- /dev/null +++ b/src/module/sheets/character-standalone/spells.mjs @@ -0,0 +1,98 @@ +const {HandlebarsApplicationMixin, DocumentSheetV2} = foundry.applications.api +const {ActorSheetV2} = foundry.applications.sheets + +export class StandaloneSpells extends HandlebarsApplicationMixin(ActorSheetV2) { + + /** @inheritDoc */ + static DEFAULT_OPTIONS = { + position: {width: 520, height: 480}, + classes: ['dsa41', 'sheet', 'actor', 'character', 'standalone', 'spells'], + tag: 'form', + actions: { + openEmbeddedDocument: StandaloneSpells.#openEmbeddedDocument, + + } + } + + /** @inheritDoc */ + static PARTS = { + form: { + template: `systems/DSA_4-1/templates/actor/character/standalone/spells.hbs` + } + } + + _actor = null + + constructor(actor) { + super(actor) + this._actor = actor + this.render(true) + } + + static async #openEmbeddedDocument(event, target) { + this._actor?.sheet.options.actions.openEmbeddedDocument.bind(this)(event, target) + } + + _configureRenderOptions(options) { + super._configureRenderOptions(options) + + options.window.title = `${this.document.name}: Zauber und Rituale` + + return options + } + + async _prepareContext(context, options, object) { + + const actorData = this.document + context.spells = [] + context.system = actorData.system + context.flags = actorData.flags + context.derived = this.document.system + context.originalName = actorData.name + context.name = context.derived.name ?? actorData.name + context.effects = actorData.effects ?? [] + + const cleanUpMerkmal = (merkmale) => { + return merkmale.split(",").map((merkmal) => merkmal.trim()) + } + + const prepareEigenschaftRoll = (actorData, name) => { + if (name && name !== "*") { + return actorData.system.attribute[name.toLowerCase()].aktuell + } else { + return 0 + } + } + + actorData.itemTypes["Spell"].forEach((item, index) => { + + const eigenschaften = item.system.probe; + const werte = [ + {name: eigenschaften[0], value: prepareEigenschaftRoll(actorData, eigenschaften[0])}, + {name: eigenschaften[1], value: prepareEigenschaftRoll(actorData, eigenschaften[1])}, + {name: eigenschaften[2], value: prepareEigenschaftRoll(actorData, eigenschaften[2])} + ] + context.spells.push({ + id: item._id, + name: item.name, + zfw: item.system.zfw, + hauszauber: item.system.hauszauber, + merkmal: cleanUpMerkmal(item.system.merkmal), + rollEigenschaft1: werte[0].value, + rollEigenschaft2: werte[1].value, + rollEigenschaft3: werte[2].value, + eigenschaft1: werte[0].name, + eigenschaft2: werte[1].name, + eigenschaft3: werte[2].name, + fav: item.getFlag("DSA_4-1", "favourite") + }) + + }) + context.hasSpells = context.spells.length > 0 + + return context + } + + _onRender(context, options) { + } +} \ No newline at end of file diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index 329bdf21..f25d4caf 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -19,6 +19,8 @@ import * as EquipmentDocument from "../documents/equipment.mjs"; import {StandaloneADVSF} from "./character-standalone/advsf.mjs"; import {StandaloneSkills} from "./character-standalone/skills.mjs"; import {Bagpack} from "./character-standalone/bagpack.mjs"; +import {StandaloneSpells} from "./character-standalone/spells.mjs"; +import {StandaloneLiturgies} from "./character-standalone/liturgies.mjs"; const {HandlebarsApplicationMixin, DocumentSheetV2} = foundry.applications.api const {ActorSheetV2} = foundry.applications.sheets @@ -62,7 +64,9 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { toggleFav: CharacterSheet.toggleFav, openStandaloneADVSF: CharacterSheet.#openStandaloneADVSF, openStandaloneSkills: CharacterSheet.#openStandaloneSkills, - openBagpack: CharacterSheet.#openBagpack + openBagpack: CharacterSheet.#openBagpack, + openStandaloneSpells: CharacterSheet.#openStandaloneSpells, + openStandaloneLiturgies: CharacterSheet.#openStandaloneLiturgies, } } diff --git a/src/style/organisms/character-tabs/_spells.scss b/src/style/organisms/character-tabs/_spells.scss index 8a47be00..7c27decb 100644 --- a/src/style/organisms/character-tabs/_spells.scss +++ b/src/style/organisms/character-tabs/_spells.scss @@ -87,4 +87,61 @@ padding: 0 4px; } } +} + +.mini-spells { + height: 100%; + display: flex; + flex-direction: column; + + .table-header { + display: grid; + grid-template-columns: 1fr 100px 30px; + padding: 0 8px; + font-weight: bold; + } + + .scrollable-table { + overflow-x: hidden; + overflow-y: auto; + + thead { + display: none; + + } + + + tr { + + td:nth-child(1) { + width: 32px; + } + + td:nth-child(3) { + width: 100px; + } + + td:nth-child(4) { + width: 30px; + } + + .spell.rollable { + position: relative; + + svg { + + position: absolute; + width: 32px; + height: 32px; + z-index: 2; + top: 0; + left: -4px; + + path { + fill: colour.$zauber-color; + } + } + } + } + } } \ No newline at end of file diff --git a/src/templates/actor/character/main-sheet.hbs b/src/templates/actor/character/main-sheet.hbs index 8f88ea7c..611361ed 100644 --- a/src/templates/actor/character/main-sheet.hbs +++ b/src/templates/actor/character/main-sheet.hbs @@ -135,9 +135,9 @@ {{#if this.hasLiturgies}} - {{/if}} + {{/if}} {{#if this.hasSpells}} - {{/if}} + {{/if}} diff --git a/src/templates/actor/character/standalone/liturgies.hbs b/src/templates/actor/character/standalone/liturgies.hbs new file mode 100644 index 00000000..e8b8cb52 --- /dev/null +++ b/src/templates/actor/character/standalone/liturgies.hbs @@ -0,0 +1,204 @@ +
+
+ +
+ + + von + +
+
+
+ {{#each this.liturgies}} + + + + + + + + + + + + + + {{#each this.O}} + + + + + + {{/each}} + {{#if this.countI}} + + + + {{#each this.I}} + + + + + + {{/each}} + {{/if}} + {{#if this.countII}} + + + + {{#each this.II}} + + + + + {{/each}} + {{/if}} + {{#if this.countIII}} + + + + {{#each this.III}} + + + + + {{/each}} + {{/if}} + {{#if this.countIV}} + + + + {{#each this.IV}} + + + + + {{/each}}{{/if}} + {{#if this.countV}} + + + + {{#each this.V}} + + + + + {{/each}} + {{/if}} + {{#if this.countVI}} + + + + {{#each this.VI}} + + + + + {{/each}} + {{/if}}{{#if this.countVII}} + + + + {{#each this.VII}} + + + + + {{/each}} + {{/if}}{{#if this.countVIII}} + + + + {{#each this.VIII}} + + + + + {{/each}} + {{/if}} + +
Liturgiekenntnis: {{this.lkp}}
+ {{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }} + + {{this.name}}
+ {{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }} + + {{this.name}}
+ {{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }} + {{this.name}}
+ {{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }} + {{this.name}}
+ {{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }} + {{this.name}}
+ {{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }} + {{this.name}}
+ {{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }} + {{this.name}}
+ {{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }} + {{this.name}}
+ {{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }} + {{this.name}}
+ {{/each}} +
\ No newline at end of file diff --git a/src/templates/actor/character/standalone/spells.hbs b/src/templates/actor/character/standalone/spells.hbs new file mode 100644 index 00000000..2ed2e4b5 --- /dev/null +++ b/src/templates/actor/character/standalone/spells.hbs @@ -0,0 +1,51 @@ +
+
+ +
+ + + von + +
+
+ + +
+
+ +
+ + Zaubername + + + Probe + + ZfW +
+
+ + + + + + + + + + + {{#each this.spells}} + + + + + + + {{/each}} + +
ZaubernameProbeZfW
+ {{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }} + + {{this.name}}{{this.eigenschaft1}} {{this.eigenschaft2}} {{this.eigenschaft3}}{{this.zfw}}
+
+ +
\ No newline at end of file