Files
fvtt-oath-hammer/module/documents/actor.mjs
2026-03-07 17:19:40 +01:00

36 lines
1023 B
JavaScript

export default class OathHammerActor extends Actor {
async _preCreate(data, options, user) {
await super._preCreate(data, options, user)
const prototypeToken = {}
if (this.type === "character") {
Object.assign(prototypeToken, {
sight: { enabled: true },
actorLink: true,
disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY,
})
this.updateSource({ prototypeToken })
}
if (this.type === "npc") {
Object.assign(prototypeToken, {
sight: { enabled: false },
actorLink: false,
disposition: CONST.TOKEN_DISPOSITIONS.HOSTILE,
})
this.updateSource({ prototypeToken })
}
}
getArmorRating() {
let rating = 0
for (const item of this.items) {
if (item.type === "armor" && item.system.equipped) {
rating += Number(item.system.armorRating) || 0
}
if (item.type === "shield" && item.system.equipped) {
rating += Number(item.system.shieldBonus) || 0
}
}
return rating
}
}