Initial system import
This commit is contained in:
53
module/documents/actor.mjs
Normal file
53
module/documents/actor.mjs
Normal file
@@ -0,0 +1,53 @@
|
||||
import HellbornUtils from "../utils.mjs"
|
||||
|
||||
export default class HellbornActor extends Actor {
|
||||
|
||||
static async create(data, options) {
|
||||
|
||||
// Case of compendium global import
|
||||
if (data instanceof Array) {
|
||||
return super.create(data, options);
|
||||
}
|
||||
// If the created actor has items (only applicable to duplicated actors) bypass the new actor creation logic
|
||||
if (data.items) {
|
||||
let actor = super.create(data, options);
|
||||
return actor;
|
||||
}
|
||||
|
||||
if (data.type === 'character') {
|
||||
}
|
||||
|
||||
return super.create(data, options);
|
||||
}
|
||||
|
||||
_onUpdate(changed, options, userId) {
|
||||
// DEBUG : console.log("CthulhuEternalActor.update", changed, options, userId)
|
||||
if (changed?.system?.wp?.exhausted) {
|
||||
ChatMessage.create({
|
||||
user: userId,
|
||||
speaker: { alias: this.name },
|
||||
rollMode: "selfroll",
|
||||
content: game.i18n.localize("HELLBORN.ChatMessage.exhausted"),
|
||||
type: CONST.CHAT_MESSAGE_STYLES.OTHER
|
||||
})
|
||||
}
|
||||
return super._onUpdate(changed, options, userId)
|
||||
}
|
||||
|
||||
|
||||
async _preCreate(data, options, user) {
|
||||
await super._preCreate(data, options, user)
|
||||
|
||||
// Configure prototype token settings
|
||||
const prototypeToken = {}
|
||||
if (this.type === "character") {
|
||||
Object.assign(prototypeToken, {
|
||||
sight: { enabled: true },
|
||||
actorLink: true,
|
||||
disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY,
|
||||
})
|
||||
this.updateSource({ prototypeToken })
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user