Fatigue management, ongoing work

This commit is contained in:
2020-05-27 23:47:49 +02:00
parent a6b46cb4ad
commit 63e4e6f91a
5 changed files with 101 additions and 9 deletions

View File

@ -39,9 +39,37 @@ const levelDown = [ { "level": -11, "score": 1, "part": 0, "epart": 2, "etotal":
{ "level": -13, "score": 1, "part": 0, "epart": 2, "etotal": 50 },
{ "level": -14, "score": 1, "part": 0, "epart": 2, "etotal": 30 },
{ "level": -15, "score": 1, "part": 0, "epart": 2, "etotal": 10 },
{ "level": -16, "score": 1, "part": 0, "epart": 2, "etotal": 2 },
{ "level": -16, "score": 1, "part": 0, "epart": 2, "etotal": 2 }
];
const fatigueMatrix = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // Dummy filler for the array.
[2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3 ],
[2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3 ],
[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 ],
[3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 4 ],
[3, 3, 4, 3, 3, 4, 3, 3, 4, 3, 3, 4 ],
[3, 3, 4, 3, 4, 4, 3, 3, 4, 3, 4, 4 ],
[3, 4, 4, 3, 4, 4, 3, 4, 4, 3, 4, 4 ],
[3, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4 ],
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ],
[4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 5 ],
[4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 4, 5 ],
[4, 4, 5, 4, 5, 5, 4, 4, 5, 4, 5, 5 ],
[4, 5, 5, 4, 5, 5, 4, 5, 5, 4, 5, 5 ],
[4, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5 ],
[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ] ];
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];
const fatigueTemplate = "<table>\
<th><tdid=1><td/><td/><td/><td/> <td/> <td/><td/><td/><td/><td/> <td/> <td/><td/><td/><td/><td/></tr>\
<th><td/><td/><td/><td/><td/> <td/> <td/><td/><td/><td/><td/> <td/> <td/><td/><td/><td/><td/></tr>\
<th><td/><td/><td/><td/><td/></tr>\
<th><td/><td/><td/><td/><td/></tr>\
<th><td/><td/><td/><td/><td/></tr>\
<th><td/><td/><td/><td/><td/></tr>\
<th><td/><td/><td/><td/><td/></tr>\
<th><td/><td/><td/><td/><td/></tr>\
</table>"
export class RdDUtility {
/* -------------------------------------------- */
@ -213,6 +241,42 @@ export class RdDUtility {
data.attributs.sust.value = 3;
}
/* -------------------------------------------- */
static makeHTMLfatigueMatrix( value, max )
{
max = (max < 16) ? 16 : max;
max = (max > 30) ? 30 : max;
value = (value > max) ? max : 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;
for (var line=0; line < fatigueLineSize.length; line++) {
let row = $("<tr/>");
let segmentsPerLine = fatigueLineSize[line];
while (segmentIdx < segmentsPerLine) {
let freeSize = fatigueTab[segmentIdx];
for (let col=0; col <5; col++) {
if ( col < freeSize )
row.append("<td class='fatigue-free'/>");
else
row.append("<td class='fatigue-none'/>");
}
row.append("<td class='fatigue-separator'/>");
segmentIdx = segmentIdx + 1;
}
table.append(row);
}
console.log("fatigue", table);
return table;
}
/* -------------------------------------------- */
static findCompetence(compList, compName)