Nouvelles corrections sur la fiche
This commit is contained in:
@@ -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
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user