Gestion des predilections et rework dons

This commit is contained in:
2022-06-05 23:27:38 +02:00
parent cd1ecf1d96
commit 665feac605
11 changed files with 158 additions and 74 deletions

View File

@ -36,7 +36,7 @@ export class MournbladeActor extends Actor {
if (data.type == 'personnage') {
const skills = await MournbladeUtility.loadCompendium("fvtt-mournblade.skills")
data.items = skills.map(i => i.toObject());
data.items = skills.map(i => i.toObject())
}
if (data.type == 'pnj') {
}
@ -92,10 +92,18 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
prepareDerivedData() {
if (this.type == 'character') {
if (this.type == 'personnage') {
let newSante = (this.data.data.attributs.pui.value + this.data.data.attributs.tre.value)*2 + 5
if (this.data.data.sante.base!=newSante ) {
this.update( {'data.sante.base': newSante} )
}
let newAme = (this.data.data.attributs.cla.value + this.data.data.attributs.tre.value)*2 + 5
if (this.data.data.ame.base!=newAme ) {
this.update( {'data.ame.base': newAme} )
}
}
super.prepareDerivedData();
super.prepareDerivedData()
}
/* -------------------------------------------- */
@ -225,6 +233,19 @@ export class MournbladeActor extends Actor {
}
}
/* -------------------------------------------- */
getCompetence( compId ) {
return this.data.items.get(compId)
}
/* -------------------------------------------- */
async setPredilectionUsed( compId, predIdx) {
let comp = this.data.items.get(compId)
let pred = duplicate(comp.data.data.predilections)
pred[predIdx].used = true
await this.updateEmbeddedDocuments('Item', [ {_id: compId, 'data.predilections': pred}])
}
/* -------------------------------------------- */
getCommonRollData(attrKey = undefined, compId = undefined) {
let rollData = MournbladeUtility.getBasicRollData()