fatigue optionnelle #113
This commit is contained in:
@ -196,10 +196,10 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getFatigueActuelle() {
|
||||
if (!this.isPersonnage()) {
|
||||
return 0;
|
||||
if (ReglesOptionelles.isUsing("appliquer-fatigue") && this.isPersonnage()) {
|
||||
return Misc.toInt(Misc.templateData(this).sante.fatigue?.value);
|
||||
}
|
||||
return Misc.toInt(Misc.templateData(this).sante.fatigue?.value);
|
||||
return 0;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getFatigueMax() {
|
||||
@ -544,7 +544,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
await this.santeIncDec("vie", actorData.data.sante.vie.max - actorData.data.sante.vie.value);
|
||||
await this.santeIncDec("endurance", actorData.data.sante.endurance.max - actorData.data.sante.endurance.value);
|
||||
if (actorData.data.sante.fatigue) {
|
||||
if (ReglesOptionelles.isUsing("appliquer-fatigue") && actorData.data.sante.fatigue) {
|
||||
await this.update({ "data.sante.fatigue.value": 0 });
|
||||
}
|
||||
}
|
||||
@ -594,17 +594,18 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async recupererFatigue(message) {
|
||||
let fatigue = Misc.templateData(this).sante.fatigue.value;
|
||||
const fatigueMin = this._computeFatigueMin();
|
||||
if (fatigue <= fatigueMin) {
|
||||
message.content += "Vous êtes déjà reposé. ";
|
||||
return;
|
||||
}
|
||||
fatigue = Math.max(fatigueMin, this._calculRecuperationSegment(fatigue));
|
||||
console.log("recupererFatigue", fatigue)
|
||||
await this.update({ "data.sante.fatigue.value": fatigue });
|
||||
if (fatigue == 0) {
|
||||
message.content += "Vous êtes complêtement reposé. ";
|
||||
if (ReglesOptionelles.isUsing("appliquer-fatigue")) {
|
||||
let fatigue = Misc.templateData(this).sante.fatigue.value;
|
||||
const fatigueMin = this._computeFatigueMin();
|
||||
if (fatigue <= fatigueMin) {
|
||||
message.content += "Vous êtes déjà reposé. ";
|
||||
return;
|
||||
}
|
||||
fatigue = Math.max(fatigueMin, this._calculRecuperationSegment(fatigue));
|
||||
await this.update({ "data.sante.fatigue.value": fatigue });
|
||||
if (fatigue == 0) {
|
||||
message.content += "Vous êtes complêtement reposé. ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1157,8 +1158,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
// Pour les autres
|
||||
let state = - (actorData.data.sante.vie.max - actorData.data.sante.vie.value);
|
||||
if (actorData.data.sante.fatigue) {
|
||||
// Creatures n'ont pas de fatigue
|
||||
if (ReglesOptionelles.isUsing("appliquer-fatigue") && actorData.data.sante.fatigue) {
|
||||
state += RdDUtility.currentFatigueMalus(actorData.data.sante.fatigue.value, actorData.data.sante.endurance.max);
|
||||
}
|
||||
// Ajout de l'éthylisme
|
||||
@ -1471,7 +1471,9 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async santeIncDec(name, inc, options = { isCritique: false, ethylisme: false }) {
|
||||
|
||||
if (name=='fatigue' && !ReglesOptionelles.isUsing("appliquer-fatigue")) {
|
||||
return;
|
||||
}
|
||||
const sante = duplicate(Misc.templateData(this).sante);
|
||||
let compteur = sante[name];
|
||||
if (!compteur) {
|
||||
@ -1511,7 +1513,7 @@ export class RdDActor extends Actor {
|
||||
compteur.value = result.newValue;
|
||||
//console.log(name, inc, data.value, result.newValue, minValue, data.max);
|
||||
// If endurance lost, then the same amount of fatigue cannot be recovered
|
||||
if (sante.fatigue && fatigue > 0) {
|
||||
if (ReglesOptionelles.isUsing("appliquer-fatigue") && sante.fatigue && fatigue > 0) {
|
||||
sante.fatigue.value = Math.max(sante.fatigue.value + fatigue, this._computeFatigueMin());
|
||||
}
|
||||
await this.update({ "data.sante": sante });
|
||||
@ -2342,6 +2344,7 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async _tacheResult(rollData) {
|
||||
// Mise à jour de la tache
|
||||
rollData.appliquerFatigue = ReglesOptionelles.isUsing("appliquer-fatigue");
|
||||
rollData.tache = duplicate(rollData.tache);
|
||||
rollData.tache.data.points_de_tache_courant += rollData.rolled.ptTache;
|
||||
if (rollData.rolled.isETotal) {
|
||||
@ -2800,10 +2803,7 @@ export class RdDActor extends Actor {
|
||||
const endurance = actorData.data.sante.endurance.max;
|
||||
let tmrFormData = {
|
||||
mode: mode,
|
||||
fatigue: {
|
||||
malus: RdDUtility.calculMalusFatigue(fatigue, endurance),
|
||||
html: "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(fatigue, endurance).html() + "</table>"
|
||||
},
|
||||
fatigue: RdDUtility.calculFatigueHtml(fatigue, endurance),
|
||||
draconic: this.getDraconicList(),
|
||||
sort: this.getSortList(),
|
||||
caracReve: actorData.data.carac.reve.value,
|
||||
|
Reference in New Issue
Block a user