Add initiative rolls
This commit is contained in:
@@ -2,3 +2,4 @@ export { default as AwEActor } from "./actor.mjs"
|
||||
export { default as AwEItem } from "./item.mjs"
|
||||
export { default as AwERoll } from "./roll.mjs"
|
||||
export { default as AwEChatMessage } from "./chat-message.mjs"
|
||||
export { default as AwECombatant } from "./combatant.mjs"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
export default class AwECombatant extends Combatant {
|
||||
/**
|
||||
* Initiative = 1d20 + highest attribute modifier.
|
||||
* @override
|
||||
*/
|
||||
getInitiativeRoll(formula) {
|
||||
const actor = this.actor
|
||||
if (!actor) return super.getInitiativeRoll(formula)
|
||||
|
||||
const attrs = actor.system?.attributes ?? {}
|
||||
const mods = ["agility", "awareness", "fitness", "influence"]
|
||||
.map(k => attrs[k]?.mod ?? 0)
|
||||
const highest = Math.max(...mods)
|
||||
|
||||
const rollFormula = highest >= 0 ? `1d20 + ${highest}` : `1d20 - ${Math.abs(highest)}`
|
||||
return Roll.create(rollFormula)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user