forked from public/foundryvtt-reve-de-dragon
Afficher la fatigue avec les compteurs
This commit is contained in:
@ -31,18 +31,33 @@ const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1,
|
||||
function _buildAllSegmentsFatigue(max) {
|
||||
const cycle = [5, 2, 4, 1, 3, 0];
|
||||
let fatigue = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
|
||||
for (let i = 0; i <= 40; i++) {
|
||||
for (let i = 0; i <= max; i++) {
|
||||
const ligneFatigue= duplicate(fatigue[i]);
|
||||
const caseIncrementee = cycle[i % 6];
|
||||
ligneFatigue[caseIncrementee]++;
|
||||
ligneFatigue[caseIncrementee + 6]++;
|
||||
ligneFatigue.fatigueMax = 2 * (i + 1);
|
||||
fatigue[i + 1] = ligneFatigue ;
|
||||
|
||||
}
|
||||
return fatigue;
|
||||
}
|
||||
function _cumulSegmentsFatigue(matrix) {
|
||||
let cumulMatrix = [];
|
||||
for (let line of matrix)
|
||||
{
|
||||
let cumul = duplicate(line);
|
||||
|
||||
for (let i = 1; i < 12; i++) {
|
||||
cumul[i] += cumul[i - 1];
|
||||
}
|
||||
cumulMatrix.push(cumul);
|
||||
}
|
||||
return cumulMatrix;
|
||||
}
|
||||
|
||||
const fatigueMatrix = _buildAllSegmentsFatigue(30);
|
||||
const cumulFatigueMatrix = _cumulSegmentsFatigue(fatigueMatrix);
|
||||
|
||||
const fatigueMalus = [ 0, 0, 0, -1, -1, -1, -2, -3, -4, -5, -6, -7 ]; // Provides the malus for each segment of fatigue
|
||||
const fatigueLineSize = [ 3, 6, 7, 8, 9, 10, 11, 12];
|
||||
@ -372,20 +387,24 @@ export class RdDUtility {
|
||||
data.compteurs.chance.max = data.carac.chance.value;
|
||||
}
|
||||
|
||||
static getSegmentsFatigue(endurance) {
|
||||
endurance = Math.max(endurance, 1);
|
||||
endurance = Math.min(endurance, fatigueMatrix.length);
|
||||
return fatigueMatrix[endurance];
|
||||
static getSegmentsFatigue(maxEnd) {
|
||||
maxEnd = Math.max(maxEnd, 1);
|
||||
maxEnd = Math.min(maxEnd, fatigueMatrix.length);
|
||||
return fatigueMatrix[maxEnd];
|
||||
}
|
||||
|
||||
static cumulSegments(segments) {
|
||||
let cumuls = [segments[0]];
|
||||
for (let i = 1; i < 12; i++) {
|
||||
cumuls[i] = segments[i] + cumuls[i - 1];
|
||||
static calculMalusFatigue(fatigue, maxEnd)
|
||||
{
|
||||
maxEnd = Math.max(maxEnd, 1);
|
||||
maxEnd = Math.min(maxEnd, cumulFatigueMatrix.length);
|
||||
let segments = cumulFatigueMatrix[maxEnd];
|
||||
for (let i=0; i<12; i++) {
|
||||
if (fatigue <= segments[i]) {
|
||||
return fatigueMalus[i]
|
||||
}
|
||||
}
|
||||
return cumuls;
|
||||
return -7;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// Build the nice (?) html table used to manage fatigue.
|
||||
// max should be the endurance max value
|
||||
|
Reference in New Issue
Block a user