forked from public/foundryvtt-reve-de-dragon
		
	une critique fait perdre 4 points de vie
Pas 5 à cause de l'endurance qui passe à zéro (on est gentils avec les personnages)
This commit is contained in:
		| @@ -890,12 +890,15 @@ export class RdDActor extends Actor { | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */   | ||||
|   async santeIncDec(name, inc ) { | ||||
|   async santeIncDec(name, inc, isCritique = false) { | ||||
|     const sante = duplicate(this.data.data.sante); | ||||
|     let data = sante[name]; | ||||
|     let minValue = 0; | ||||
|     if (this.type == 'personnage') | ||||
|       minValue = name == "vie" ? Number(-this.data.data.attributs.sconst.value) : 0; | ||||
|     if (this.type == 'personnage') { | ||||
|       // TODO: les animaux/humanoïdes on théoriquement aussi un sconst, mais la SPA n'est pas passé par là | ||||
|       minValue = name == "vie" ? -Number(this.data.data.attributs.sconst.value) : 0; | ||||
|     } | ||||
|  | ||||
|     let newValue = Math.max(minValue, Math.min(data.value + inc, data.max)); | ||||
|     //console.log("New value ", inc, minValue, newValue); | ||||
|  | ||||
| @@ -903,7 +906,7 @@ export class RdDActor extends Actor { | ||||
|       if ( sante.fatigue && inc < 0 ) { // Each endurance lost -> fatigue lost | ||||
|         sante.fatigue.value = sante.fatigue.value - inc | ||||
|       } | ||||
|       if ( newValue == 0 && inc < 0) { // perte endurance et endurance devient 0 -> -1 vie | ||||
|       if ( newValue == 0 && inc < 0 && !isCritique) { // perte endurance et endurance devient 0 -> -1 vie (sauf critique) | ||||
|         sante.vie.value = sante.vie.value - 1; | ||||
|       } | ||||
|       newValue = Math.max(0, newValue); | ||||
| @@ -1298,9 +1301,8 @@ export class RdDActor extends Actor { | ||||
|     let degatsReel = attackerRoll.degats - armure; | ||||
|  | ||||
|     let result = RdDUtility.computeBlessuresSante(degatsReel, attackerRoll.mortalite); | ||||
|     if ( this.data.type != 'entite') // Pas de PV chez les entités | ||||
|     await this.santeIncDec("vie", result.vie); | ||||
|     await this.santeIncDec("endurance", result.endurance); | ||||
|     await this.santeIncDec("endurance", result.endurance, (result.critiques > 0)); | ||||
|     result.locName = (attackerRoll.loc) ?  attackerRoll.loc.label : "Corps"; | ||||
|  | ||||
|     this.manageBlessures(result); // Will upate the result table | ||||
|   | ||||
		Reference in New Issue
	
	Block a user