forked from public/foundryvtt-reve-de-dragon
		
	Amélioration fatigue/mort
méthodes plus facile pour utilisation hors de l'actor
This commit is contained in:
		| @@ -175,12 +175,24 @@ export class RdDActor extends Actor { | |||||||
|   isCreature() { |   isCreature() { | ||||||
|     return this.data.type == 'creature' || this.data.type == 'entite'; |     return this.data.type == 'creature' || this.data.type == 'entite'; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   isPersonnage() { |   isPersonnage() { | ||||||
|     return this.data.type == 'personnage'; |     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() { |   getReveActuel() { | ||||||
|     return Misc.toInt(this.data.data.reve?.reve?.value ?? this.data.data.carac.reve.value); |     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) { |     if (sante.fatigue && fatigue > 0) { | ||||||
|       sante.fatigue.value = Math.max(sante.fatigue.value + fatigue, this._computeFatigueMin()); |       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.addStatusEffectById('dead'); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     await this.update({ "data.sante": sante }); |  | ||||||
|     return result; |     return result; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   isDead() { | ||||||
|  |     return !this.isEntiteCauchemar() && this.data.data.sante.vie.value<-this.getSConst() | ||||||
|  |   } | ||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   _computeFatigueMin() { |   _computeFatigueMin() { | ||||||
|     return this.data.data.sante.endurance.max - this.data.data.sante.endurance.value; |     return this.data.data.sante.endurance.max - this.data.data.sante.endurance.value; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user