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) {
+1 -1
View File
@@ -279,7 +279,7 @@ export default class LethalFantasyActor extends Actor {
break
default:
ui.notifications.error(game.i18n.localize("LETHALFANTASY.Notifications.rollTypeNotFound") + String(rollType))
break
return
}
// In all cases
+1 -1
View File
@@ -321,7 +321,7 @@ export default class LethalFantasyRoll extends Roll {
}
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes);
console.log("Roll mode", rollModes)
const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes,
+5
View File
@@ -356,6 +356,11 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
}
}
if (weaponsChoices.length === 0) {
ui.notifications.warn(`${this.parent.name} has no weapons or spells available for combat. Add a weapon to the character sheet first.`)
return
}
let roll = await LethalFantasyRoll.promptCombatAction({
actorId: this.parent.id,
actorName: this.parent.name,
-1
View File
@@ -284,7 +284,6 @@ export default class LethalFantasyMonster extends foundry.abstract.TypeDataModel
// In all cases
if (rollTarget) {
rollTarget.tokenId = tokenId
console.log(rollTarget)
await this.roll(rollType, rollTarget, defenderId, defenderTokenId, extraShieldDr)
}
}
+1 -1
View File
@@ -1195,7 +1195,7 @@ export default class LethalFantasyUtils {
ChatMessage.create({
user: game.user.id,
speaker: { alias: targetActor.name },
rollMode: "gmroll",
mode: "gmroll",
content: messageContent
})
}