#80 adds a temporary solution to quickly roll Initiative on a given Weapon

main
macniel 2026-03-12 19:26:28 +01:00
parent b459c96961
commit efb9a415e4
3 changed files with 23 additions and 2 deletions

View File

@ -24,6 +24,7 @@ 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";
import {evaluateRoll} from "../globals/DSARoll.mjs";
const {HandlebarsApplicationMixin, DocumentSheetV2} = foundry.applications.api
const {ActorSheetV2} = foundry.applications.sheets
@ -73,7 +74,8 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
openStandaloneLiturgies: CharacterSheet.#openStandaloneLiturgies,
openStandaloneHealth: CharacterSheet.#openStandaloneHealth,
setWounds: CharacterSheet.#setWounds,
switchSet: CharacterSheet.#switchSet
switchSet: CharacterSheet.#switchSet,
openInitiative: CharacterSheet.#openInitiative,
}
}
@ -157,6 +159,18 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
new AttributeDialog(this.document, target.dataset.itemId).render(true)
}
// TODO: add combat statistics and dialog
static async #openInitiative(event, target) {
const {formula} = target.dataset
const evaluated = await new Roll(formula.replace("w", "d")).evaluate()
const context = {
formula,
initiativeRolled: evaluated.terms[0].results[0].result,
total: evaluated.total
}
await displayRoll(evaluated, game.user, this.document, false, false, 'systems/DSA_4-1/templates/chat/initiative-message.hbs', context)
}
static async #progressCooldown(event, target) {
const {cooldownId} = target.dataset
const cooldowns = this.document.system.cooldowns

View File

@ -91,7 +91,8 @@
{{/if}}
{{#if this.ini}}
<div data-tooltip="{{localize "WEAPON.initiative" weapon=this.name}}"
class="ini sidebar-element rollable" data-action="openInitiative"><label>INI</label>
class="ini sidebar-element rollable" data-action="openInitiative" data-formula="{{this.ini}}">
<label>INI</label>
<div class="formula">{{this.ini}}</div>
</div>
{{/if}}

View File

@ -0,0 +1,6 @@
<div>
<div>Formel: {{formula}}</div>
<div>Gewürfelt: {{initiativeRolled}}</div>
<hr/>
<div>Initiative: {{total}}</div>
</div>