Fix various issues with rolls and compendiums
All checks were successful
Release Creation / build (release) Successful in 57s

This commit is contained in:
2025-08-24 16:19:35 +02:00
parent 8a5b402388
commit 668da28d2c
21 changed files with 392 additions and 101 deletions

View File

@@ -62,7 +62,8 @@ export default class FTLNomadRoll extends Roll {
static updateFullFormula(options) {
let fullFormula
fullFormula = `${options.formula} + ${options.rollItem.value} + ${options.skillModifier}D + ${options.rangeModifier}D + ${options.numericModifier}D`
let mod = options.rollItem?.value || 0
fullFormula = `${options.formula} + ${options.skillModifier}D + ${mod} + ${options.rangeModifier}D + ${options.numericModifier}D`
// Replace all the "+ -" with "-"
fullFormula = fullFormula.replace(/\+\s*-/g, "- ")
$('#roll-dialog-full-formula').text(fullFormula)
@@ -85,20 +86,15 @@ export default class FTLNomadRoll extends Roll {
*/
static async prompt(options = {}) {
let formula = "2d6"
let actor = game.actors.get(options.actorId)
switch (options.rollType) {
case "skill":
break
case "damage":
let formula = options.rollItem.system.damage
let damageRoll = new Roll(formula)
await damageRoll.evaluate()
await damageRoll.toMessage({
flavor: `${options.rollItem.name} - Damage Roll`
});
return
options.weapon = foundry.utils.duplicate(options.rollItem)
break
case "weapon":
let actor = game.actors.get(options.actorId)
options.weapon = foundry.utils.duplicate(options.rollItem)
options.rollItem = actor.system.skills.combat
break
@@ -106,6 +102,7 @@ export default class FTLNomadRoll extends Roll {
break
}
options.actor = actor
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes)
const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes,
@@ -116,7 +113,7 @@ export default class FTLNomadRoll extends Roll {
const choiceModifier = SYSTEM.MODIFIER_CHOICES
let choiceRangeModifier = {}
let rangeModifier = 0
if ( options.weapon) {
if (options.weapon) {
// Build the range modifiers
let range = SYSTEM.WEAPON_RANGE[options.weapon.system.rangeType]
for (let [key, value] of Object.entries(range.range)) {
@@ -192,7 +189,7 @@ export default class FTLNomadRoll extends Roll {
$(".select-combat-option").change(event => {
let field = $(event.target).data("field")
let modifier = SYSTEM.ATTACK_MODIFIERS[field]
if ( event.target.checked) {
if (event.target.checked) {
options.numericModifier += modifier
} else {
options.numericModifier -= modifier
@@ -212,13 +209,20 @@ export default class FTLNomadRoll extends Roll {
if (Hooks.call("fvtt-ftl-nomad.preRoll", options, rollData) === false) return
let diceFormula = `${2+Math.abs(options.numericModifier)}D6`
if ( options.numericModifier > 0 ) {
diceFormula += `kh2 + ${options.rollItem.value}`
options.numericModifier = Number(rollData.numericModifier) || 0
options.skillModifier = Number(rollData.skillModifier) || 0
options.rangeModifier = Number(rollData.rangeModifier) || 0
let mod = options.rollItem?.value || 0
// Build the dice formula
let diceFormula = `${2 + Math.abs(options.skillModifier)}D6`
if (options.skillModifier > 0) {
diceFormula += `kh2 + ${mod}`
} else {
diceFormula += `kl2 + ${options.rollItem.value}`
diceFormula += `kl2 + ${mod}`
}
console.log("FTLNomadRoll | Rolling ", diceFormula, options, rollData)
const roll = new this(diceFormula, options.data, rollData)
await roll.evaluate()
@@ -254,6 +258,8 @@ export default class FTLNomadRoll extends Roll {
*/
static createTitle(type, target) {
switch (type) {
case "damage":
return `${game.i18n.localize("FTLNOMAD.Label.titleDamage")}`
case "skill":
return `${game.i18n.localize("FTLNOMAD.Label.titleSkill")}`
case "weapon":