From f8d101bfe38a758a9bd96a1ef3b823ffb51d41b7 Mon Sep 17 00:00:00 2001 From: macniel Date: Wed, 4 Feb 2026 19:13:50 +0100 Subject: [PATCH] adds spell and liturgy rolls to dice engine --- src/module/dialog/liturgyDialog.mjs | 35 ++++++++++++-- src/module/dialog/spellDialog.mjs | 51 ++++++++++++++++++++- src/module/setup/config.mjs | 6 ++- src/module/sheets/characterSheet.mjs | 1 + src/templates/chat/liturgy-chat-message.hbs | 13 ++++++ src/templates/chat/spell-chat-message.hbs | 21 +++++++++ 6 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 src/templates/chat/liturgy-chat-message.hbs create mode 100644 src/templates/chat/spell-chat-message.hbs diff --git a/src/module/dialog/liturgyDialog.mjs b/src/module/dialog/liturgyDialog.mjs index 23fea809..1c54a152 100644 --- a/src/module/dialog/liturgyDialog.mjs +++ b/src/module/dialog/liturgyDialog.mjs @@ -1,5 +1,6 @@ import {LiturgyData} from "../data/miracle/liturgyData.mjs"; import {Talent} from "../data/talent.mjs"; +import {evaluateRoll} from "../globals/DSARoll.mjs"; const { ApplicationV2, @@ -137,14 +138,15 @@ export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) { const castingTime = this.#normalizeCastingTime(this._liturgy) - //TODO push it into the sun eeerh cooldown queue if (castingTime > 0) { const cooldowns = this._actor.system.cooldowns let m = (queue, data) => { + new game.DSA41.Talent({ name: data.title, taw: data.taw, mod: data.mod, + owner: data.actor, eigenschaften: { mu: data.eigenschaften.mu, in: data.eigenschaften.in, @@ -154,11 +156,33 @@ export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) { eigenschaft2: "in", eigenschaft3: "ch" }).evaluate("publicroll").then(result => { + const context = { + liturgy: data.title, + lkw: data.taw, + mod: data.mod, + owner: data.actor, + lkp: result.tap, + meisterlich: result.meisterlich, + patzer: result.patzer + } + + if(result.tap>0) { + context.remaining = Math.abs(result.tap) + } else if (result.tap===0) { + context.remaining = 1 + } else { + context.missing = Math.abs(result.tap) + } + game.DSA41.displayRoll( + result.evaluated, + game.user, + data.actor, + false, + false, + 'systems/DSA_4-1/templates/chat/liturgy-chat-message.hbs', + context + ) - result.evaluatedRoll.toMessage({ - speaker: ChatMessage.getSpeaker({actor: game.actors.get(data.actorId)}), - flavor: `Liturgie: ${data.title}
LkP*: ${result.tap}
${result.meisterlich ? "Meisterlich" : ""}${result.patzer ? "Petzer" : ""}
${data.variant}`, - }) }) } cooldowns.push({ @@ -169,6 +193,7 @@ export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) { title: this._liturgy.name, taw: lkp, mod: mod, + owner: this._actor._id, actorId: this._actor._id, variant: this._variation.effect, eigenschaften: { diff --git a/src/module/dialog/spellDialog.mjs b/src/module/dialog/spellDialog.mjs index 8ddfe7b8..11d2e9b5 100644 --- a/src/module/dialog/spellDialog.mjs +++ b/src/module/dialog/spellDialog.mjs @@ -2,6 +2,7 @@ import {ATTRIBUTE} from "../data/attribute.mjs"; import {spoModData, leadingAttribute} from "../data/spellData/spellData.mjs"; import {evaluateRoll} from "../globals/DSARoll.mjs"; +import {displayRoll} from "../globals/displayRoll.js"; const { ApplicationV2, @@ -53,6 +54,7 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) { _costModel = {} _castTimeModel = {} _spoMods = {} + _spell = null displayModResult = 0 constructor(actor, spellId) { @@ -257,6 +259,53 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) { owner: this._actor } ) + + const taw = this._spell.system.zfw + + let spellDie3 = this._spell.system.probe[2] + + if (spellDie3 === "*") { + spellDie3 = this._spellDie + } + + const context = { + spell: this._spell, + zfp: result.tap, + + ergebnis: [ + { + eigenschaft: this._spell.system.probe[0], + eigenschaftWert: this._actor.system.attribute[this._spell.system.probe[0].toLowerCase()].aktuell, + wuerfelErgebnis: result.evaluated.terms[0].results[0].result, + + }, + { + eigenschaft: this._spell.system.probe[1], + eigenschaftWert: this._actor.system.attribute[this._spell.system.probe[1].toLowerCase()].aktuell, + wuerfelErgebnis: result.evaluated.terms[0].results[1].result, + + }, + { + eigenschaft: this._spell.system.probe[2], + eigenschaftWert: this._actor.system.attribute[spellDie3.toLowerCase()].aktuell, + wuerfelErgebnis: result.evaluated.terms[0].results[2].result, + } + ], + patzer: result.patzer, + meisterlich: result.meisterlich, + } + + + if(result.tap>0) { + context.remaining = Math.abs(result.tap) + } else if (result.tap===0) { + context.remaining = 1 + } else { + context.missing = Math.abs(result.tap) + } + + displayRoll(result.evaluated, game.user, this._actor, true, true, 'systems/DSA_4-1/templates/chat/spell-chat-message.hbs', context) +/* if (result.tap >= 0) { // erfolg await result.evaluated.toMessage({ speaker: ChatMessage.getSpeaker({actor: this._actor}), @@ -267,7 +316,7 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) { speaker: ChatMessage.getSpeaker({actor: this._actor}), flavor: ` ${result.meisterlich ? 'Gepatzt' : ''} mit ${Math.abs(result.tap)} Punkten daneben`, }) - } + }*/ this.zfp = result.tap this.zfpDetermined = true diff --git a/src/module/setup/config.mjs b/src/module/setup/config.mjs index a69c1f3f..120a5ff4 100644 --- a/src/module/setup/config.mjs +++ b/src/module/setup/config.mjs @@ -21,6 +21,8 @@ import {Character} from "../documents/character.mjs"; import {currency} from "../handlebar-helpers/currency.mjs"; import {DeityDataModel} from "../data/deity.mjs"; import {ItemBrowserDialog} from "../dialog/itemBrowserDialog.mjs"; +import {displayRoll} from "../globals/displayRoll.js"; +import {evaluateRoll} from "../globals/DSARoll.mjs"; function initGlobalAccess() { @@ -33,7 +35,9 @@ function initGlobalAccess() { BattleDialog, ItemBrowserDialog, Talent, - displayCurrency: currency + displayCurrency: currency, + displayRoll, + evaluateRoll } } diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index cc9b2a7f..acf22242 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -23,6 +23,7 @@ import {StandaloneSpells} from "./character-standalone/spells.mjs"; import {StandaloneLiturgies} from "./character-standalone/liturgies.mjs"; import {StandaloneHealth} from "./character-standalone/health.mjs"; import {SpellDialog} from "../dialog/spellDialog.mjs"; +import {displayRoll} from "../globals/displayRoll.js"; const {HandlebarsApplicationMixin, DocumentSheetV2} = foundry.applications.api const {ActorSheetV2} = foundry.applications.sheets diff --git a/src/templates/chat/liturgy-chat-message.hbs b/src/templates/chat/liturgy-chat-message.hbs new file mode 100644 index 00000000..97d56a5b --- /dev/null +++ b/src/templates/chat/liturgy-chat-message.hbs @@ -0,0 +1,13 @@ + + +
+
{{liturgy}} (LkP*: {{lkp}})
+
Modifiziert: {{mod}}
+
Gewürfelt:
+
+ {{#if missing}} +
Gefehlt: {{missing}}
+ {{else}} +
Übrig: {{remaining}}
+ {{/if}} +
\ No newline at end of file diff --git a/src/templates/chat/spell-chat-message.hbs b/src/templates/chat/spell-chat-message.hbs new file mode 100644 index 00000000..3951e391 --- /dev/null +++ b/src/templates/chat/spell-chat-message.hbs @@ -0,0 +1,21 @@ + + +
+
{{spell.name}} (ZfP*: {{zfp}})
+
Modifiziert: {{mod}}
+
Gewürfelt:
+
+ {{#each ergebnis}} +
+ {{eigenschaft}} ({{eigenschaftWert}}) + {{wuerfelErgebnis}} +
+ {{/each}} +
+
+ {{#if missing}} +
Gefehlt: {{missing}}
+ {{else}} +
Übrig: {{remaining}}
+ {{/if}} +
\ No newline at end of file