adds spell and liturgy rolls to dice engine

main 0.8.0
macniel 2026-02-04 19:13:50 +01:00
parent 89848aa849
commit f8d101bfe3
6 changed files with 120 additions and 7 deletions

View File

@ -1,5 +1,6 @@
import {LiturgyData} from "../data/miracle/liturgyData.mjs"; import {LiturgyData} from "../data/miracle/liturgyData.mjs";
import {Talent} from "../data/talent.mjs"; import {Talent} from "../data/talent.mjs";
import {evaluateRoll} from "../globals/DSARoll.mjs";
const { const {
ApplicationV2, ApplicationV2,
@ -137,14 +138,15 @@ export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) {
const castingTime = this.#normalizeCastingTime(this._liturgy) const castingTime = this.#normalizeCastingTime(this._liturgy)
//TODO push it into the sun eeerh cooldown queue
if (castingTime > 0) { if (castingTime > 0) {
const cooldowns = this._actor.system.cooldowns const cooldowns = this._actor.system.cooldowns
let m = (queue, data) => { let m = (queue, data) => {
new game.DSA41.Talent({ new game.DSA41.Talent({
name: data.title, name: data.title,
taw: data.taw, taw: data.taw,
mod: data.mod, mod: data.mod,
owner: data.actor,
eigenschaften: { eigenschaften: {
mu: data.eigenschaften.mu, mu: data.eigenschaften.mu,
in: data.eigenschaften.in, in: data.eigenschaften.in,
@ -154,11 +156,33 @@ export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) {
eigenschaft2: "in", eigenschaft2: "in",
eigenschaft3: "ch" eigenschaft3: "ch"
}).evaluate("publicroll").then(result => { }).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}<br/>LkP*: ${result.tap}<br/>${result.meisterlich ? "Meisterlich" : ""}${result.patzer ? "Petzer" : ""}<br/>${data.variant}`,
})
}) })
} }
cooldowns.push({ cooldowns.push({
@ -169,6 +193,7 @@ export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) {
title: this._liturgy.name, title: this._liturgy.name,
taw: lkp, taw: lkp,
mod: mod, mod: mod,
owner: this._actor._id,
actorId: this._actor._id, actorId: this._actor._id,
variant: this._variation.effect, variant: this._variation.effect,
eigenschaften: { eigenschaften: {

View File

@ -2,6 +2,7 @@
import {ATTRIBUTE} from "../data/attribute.mjs"; import {ATTRIBUTE} from "../data/attribute.mjs";
import {spoModData, leadingAttribute} from "../data/spellData/spellData.mjs"; import {spoModData, leadingAttribute} from "../data/spellData/spellData.mjs";
import {evaluateRoll} from "../globals/DSARoll.mjs"; import {evaluateRoll} from "../globals/DSARoll.mjs";
import {displayRoll} from "../globals/displayRoll.js";
const { const {
ApplicationV2, ApplicationV2,
@ -53,6 +54,7 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
_costModel = {} _costModel = {}
_castTimeModel = {} _castTimeModel = {}
_spoMods = {} _spoMods = {}
_spell = null
displayModResult = 0 displayModResult = 0
constructor(actor, spellId) { constructor(actor, spellId) {
@ -257,6 +259,53 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
owner: this._actor 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 if (result.tap >= 0) { // erfolg
await result.evaluated.toMessage({ await result.evaluated.toMessage({
speaker: ChatMessage.getSpeaker({actor: this._actor}), speaker: ChatMessage.getSpeaker({actor: this._actor}),
@ -267,7 +316,7 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
speaker: ChatMessage.getSpeaker({actor: this._actor}), speaker: ChatMessage.getSpeaker({actor: this._actor}),
flavor: ` ${result.meisterlich ? 'Gepatzt' : ''} mit ${Math.abs(result.tap)} Punkten daneben`, flavor: ` ${result.meisterlich ? 'Gepatzt' : ''} mit ${Math.abs(result.tap)} Punkten daneben`,
}) })
} }*/
this.zfp = result.tap this.zfp = result.tap
this.zfpDetermined = true this.zfpDetermined = true

View File

@ -21,6 +21,8 @@ import {Character} from "../documents/character.mjs";
import {currency} from "../handlebar-helpers/currency.mjs"; import {currency} from "../handlebar-helpers/currency.mjs";
import {DeityDataModel} from "../data/deity.mjs"; import {DeityDataModel} from "../data/deity.mjs";
import {ItemBrowserDialog} from "../dialog/itemBrowserDialog.mjs"; import {ItemBrowserDialog} from "../dialog/itemBrowserDialog.mjs";
import {displayRoll} from "../globals/displayRoll.js";
import {evaluateRoll} from "../globals/DSARoll.mjs";
function initGlobalAccess() { function initGlobalAccess() {
@ -33,7 +35,9 @@ function initGlobalAccess() {
BattleDialog, BattleDialog,
ItemBrowserDialog, ItemBrowserDialog,
Talent, Talent,
displayCurrency: currency displayCurrency: currency,
displayRoll,
evaluateRoll
} }
} }

View File

@ -23,6 +23,7 @@ import {StandaloneSpells} from "./character-standalone/spells.mjs";
import {StandaloneLiturgies} from "./character-standalone/liturgies.mjs"; import {StandaloneLiturgies} from "./character-standalone/liturgies.mjs";
import {StandaloneHealth} from "./character-standalone/health.mjs"; import {StandaloneHealth} from "./character-standalone/health.mjs";
import {SpellDialog} from "../dialog/spellDialog.mjs"; import {SpellDialog} from "../dialog/spellDialog.mjs";
import {displayRoll} from "../globals/displayRoll.js";
const {HandlebarsApplicationMixin, DocumentSheetV2} = foundry.applications.api const {HandlebarsApplicationMixin, DocumentSheetV2} = foundry.applications.api
const {ActorSheetV2} = foundry.applications.sheets const {ActorSheetV2} = foundry.applications.sheets

View File

@ -0,0 +1,13 @@
<div>
<div>{{liturgy}} (LkP*: {{lkp}})</div>
<div>Modifiziert: {{mod}}</div>
<div>Gewürfelt:</div>
<hr>
{{#if missing}}
<div>Gefehlt: {{missing}}</div>
{{else}}
<div>Übrig: {{remaining}}</div>
{{/if}}
</div>

View File

@ -0,0 +1,21 @@
<div>
<div>{{spell.name}} (ZfP*: {{zfp}})</div>
<div>Modifiziert: {{mod}}</div>
<div>Gewürfelt:</div>
<section class="die">
{{#each ergebnis}}
<div>
<span class="provided {{#if reduced}}modified{{/if}}">{{eigenschaft}} ({{eigenschaftWert}})</span>
<span class="value">{{wuerfelErgebnis}}</span>
</div>
{{/each}}
</section>
<hr>
{{#if missing}}
<div>Gefehlt: {{missing}}</div>
{{else}}
<div>Übrig: {{remaining}}</div>
{{/if}}
</div>