Combat initiativ

This commit is contained in:
2025-01-18 19:26:14 +01:00
parent 4e673913a1
commit 4198bf82be
28 changed files with 102 additions and 82 deletions

View File

@ -565,8 +565,10 @@ export default class LethalFantasyRoll extends Roll {
},
{
action: "cancel",
label: "Other action, no weapon progression dice",
callback: (event, button, dialog) => { return null; }
label: "Other action, no progression dice",
callback: (event, button, dialog) => {
return null;
}
}
],
rejectClose: false // Click on Close button will not launch an error
@ -574,12 +576,16 @@ export default class LethalFantasyRoll extends Roll {
console.log("RollContext", rollContext)
if (rollContext === null || !rollContext?.progressionDiceId) {
let combat = game.combats.get(options.combatId)
let combatant = combat.combatants.get(options.combatantId)
combatant.update({ 'system.progressionCount': 1 })
return
}
// Get the weapons from the actor items
let actor = game.actors.get(options.actorId)
let weapon = actor.items.find(i => i.type === "weapon" && i.id === rollContext.progressionDiceId)
let isMonster = actor.type === "monster"
// Get the dice and roll it
let formula = weapon.system.combatProgressionDice
let roll = new Roll(formula)
@ -592,7 +598,7 @@ export default class LethalFantasyRoll extends Roll {
if (roll.total <= max ) {
// Notify that the player can act now with a chat message
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionOK", { name: actor.name, weapon: weapon.name, roll: roll.total })
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionOK", { isMonster, name: actor.name, weapon: weapon.name, roll: roll.total })
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: actor }) })
// Update the combatant progression count
let combat = game.combats.get(options.combatId)
@ -600,7 +606,7 @@ export default class LethalFantasyRoll extends Roll {
combatant.update({ 'system.progressionCount': 0 })
} else {
// Notify that the player cannot act now with a chat message
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionKO", { name: actor.name, weapon: weapon.name, roll: roll.total })
let message = game.i18n.format("LETHALFANTASY.Notifications.messageProgressionKO", { isMonster, name: actor.name, weapon: weapon.name, roll: roll.total })
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: actor }) })
}
}