Fix spell rolls again
Release Creation / build (release) Successful in 47s

This commit is contained in:
2026-05-25 20:41:00 +02:00
parent e45edd60c4
commit f6fb0b68b8
4 changed files with 335 additions and 258 deletions
+8 -3
View File
@@ -25,7 +25,8 @@ export default class D30Roll {
RANGED_DEFENSE: "ranged_defense",
ARCANE_SPELL_ATTACK: "arcane_spell_attack",
ARCANE_SPELL_DEFENSE: "arcane_spell_defense",
SKILL_ROLLS: "skill_rolls"
SKILL_ROLLS: "skill_rolls",
SAVING_THROWS: "saving_throws"
}
/**
@@ -137,11 +138,15 @@ export default class D30Roll {
}
// Skill types
if (externalType === "skill" || externalType === "monster-skill" ||
externalType === "save" || externalType === "challenge") {
if (externalType === "skill" || externalType === "monster-skill" || externalType === "challenge") {
return this.ROLL_TYPES.SKILL_ROLLS
}
// Saving throw types
if (externalType === "save") {
return options.isSpellSave ? this.ROLL_TYPES.ARCANE_SPELL_DEFENSE : this.ROLL_TYPES.SAVING_THROWS
}
// If no match, return null
console.warn(`D30Roll | Unknown external roll type: ${externalType}`)
return null
+14 -4
View File
@@ -609,7 +609,7 @@ export default class LethalFantasyRoll extends Roll {
rollD30.total,
options.rollType,
options.rollTarget?.weapon,
{ isRanged: isRangedForD30 }
{ isRanged: isRangedForD30, isSpellSave: saveSpell }
)
options.D30message = d30Message
}
@@ -787,9 +787,18 @@ export default class LethalFantasyRoll extends Roll {
let buttons = []
if (currentAction) {
if (currentAction.type === "weapon") {
let weaponLabel = "Roll progression dice"
if (currentAction.rangedMode) {
// Compute loading count from the speed formula (e.g. "3+1d6" → load=3)
const speedStr = currentAction.system?.speed?.[currentAction.rangedMode] ?? ""
const rangedLoad = currentAction.rangedLoad ?? (Number(speedStr.split("+")[0]) || 0)
if (rangedLoad > 0 && !currentAction.weaponLoaded) {
weaponLabel = "Load weapon"
}
}
buttons.push({
action: "roll",
label: "Roll progression dice",
label: weaponLabel,
callback: (event, button) => {
let pos = $('#combat-action-dialog').position()
game.user.setFlag(SYSTEM.id, "combat-action-dialog-pos", pos)
@@ -908,14 +917,15 @@ export default class LethalFantasyRoll extends Roll {
if (rollContext === "rollLethargyDice") {
if (currentAction.spellStatus === "castingTime") {
let time = currentAction.type === "spell" ? currentAction.system.castingTime : currentAction.system.prayerTime
if (currentAction.castingTime <= time) {
if (currentAction.castingTime < time) {
let message = `Casting time : ${currentAction.name}, count : ${currentAction.castingTime}/${time}`
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
currentAction.castingTime += 1
await combatant.setFlag(SYSTEM.id, "currentAction", foundry.utils.duplicate(currentAction))
return
} else {
let message = `Spell/Miracle ${currentAction.name} ready to be cast on next second !`
// Last counting second — announce ready and transition immediately (no extra second consumed)
let message = `Casting time : ${currentAction.name}, count : ${time}/${time} — ready to cast next second !`
ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) })
currentAction.castingTime = 1
currentAction.spellStatus = "toBeCasted"