Manage selective fire

This commit is contained in:
2025-06-15 00:30:24 +02:00
parent e0400793ff
commit 9e4d76298c
35 changed files with 654 additions and 122 deletions

View File

@ -180,6 +180,30 @@ export default class CthulhuEternalUtils {
});
}
static async healingRoll(rollMessage) {
let rollData = rollMessage.rolls[0]?.options?.rollData
let healingFormula = rollData.rollItem.system.healingFormula
let healingMsg = "CTHULHUETERNAL.Label.healingRoll"
if (rollData.resultType === "successCritical") {
healingFormula += " * 2"
}
if (rollData.resultType === "failureCritical") {
healingMsg = "CTHULHUETERNAL.Label.healingRollFailure"
}
// Now display the result in chat message
let roll = new Roll(healingFormula)
await roll.evaluate()
roll.toMessage({
speaker: ChatMessage.getSpeaker({ actor: rollData.actorId }),
flavor: `${game.i18n.localize(healingMsg)} : ${roll.total}`,
rolls: [roll],
options: {
rollData: rollData,
resultType: rollData.resultType
}
})
}
static async damageRoll(rollMessage) {
let rollData = rollMessage.rolls[0]?.options?.rollData
let actor = game.actors.get(rollData.actorId)
@ -187,7 +211,9 @@ export default class CthulhuEternalUtils {
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Label.noActorFound"))
return
}
console.log("Damage roll data", rollData)
rollData.weapon.resultType = rollData.resultType // Keep the result type from the roll message
rollData.weapon.selectiveFireChoice = rollData.selectiveFireChoice // Keep the selected fire choice from the roll message
actor.system.roll("damage", rollData.weapon)
}