Fix #30 - Disable dual skills dop
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import CthulhuEternalUtils from "../utils.mjs"
|
||||
|
||||
export default class CthulhuEternalActor extends Actor {
|
||||
|
||||
|
||||
static async create(data, options) {
|
||||
|
||||
// Case of compendium global import
|
||||
@ -19,7 +19,7 @@ export default class CthulhuEternalActor extends Actor {
|
||||
const skills = await CthulhuEternalUtils.loadCompendium("fvtt-cthulhu-eternal.skills")
|
||||
data.items = data.items || []
|
||||
for (let skill of skills) {
|
||||
if (skill.system.settings === era ) {
|
||||
if (skill.system.settings === era) {
|
||||
data.items.push(skill.toObject())
|
||||
}
|
||||
}
|
||||
@ -30,7 +30,7 @@ export default class CthulhuEternalActor extends Actor {
|
||||
|
||||
_onUpdate(changed, options, userId) {
|
||||
// DEBUG : console.log("CthulhuEternalActor.update", changed, options, userId)
|
||||
if ( changed?.system?.wp?.exhausted) {
|
||||
if (changed?.system?.wp?.exhausted) {
|
||||
ChatMessage.create({
|
||||
user: userId,
|
||||
speaker: { alias: this.name },
|
||||
@ -42,19 +42,36 @@ export default class CthulhuEternalActor extends Actor {
|
||||
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 === "protagonist") {
|
||||
Object.assign(prototypeToken, {
|
||||
sight: { enabled: true },
|
||||
actorLink: true,
|
||||
disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY,
|
||||
})
|
||||
this.updateSource({ prototypeToken })
|
||||
async createEmbeddedDocuments(embeddedName, data, operation) {
|
||||
let newData = []
|
||||
if (embeddedName === "Item") {
|
||||
for (let i of data) {
|
||||
if (i.type === "skill") {
|
||||
if (this.items.find(item => item.name.toLowerCase() === i.name.toLowerCase())) {
|
||||
ui.notifications.warn(game.i18n.localize("CTHULHUETERNAL.Notifications.skillAlreadyExists"))
|
||||
continue
|
||||
}
|
||||
}
|
||||
newData.push(i)
|
||||
}
|
||||
return super.createEmbeddedDocuments(embeddedName, newData, operation)
|
||||
}
|
||||
return super.createEmbeddedDocuments(embeddedName, data, operation)
|
||||
}
|
||||
|
||||
async _preCreate(data, options, user) {
|
||||
await super._preCreate(data, options, user)
|
||||
|
||||
// Configure prototype token settings
|
||||
const prototypeToken = {}
|
||||
if (this.type === "protagonist") {
|
||||
Object.assign(prototypeToken, {
|
||||
sight: { enabled: true },
|
||||
actorLink: true,
|
||||
disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY,
|
||||
})
|
||||
this.updateSource({ prototypeToken })
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user