Fix perte fatigue sur critique
prendre la perte d'endurance comme incrément de fatigue
This commit is contained in:
		| @@ -832,7 +832,6 @@ export class RdDActor extends Actor { | ||||
|     } | ||||
|     // Mise à jour valeur totale et états | ||||
|     this.encTotal = encTotal; | ||||
|     console.log("Enco total : ", this.encTotal); | ||||
|     this.detectSurEncombrement(); | ||||
|     // Mise à jour éventuelle du malus armure | ||||
|     if (this.data.data.attributs && this.data.data.attributs.malusarmure && newMalusArmure != malusArmureData.value) { | ||||
| @@ -1129,8 +1128,8 @@ export class RdDActor extends Actor { | ||||
|   async santeIncDec(name, inc, isCritique = false) { | ||||
|  | ||||
|     const sante = duplicate(this.data.data.sante); | ||||
|     let data = sante[name]; | ||||
|     if (!data) { | ||||
|     let compteur = sante[name]; | ||||
|     if (!compteur) { | ||||
|       return; | ||||
|     } | ||||
|     let result = { | ||||
| @@ -1143,13 +1142,10 @@ export class RdDActor extends Actor { | ||||
|       minValue = name == "vie" ? -Number(this.data.data.attributs.sconst.value) : 0; | ||||
|     } | ||||
|  | ||||
|     result.newValue = Math.max(minValue, Math.min(data.value + inc, data.max)); | ||||
|     result.newValue = Math.max(minValue, Math.min(compteur.value + inc, compteur.max)); | ||||
|     //console.log("New value ", inc, minValue, result.newValue); | ||||
|  | ||||
|     let fatigue = 0; | ||||
|     if (name == "endurance" && this.data.type != 'entite') { | ||||
|       if (sante.fatigue && inc < 0) { // Each endurance lost -> fatigue lost | ||||
|         sante.fatigue.value = sante.fatigue.value - inc | ||||
|       } | ||||
|       if (!isCritique && result.newValue == 0 && inc < 0) { // perte endurance et endurance devient 0 -> -1 vie sauf si coup critique | ||||
|         sante.vie.value = sante.vie.value - 1; | ||||
|       } | ||||
| @@ -1157,21 +1153,23 @@ export class RdDActor extends Actor { | ||||
|       if (inc > 0) { // le max d'endurance s'applique seulement à la récupération | ||||
|         result.newValue = Math.min(result.newValue, this._computeEnduranceMax()) | ||||
|       } | ||||
|       if (data.value - result.newValue > 1) { | ||||
|       const perte = compteur.value - result.newValue; | ||||
|       if (perte > 1) { | ||||
|         // Peut-être sonné si 2 points d'endurance perdus d'un coup | ||||
|         const testIsSonne = this.testSiSonne(sante, result.newValue); | ||||
|         result.sonne = testIsSonne.sonne; | ||||
|         result.jetEndurance = testIsSonne.roll.total; | ||||
|       } else if (inc > 0 && !this.isEntiteCauchemar()) { | ||||
|         sante.sonne.value = false; | ||||
|       } else if (inc > 0) { | ||||
|         await this.setSonne(false); | ||||
|       } | ||||
|       if (sante.fatigue && inc < 0) { // Each endurance lost -> fatigue lost | ||||
|         fatigue = perte; | ||||
|       } | ||||
|     } | ||||
|     data.value = result.newValue; | ||||
|     compteur.value = result.newValue; | ||||
|     //console.log(name, inc, data.value, result.newValue, minValue, data.max); | ||||
|     if (sante.fatigue) { // If endurance lost, then the same amount of fatigue cannot be recovered | ||||
|       sante.fatigue.value = Math.max(sante.fatigue.value, this._computeFatigueMin()); | ||||
|     } | ||||
|     //console.log("SANTE::::", sante); | ||||
|     // If endurance lost, then the same amount of fatigue cannot be recovered | ||||
|     sante.fatigue.value = Math.max(sante.fatigue.value + fatigue, this._computeFatigueMin()); | ||||
|  | ||||
|     await this.update({ "data.sante": sante }); | ||||
|     return result; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user