Initial import
This commit is contained in:
2
module/documents/_module.mjs
Normal file
2
module/documents/_module.mjs
Normal file
@@ -0,0 +1,2 @@
|
||||
export { default as OathHammerActor } from "./actor.mjs"
|
||||
export { default as OathHammerItem } from "./item.mjs"
|
||||
35
module/documents/actor.mjs
Normal file
35
module/documents/actor.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
22
module/documents/item.mjs
Normal file
22
module/documents/item.mjs
Normal file
@@ -0,0 +1,22 @@
|
||||
const defaultItemImg = {
|
||||
weapon: "systems/fvtt-oath-hammer/assets/icons/icon_weapon.webp",
|
||||
armor: "systems/fvtt-oath-hammer/assets/icons/icon_armor.webp",
|
||||
shield: "systems/fvtt-oath-hammer/assets/icons/icon_shield.webp",
|
||||
ammunition: "systems/fvtt-oath-hammer/assets/icons/icon_ammunition.webp",
|
||||
equipment: "systems/fvtt-oath-hammer/assets/icons/icon_equipment.webp",
|
||||
spell: "systems/fvtt-oath-hammer/assets/icons/icon_spell.webp",
|
||||
miracle: "systems/fvtt-oath-hammer/assets/icons/icon_miracle.webp",
|
||||
"magic-item": "systems/fvtt-oath-hammer/assets/icons/icon_magic_item.webp",
|
||||
ability: "systems/fvtt-oath-hammer/assets/icons/icon_ability.webp",
|
||||
oath: "systems/fvtt-oath-hammer/assets/icons/icon_oath.webp",
|
||||
condition: "systems/fvtt-oath-hammer/assets/icons/icon_condition.webp"
|
||||
}
|
||||
|
||||
export default class OathHammerItem extends Item {
|
||||
constructor(data, context) {
|
||||
if (!data.img && defaultItemImg[data.type]) {
|
||||
data.img = defaultItemImg[data.type]
|
||||
}
|
||||
super(data, context)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user