Séparation de l'Actor Vehicule

This commit is contained in:
2023-11-03 20:21:17 +01:00
parent 038e922f0f
commit ece9ab6f64
8 changed files with 98 additions and 93 deletions

View File

@ -28,7 +28,7 @@ const ajustementsEncaissement = Misc.intArray(-10, 26);
/* -------------------------------------------- */
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]];
const fatigue = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
for (let i = 0; i <= max; i++) {
const ligneFatigue = duplicate(fatigue[i]);
const caseIncrementee = cycle[i % 6];
@ -55,7 +55,7 @@ function _cumulSegmentsFatigue(matrix) {
}
/* -------------------------------------------- */
const fatigueMatrix = _buildAllSegmentsFatigue(60);
export const fatigueMatrix = _buildAllSegmentsFatigue(60);
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
@ -460,10 +460,8 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static getSegmentsFatigue(maxEnd) {
maxEnd = Math.max(maxEnd, 1);
maxEnd = Math.min(maxEnd, fatigueMatrix.length);
return fatigueMatrix[maxEnd];
static getSegmentsFatigue(maxEndurance) {
return fatigueMatrix[Math.min(Math.max(maxEndurance, 1), fatigueMatrix.length)];
}
/* -------------------------------------------- */
@ -491,7 +489,7 @@ export class RdDUtility {
// Build the nice (?) html table used to manage fatigue.
// max should be the endurance max value
static makeHTMLfatigueMatrix(fatigue, maxEndurance) {
let segments = this.getSegmentsFatigue(maxEndurance);
const segments = this.getSegmentsFatigue(maxEndurance);
return this.makeHTMLfatigueMatrixForSegment(fatigue, segments);
}
@ -625,25 +623,6 @@ export class RdDUtility {
return perte.total;
}
/* -------------------------------------------- */
static currentFatigueMalus(value, max) {
if (ReglesOptionnelles.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 0;
}
/* -------------------------------------------- */
static async responseNombreAstral(callData) {
let actor = game.actors.get(callData.id);