UPdate and fixes for roll in combats
Release Creation / build (release) Successful in 43s

This commit is contained in:
2026-05-18 20:26:39 +02:00
parent 7279cd752d
commit 96306623e5
47 changed files with 329 additions and 177 deletions
+17 -10
View File
@@ -119,18 +119,12 @@ export class LethalFantasyCombat extends Combat {
}
async rollInitiative(ids, options) {
console.log("%%%%%%%%% Roll Initiative", ids, options);
ids = typeof ids === "string" ? [ids] : ids;
let messages = [];
let rollMode = game.settings.get("core", "rollMode");
let updates = [];
for (let cId of ids) {
const c = this.combatants.get(cId);
const playerOwner = game.users.find(u => u.active && !u.isGM && u.character?.id === c.actor.id);
if (game.user.isGM && playerOwner) {
console.log("Rolling initiative for", c.actor.name);
game.socket.emit(`system.${SYSTEM.id}`, { type: "rollInitiative", userId: playerOwner.id, actorId: c.actor.id, combatId: this.id, combatantId: c.id });
} else {
await c.actor.system.rollInitiative(this.id, c.id);
@@ -165,6 +159,8 @@ export class LethalFantasyCombat extends Combat {
} else {
ui.notifications.info(`No monsters act yet — earliest monster initiative is ${earliest} (current round: ${currentRound}).`);
}
} else {
this._monsterProgressionRolledRound = currentRound;
}
}
@@ -189,15 +185,12 @@ export class LethalFantasyCombat extends Combat {
}
async nextTurn() {
console.log("NEXT TURN");
let turn = this.turn ?? -1;
let skipDefeated = this.settings.skipDefeated;
// Determine the next turn number
let next = null;
for (let [i, t] of this.turns.entries()) {
console.log("Turn", t);
if (i <= turn) continue;
if (skipDefeated && t.isDefeated) continue;
next = i;
@@ -221,7 +214,6 @@ export class LethalFantasyCombat extends Combat {
this.turnsDone = false
let turn = this.turn === null ? null : 0; // Preserve the fact that it's no-one's turn currently.
console.log("ROUND", this);
let advanceTime = Math.max(this.turns.length - this.turn, 0) * CONFIG.time.turnTime;
advanceTime += CONFIG.time.roundTime;
@@ -239,6 +231,21 @@ export class LethalFantasyCombat extends Combat {
return this;
}
// Warn if eligible monsters have not rolled progression dice this round
const eligibleMonsters = this.combatants.filter(
c => c.actor?.type === "monster" && !c.isDefeated && c.initiative !== null && this.round >= c.initiative
);
if (eligibleMonsters.length > 0 && this._monsterProgressionRolledRound !== this.round) {
const proceed = await foundry.applications.api.DialogV2.confirm({
window: { title: game.i18n.localize("LETHALFANTASY.Combat.monstersNotRolledTitle") },
content: `<p>${game.i18n.localize("LETHALFANTASY.Combat.monstersNotRolledMsg")}</p>`,
yes: { label: game.i18n.localize("LETHALFANTASY.Combat.proceedYes") },
no: { label: game.i18n.localize("LETHALFANTASY.Combat.proceedNo") },
rejectClose: false,
});
if (!proceed) return this;
}
for (let c of this.combatants) {
if (nextRound >= c.initiative) {
if (c.actor.type === "monster") continue; // Monsters roll manually via the "Roll Monsters" button
+4 -1
View File
@@ -142,11 +142,14 @@ export async function rollFreeDie(dieType, count = 1, explode = false) {
`
const rollMode = game.settings.get("core", "rollMode")
// Normalize old-style rollMode keys (v12/v13) to new-style (v14), fallback to "public"
const modeMap = { publicroll: "public", gmroll: "gm", blindroll: "blind", selfroll: "self" }
const mode = modeMap[rollMode] ?? rollMode ?? "public"
const msgData = {
speaker: ChatMessage.getSpeaker(),
content,
sound: CONFIG.sounds.dice,
mode,
}
ChatMessage.applyMode(msgData, rollMode)
await ChatMessage.create(msgData)
}