Ajout du xplog
This commit is contained in:
@ -204,6 +204,24 @@ export class BoLActor extends Actor {
|
||||
return undefined
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
addXPLog(type, name, cost, value) {
|
||||
let xplog = {
|
||||
name: "XP : "+game.i18n.localize(type), type: "feature",
|
||||
img: "icons/magic/symbols/chevron-elipse-circle-blue.webp",
|
||||
system: {
|
||||
subtype: "xplog", properties: {
|
||||
xptype: type,
|
||||
xpdate: new Date().toLocaleDateString(),
|
||||
xpname: name,
|
||||
xpcost: cost,
|
||||
xpvalue: value
|
||||
}
|
||||
}
|
||||
}
|
||||
this.createEmbeddedDocuments('Item', [xplog])
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
incAttributeXP(key) {
|
||||
let attr = duplicate(this.system.attributes[key])
|
||||
@ -214,6 +232,7 @@ export class BoLActor extends Actor {
|
||||
attr.value += 1
|
||||
xp.spent += nextXP
|
||||
this.update({ [`system.attributes.${key}`]: attr, [`system.xp`]: xp })
|
||||
this.addXPLog("attribute", key, nextXP, attr.value)
|
||||
} else {
|
||||
ui.notifications.warn("Pas assez de points d'expérience !")
|
||||
}
|
||||
@ -230,6 +249,7 @@ export class BoLActor extends Actor {
|
||||
apt.value += 1
|
||||
xp.spent += nextXP
|
||||
this.update({ [`system.aptitudes.${key}`]: apt, [`system.xp`]: xp })
|
||||
this.addXPLog("aptitude", key, nextXP, apt.value)
|
||||
} else {
|
||||
ui.notifications.warn("Pas assez de points d'expérience !")
|
||||
}
|
||||
@ -246,6 +266,7 @@ export class BoLActor extends Actor {
|
||||
xp.spent += nextXP
|
||||
this.update({ [`system.xp`]: xp })
|
||||
this.updateEmbeddedDocuments('Item', [{ _id: career._id, 'system.rank': career.system.rank + 1 }])
|
||||
this.addXPLog("career", career.name, nextXP, career.system.rank+1)
|
||||
} else {
|
||||
ui.notifications.warn("Pas assez de points d'expérience !")
|
||||
}
|
||||
@ -298,6 +319,9 @@ export class BoLActor extends Actor {
|
||||
get boleffects() {
|
||||
return this.items.filter(i => i.type === "feature" && i.system.subtype === "boleffect")
|
||||
}
|
||||
get xplog() {
|
||||
return this.items.filter(i => i.type === "feature" && i.system.subtype === "xplog")
|
||||
}
|
||||
get horoscopes() {
|
||||
return this.items.filter(i => i.type === "feature" && i.system.subtype === "horoscope")
|
||||
}
|
||||
|
Reference in New Issue
Block a user