Add optionnal modifier

This commit is contained in:
2025-10-27 20:06:24 +00:00
parent 8a5d1cc1d8
commit ace607d05c
14 changed files with 62 additions and 31 deletions

View File

@@ -144,6 +144,20 @@ export const MODIFIER_CHOICES = {
"impossible6": { id: "impossible6", label: "FTLNOMAD.Label.Impossible6", value: "-6" }
}
export const NUMERIC_MODIFIER_CHOICES = {
"-5": { label: "-5", value: -5 },
"-4": { label: "-4", value: -4 },
"-3": { label: "-3", value: -3 },
"-2": { label: "-2", value: -2 },
"-1": { label: "-1", value: -1 },
"0": { label: "0", value: 0 },
"+1": { label: "+1", value: 1 },
"+2": { label: "+2", value: 2 },
"+3": { label: "+3", value: 3 },
"+4": { label: "+4", value: 4 },
"+5": { label: "+5", value: 5 }
}
export const STARSHIP_HULL = {
"pod": { id: "pod", label: "FTLNOMAD.Starship.Hull.Pod" },
"micro": { id: "micro", label: "FTLNOMAD.Starship.Hull.Micro" },
@@ -163,6 +177,7 @@ export const STARSHIP_HULL = {
export const SYSTEM = {
id: SYSTEM_ID,
MODIFIER_CHOICES,
NUMERIC_MODIFIER_CHOICES,
ATTACK_MODIFIERS,
TECH_AGES,
WEAPON_TYPES,

View File

@@ -66,7 +66,7 @@ export default class FTLNomadRoll extends Roll {
fullFormula = `${options.formula} + ${options.damageModifier}D6 `
} else {
let mod = options.rollItem?.value || 0
fullFormula = `${options.formula} + ${options.skillModifier}D + ${mod} + ${options.rangeModifier}D + ${options.numericModifier}D`
fullFormula = `${options.formula} + ${options.skillModifier}D + ${mod} + ${options.rangeModifier}D + ${options.numericModifier}D + ${options.numericModifierSelect}`
}
// Replace all the "+ -" with "-"
fullFormula = fullFormula.replace(/\+\s*\-/g, "- ")
@@ -116,6 +116,7 @@ export default class FTLNomadRoll extends Roll {
})
const choiceModifier = SYSTEM.MODIFIER_CHOICES
const choiceNumericModifier = SYSTEM.NUMERIC_MODIFIER_CHOICES
let choiceRangeModifier = {}
let rangeModifier = 0
if (options.weapon) {
@@ -129,8 +130,10 @@ export default class FTLNomadRoll extends Roll {
let damageModifier = "0"
let modifier = "0"
let numericModifierSelect = 0
options.skillModifier = 0
options.numericModifier = 0
options.numericModifierSelect = 0
options.rangeModifier = rangeModifier
options.damageModifier = damageModifier
let fullFormula = `${formula} + ${options.rollItem.value}`
@@ -152,6 +155,7 @@ export default class FTLNomadRoll extends Roll {
rollModes,
fieldRollMode,
choiceModifier,
choiceNumericModifier,
choiceRangeModifier,
choiceDamageModifier,
rangeModifier,
@@ -159,6 +163,7 @@ export default class FTLNomadRoll extends Roll {
formula,
hasTarget: options.hasTarget,
modifier,
numericModifierSelect,
}
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-ftl-nomad/templates/roll-dialog.hbs", dialogContext)
@@ -189,6 +194,10 @@ export default class FTLNomadRoll extends Roll {
options.skillModifier = Number(event.target.value)
FTLNomadRoll.updateFullFormula(options)
})
$(".roll-numeric-modifier").change(event => {
options.numericModifierSelect = Number(event.target.value)
FTLNomadRoll.updateFullFormula(options)
})
$(".roll-damage-modifier").change(event => {
options.damageModifier = Number(event.target.value)
FTLNomadRoll.updateFullFormula(options)
@@ -223,8 +232,10 @@ 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.numericModifierSelect = Number(rollData.numericModifierSelect) || 0
options.finalModifier = options.numericModifier + options.skillModifier + options.rangeModifier
let mod = options.rollItem?.value || 0
mod += options.numericModifierSelect
// Build the dice formula
let diceFormula = "2d6"