FIx spell order and dual rollll for spell damages
Release Creation / build (release) Successful in 1m6s
Release Creation / build (release) Successful in 1m6s
This commit is contained in:
@@ -268,12 +268,12 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
{
|
||||
action: "cancel",
|
||||
label: game.i18n.localize("LETHALFANTASY.Combat.proceedNo"),
|
||||
callback: () => null
|
||||
callback: () => "cancel"
|
||||
}
|
||||
],
|
||||
rejectClose: false
|
||||
})
|
||||
if (manualDR === null) return
|
||||
if (manualDR === null || manualDR === "cancel") return
|
||||
|
||||
const rollOpts = {
|
||||
type: "spell-damage",
|
||||
@@ -286,18 +286,7 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
actorName: this.actor.name,
|
||||
actorImage: this.actor.img
|
||||
}
|
||||
const roll = new LethalFantasyRoll(formula, {}, rollOpts)
|
||||
await roll.evaluate()
|
||||
const diceResults = []
|
||||
for (const term of roll.dice) {
|
||||
for (const r of term.results) {
|
||||
diceResults.push({ dice: `1D${term.faces}`, value: r.result })
|
||||
}
|
||||
}
|
||||
roll.options.diceResults = diceResults
|
||||
roll.options.rollTotal = roll.total
|
||||
if (game?.dice3d) await game.dice3d.showForRoll(roll, game.user, true)
|
||||
await roll.toMessage()
|
||||
await LethalFantasyRoll.rollSpellDamageToMessage(formula, rollOpts)
|
||||
}
|
||||
|
||||
static #onCreateEquipment(event, target) {
|
||||
|
||||
@@ -908,7 +908,7 @@ 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
|
||||
@@ -1529,4 +1529,43 @@ export default class LethalFantasyRoll extends Roll {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate a spell/miracle damage formula with per-die explosion, then post to chat.
|
||||
* Explosion dice are shown manually via showForRoll; the main roll is shown automatically
|
||||
* by toMessage() (which triggers Dice So Nice via its createChatMessage hook).
|
||||
* Append "NE" to the formula to disable explosion.
|
||||
*
|
||||
* @param {string} formula Dice formula, e.g. "1d8", "2d6", "1d8NE"
|
||||
* @param {Object} rollOpts Options for LethalFantasyRoll (rollType, actorId, defenderId, etc.)
|
||||
* @returns {Promise<ChatMessage>}
|
||||
*/
|
||||
static async rollSpellDamageToMessage(formula, rollOpts) {
|
||||
const roll = new LethalFantasyRoll(formula, {}, rollOpts)
|
||||
await roll.evaluate()
|
||||
const shouldExplode = !/NE$/i.test(formula)
|
||||
const diceResults = []
|
||||
let diceSum = 0
|
||||
for (const term of roll.dice) {
|
||||
const singleDice = `1D${term.faces}`
|
||||
for (const r of term.results) {
|
||||
let diceResult = r.result
|
||||
diceResults.push({ dice: singleDice.toUpperCase(), value: diceResult })
|
||||
diceSum += diceResult
|
||||
if (shouldExplode && term.faces > 0) {
|
||||
while (diceResult === term.faces) {
|
||||
const xr = await new Roll(singleDice).evaluate()
|
||||
if (game?.dice3d) await game.dice3d.showForRoll(xr, game.user, true)
|
||||
// Optional chaining guards against unexpected roll structure
|
||||
diceResult = xr.dice?.[0]?.results?.[0]?.result ?? (term.faces - 1)
|
||||
diceResults.push({ dice: `${singleDice.toUpperCase()}-1`, value: diceResult - 1 })
|
||||
diceSum += (diceResult - 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
roll.options.diceResults = diceResults
|
||||
roll.options.rollTotal = diceSum
|
||||
return roll.toMessage()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user