From d612b7467580e59ce72ea7aeec5d2706b743d450 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 2 Feb 2021 19:17:59 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20fatigue/mort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit méthodes plus facile pour utilisation hors de l'actor --- module/actor.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) 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;