Fix roll options
All checks were successful
Release Creation / build (release) Successful in 1m8s

This commit is contained in:
2025-08-26 22:14:45 +02:00
parent 188501423a
commit d80e3e4658
13 changed files with 60 additions and 34 deletions

View File

@@ -93,6 +93,7 @@ export default class FTLNomadRoll extends Roll {
break
case "damage":
options.weapon = foundry.utils.duplicate(options.rollItem)
formula = options.weapon.system.damage
break
case "weapon":
options.weapon = foundry.utils.duplicate(options.rollItem)
@@ -212,11 +213,30 @@ export default class FTLNomadRoll extends Roll {
options.numericModifier = Number(rollData.numericModifier) || 0
options.skillModifier = Number(rollData.skillModifier) || 0
options.rangeModifier = Number(rollData.rangeModifier) || 0
options.finalModifier = options.numericModifier + options.skillModifier + options.rangeModifier
let mod = options.rollItem?.value || 0
// Build the dice formula
let diceFormula = `${2 + Math.abs(options.skillModifier)}D6`
if (options.skillModifier > 0) {
let diceFormula = "2d6"
if (options.rollType === "damage") {
let damageFormula = options.weapon.system.damage.toUpperCase().replace(/D/g, "d")
// Extract the mod (if present), like in 3d6+1
let match = damageFormula.match(/([+-]\d+)$/)
if (match) {
mod += Number(match[1])
damageFormula = damageFormula.replace(match[1], "")
}
// Replace the D6 by the correct number of D6
damageFormula = damageFormula.replace(/(\d*)d6/gi, (match, p1) => {
let numDice = Number(p1) || 1
numDice += Math.abs(options.skillModifier)
return `${numDice}d6`
})
diceFormula = damageFormula
} else {
diceFormula = `${2 + Math.abs(options.finalModifier)}D6`
}
if (options.finalModifier > 0) {
diceFormula += `kh2 + ${mod}`
} else {
diceFormula += `kl2 + ${mod}`