diff --git a/module/actor.js b/module/actor.js index 14e5c427..0d0b4a6c 100644 --- a/module/actor.js +++ b/module/actor.js @@ -175,12 +175,24 @@ export class RdDActor extends Actor { isCreature() { return this.data.type == 'creature' || this.data.type == 'entite'; } - /* -------------------------------------------- */ isPersonnage() { return this.data.type == 'personnage'; } - + /* -------------------------------------------- */ + getFatigueActuelle() { + if (!this.isPersonnage()) { + return 0; + } + return Misc.toInt(this.data.data.sante.fatigue?.value); + } + /* -------------------------------------------- */ + getFatigueMax() { + if (!this.isPersonnage()) { + return 1; + } + return Misc.toInt(this.data.data.sante.fatigue?.max); + } /* -------------------------------------------- */ getReveActuel() { return Misc.toInt(this.data.data.reve?.reve?.value ?? this.data.data.carac.reve.value); @@ -1295,14 +1307,17 @@ export class RdDActor extends Actor { if (sante.fatigue && fatigue > 0) { sante.fatigue.value = Math.max(sante.fatigue.value + fatigue, this._computeFatigueMin()); } - if (!this.isEntiteCauchemar() && sante.vie.value<-this.getSConst()) { + await this.update({ "data.sante": sante }); + if (this.isDead()) { await this.addStatusEffectById('dead'); } - - await this.update({ "data.sante": sante }); return result; } + isDead() { + return !this.isEntiteCauchemar() && this.data.data.sante.vie.value<-this.getSConst() + } + /* -------------------------------------------- */ _computeFatigueMin() { return this.data.data.sante.endurance.max - this.data.data.sante.endurance.value;