forked from public/foundryvtt-reve-de-dragon
Compute general state
This commit is contained in:
@ -224,8 +224,8 @@ export class RdDUtility {
|
||||
let endurance = Math.max( parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value), parseInt(data.sante.vie.max) + parseInt(data.carac.volonte.value) );
|
||||
data.sante.endurance.max = endurance;
|
||||
data.sante.endurance.value = endurance;
|
||||
data.sante.fatigue.max = endurance;
|
||||
data.sante.fatigue.value = endurance;
|
||||
data.sante.fatigue.max = endurance*2;
|
||||
data.sante.fatigue.value = 0;
|
||||
|
||||
data.attributs.sconst.value = 5; // Max !
|
||||
if ( data.carac.constitution.value < 9 )
|
||||
@ -240,24 +240,26 @@ export class RdDUtility {
|
||||
data.attributs.sust.value = 2;
|
||||
else if (data.carac.taille.value < 14 )
|
||||
data.attributs.sust.value = 3;
|
||||
|
||||
//Compteurs
|
||||
data.compteurs.reve.value = data.carac.reve.value;
|
||||
data.compteurs.reve.max = data.carac.reve.value;
|
||||
data.compteurs.chance.value = data.carac.chance.value;
|
||||
data.compteurs.chance.max = data.carac.chance.value;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static makeHTMLfatigueMatrix( value, max )
|
||||
// Build the nice (?) html table used to manage fatigue.
|
||||
// max should be the endurance max value
|
||||
static makeHTMLfatigueMatrix( value, max )
|
||||
{
|
||||
max = (max < 16) ? 16 : max;
|
||||
max = (max > 30) ? 30 : max;
|
||||
value = (value > max) ? max : value;
|
||||
value = (value > max*2) ? max*2 : value;
|
||||
value = (value < 0) ? 0 : value;
|
||||
|
||||
let fatigueTab = fatigueMatrix[max];
|
||||
let idx = 0; // Current fatigue slot
|
||||
let remFatigue = value;
|
||||
while ( remFatigue >= fatigueTab[idx] ) { // computes the fatigue segment consumed
|
||||
remFatigue = remFatigue - fatigueTab[idx];
|
||||
idx = idx + 1;
|
||||
}
|
||||
// At this point, we have the segment id in idx and the remaing fatigue points for the next segment in remFatigue
|
||||
|
||||
let table = $("<table/>").addClass('table-fatigue');
|
||||
let segmentIdx = 0;
|
||||
let fatigueCount = 0;
|
||||
@ -287,6 +289,25 @@ export class RdDUtility {
|
||||
return table;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static currentFatigueMalus( value, max)
|
||||
{
|
||||
max = (max < 16) ? 16 : max;
|
||||
max = (max > 30) ? 30 : max;
|
||||
value = (value > max*2) ? max*2 : value;
|
||||
value = (value < 0) ? 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 !
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
static findCompetence(compList, compName)
|
||||
|
Reference in New Issue
Block a user