Fix initiative again
Release Creation / build (release) Successful in 43s

This commit is contained in:
2026-05-18 07:58:28 +02:00
parent db3e8b5d35
commit 7279cd752d
33 changed files with 120 additions and 95 deletions
+19 -2
View File
@@ -143,10 +143,27 @@ export class LethalFantasyCombat extends Combat {
/** Roll progression dice for all eligible monster combatants this round. Called manually by the GM. */
async rollMonsterProgression() {
const currentRound = this.round;
for (let c of this.combatants) {
if (c.actor.type !== "monster") continue;
const monsters = this.combatants.filter(c => c.actor?.type === "monster" && !c.isDefeated);
if (monsters.length === 0) {
ui.notifications.warn("No monsters in combat.");
return;
}
let rolled = 0;
for (let c of monsters) {
if (c.initiative !== null && currentRound >= c.initiative) {
await c.actor.system.rollProgressionDice(this.id, c.id);
rolled++;
}
}
if (rolled === 0) {
const earliest = monsters.reduce((min, c) => (c.initiative !== null && c.initiative < min) ? c.initiative : min, Infinity);
if (earliest === Infinity) {
ui.notifications.warn("Monsters have no initiative set. Roll initiative first.");
} else {
ui.notifications.info(`No monsters act yet — earliest monster initiative is ${earliest} (current round: ${currentRound}).`);
}
}
}
@@ -259,9 +259,11 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
async _onRoll(event, target) {
if (this.isEditMode) return
const rollType = event.target.dataset.rollType
let rollKey = event.target.dataset.rollKey;
let rollDice = event.target.dataset?.rollDice;
const el = event.currentTarget
const rollType = el.dataset.rollType
if (!rollType) return
let rollKey = el.dataset.rollKey
let rollDice = el.dataset.rollDice
this.actor.prepareRoll(rollType, rollKey, rollDice)
+3 -1
View File
@@ -115,7 +115,9 @@ export default class LethalFantasyMonsterSheet extends LethalFantasyActorSheet {
}
static async #onRollInitiative(event, target) {
await this.document.system.rollInitiative(event, target)
const combat = game.combat
const combatant = combat?.combatants.find(c => c.actorId === this.document.id)
await this.document.system.rollInitiative(combat?.id, combatant?.id)
}
getBestWeaponClassSkill(skills, rollType, multiplier = 1.0) {