Nouvelles corrections sur la fiche

This commit is contained in:
2026-03-06 14:49:32 +01:00
parent a527bd494f
commit 97e97273da
6 changed files with 84 additions and 1 deletions
+24
View File
@@ -19,6 +19,10 @@ export default class AwERoll extends Roll {
get actorImage() { return this.options.actorImage }
get sourceItemName() { return this.options.sourceItemName }
get sourceItemImg() { return this.options.sourceItemImg }
get damageFormula() { return this.options.damageFormula }
get damageType() { return this.options.damageType }
get damageResult() { return this.options.damageResult }
get damageCritical() { return this.options.damageCritical ?? false }
// --- Outcome calculation ---
@@ -170,6 +174,23 @@ export default class AwERoll extends Roll {
roll.options.outcome = AwERoll.computeOutcome(roll.total, dc, d20Value)
}
// If this is a weapon attack and it hit, roll damage
if (options.damageFormula && roll.options.outcome) {
const isHit = roll.options.outcome === "success" || roll.options.outcome === "criticalSuccess"
const isCrit = roll.options.outcome === "criticalSuccess"
if (isHit) {
// Double the dice count on critical success
const formula = isCrit
? options.damageFormula.replace(/(\d+)d(\d+)/gi, (_, n, d) => `${Number(n) * 2}d${d}`)
: options.damageFormula
const dmgRoll = new Roll(formula)
await dmgRoll.evaluate()
roll.options.damageResult = dmgRoll.total
roll.options.damageCritical = isCrit
roll.options.damageType = options.damageType
}
}
await roll.toMessage({
speaker: ChatMessage.getSpeaker({ actor: game.actors.get(options.actorId) }),
flavor: attrLabel,
@@ -197,6 +218,9 @@ export default class AwERoll extends Roll {
actorImage: this.actorImage,
sourceItemName: this.sourceItemName,
sourceItemImg: this.sourceItemImg,
damageResult: isPrivate ? null : this.damageResult,
damageCritical: this.damageCritical,
damageType: this.damageType,
isPrivate
}
)