forked from public/foundryvtt-reve-de-dragon
More automatism
This commit is contained in:
@ -58,7 +58,8 @@ const fatigueMatrix = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, //
|
||||
[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 fatigueLineSize = [ 3, 6, 7, 8, 9, 10, 11, 12];
|
||||
const fatigueLineMalus = [ 0, -1, -2, -3, -4, -5, -6, -7 ];
|
||||
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>\
|
||||
@ -247,6 +248,8 @@ export class RdDUtility {
|
||||
max = (max < 16) ? 16 : max;
|
||||
max = (max > 30) ? 30 : max;
|
||||
value = (value > max) ? max : value;
|
||||
value = (value < 0) ? 0 : value;
|
||||
|
||||
let fatigueTab = fatigueMatrix[max];
|
||||
let idx = 0; // Current fatigue slot
|
||||
let remFatigue = value;
|
||||
@ -257,23 +260,30 @@ export class RdDUtility {
|
||||
// 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;
|
||||
for (var line=0; line < fatigueLineSize.length; line++) {
|
||||
let row = $("<tr/>");
|
||||
let segmentsPerLine = fatigueLineSize[line];
|
||||
row.append("<td class='fatigue-malus'>" + fatigueLineMalus[line] + "</td>");
|
||||
while (segmentIdx < segmentsPerLine) {
|
||||
let freeSize = fatigueTab[segmentIdx];
|
||||
for (let col=0; col <5; col++) {
|
||||
if ( col < freeSize )
|
||||
row.append("<td class='fatigue-free'/>");
|
||||
else
|
||||
if ( col < freeSize ) {
|
||||
if (fatigueCount < value )
|
||||
row.append("<td class='fatigue-used'/>");
|
||||
else
|
||||
row.append("<td class='fatigue-free'/>");
|
||||
fatigueCount++;
|
||||
} else {
|
||||
row.append("<td class='fatigue-none'/>");
|
||||
}
|
||||
}
|
||||
row.append("<td class='fatigue-separator'/>");
|
||||
segmentIdx = segmentIdx + 1;
|
||||
}
|
||||
table.append(row);
|
||||
}
|
||||
console.log("fatigue", table);
|
||||
//console.log("fatigue", table);
|
||||
return table;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user