fatigue optionnelle #113

This commit is contained in:
Vincent Vandemeulebrouck
2021-05-08 20:08:56 +02:00
parent 11131e3b52
commit 51a3c4d04a
10 changed files with 97 additions and 86 deletions

View File

@ -6,6 +6,7 @@ import { Misc } from "./misc.js";
import { Grammar } from "./grammar.js";
import { TMRUtility } from "./tmr-utility.js";
import { DialogItemAchat } from "./dialog-item-achat.js";
import { ReglesOptionelles } from "./regles-optionelles.js";
/* -------------------------------------------- */
// This table starts at 0 -> niveau -10
@ -388,6 +389,14 @@ export class RdDUtility {
}
return -7;
}
static calculFatigueHtml(fatigue, endurance) {
return ReglesOptionelles.isUsing("appliquer-fatigue") ? {
malus: RdDUtility.calculMalusFatigue(fatigue, endurance),
html: "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(fatigue, endurance).html() + "</table>"
} : { malus:0, html:''};
}
/* -------------------------------------------- */
// Build the nice (?) html table used to manage fatigue.
// max should be the endurance max value
@ -475,18 +484,21 @@ export class RdDUtility {
/* -------------------------------------------- */
static currentFatigueMalus(value, max) {
max = Math.max(1, Math.min(max, 60));
value = Math.min(max * 2, Math.max(0, value));
let fatigueTab = fatigueMatrix[max];
let fatigueRem = value;
for (let idx = 0; idx < fatigueTab.length; idx++) {
fatigueRem -= fatigueTab[idx];
if (fatigueRem <= 0) {
return fatigueMalus[idx];
if (ReglesOptionelles.isUsing("appliquer-fatigue")) {
max = Math.max(1, Math.min(max, 60));
value = Math.min(max * 2, Math.max(0, value));
let fatigueTab = fatigueMatrix[max];
let fatigueRem = value;
for (let idx = 0; idx < fatigueTab.length; idx++) {
fatigueRem -= fatigueTab[idx];
if (fatigueRem <= 0) {
return fatigueMalus[idx];
}
}
return -7; // This is the max !
}
return -7; // This is the max !
return 0;
}
/* -------------------------------------------- */