diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 15c92bb3..7486cace 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -54,7 +54,7 @@ export class RdDActorSheet extends ActorSheet { list.push(item); } } - + data.data.fatigueHTML = "" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.fatigue.max ).html() +"
"; data.data.materiel = this._checkNull(data.itemsByType['objet']); data.data.armes = this._checkNull(data.itemsByType['arme']); data.data.armures = this._checkNull(data.itemsByType['armure']); @@ -62,6 +62,8 @@ export class RdDActorSheet extends ActorSheet { data.data.potions = this._checkNull(data.itemsByType['potions']); data.data.competenceByCategory = data.competenceByCategory; + console.log("HTML", data.data.fatigueHTML); + return data; } @@ -93,6 +95,7 @@ export class RdDActorSheet extends ActorSheet { let compName = event.currentTarget.text; this.actor.rollCompetence( compName); }); + // On carac change $(".competence-value").change((event) => { let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", ""); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index ba855a35..79ce0aac 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -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 = "\ + \ + \ + \ + \ + \ + \ + \ + \ +
" + 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 = $("").addClass('table-fatigue'); + let segmentIdx = 0; + for (var line=0; line < fatigueLineSize.length; line++) { + let row = $(""); + let segmentsPerLine = fatigueLineSize[line]; + while (segmentIdx < segmentsPerLine) { + let freeSize = fatigueTab[segmentIdx]; + for (let col=0; col <5; col++) { + if ( col < freeSize ) + row.append("
"); + else + row.append(""); + } + row.append(""); + segmentIdx = segmentIdx + 1; + } + table.append(row); + } + console.log("fatigue", table); + return table; + } + /* -------------------------------------------- */ static findCompetence(compList, compName) diff --git a/styles/simple.css b/styles/simple.css index 09f0ddb6..b2227c5e 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -305,9 +305,30 @@ background-color: lightblue; } +/* ======================================== */ +/* Global UI elements */ select { font-family: "GoudyAcc", sans-serif; } button { font-family: "GoudyAcc", sans-serif; } + +/* ======================================== */ +/* Fatigue CSS */ +.table-fatigue { + table-layout: fixed; +} +.table-fatigue td { + table-layout: fixed; + width: 8px; + height: 8px; +} +.table-fatigue .fatigue-none { + background-color: black; + border: 1px solid #999; +} +.table-fatigue .fatigue-free { + border: 1px solid #999; +} + diff --git a/template.json b/template.json index d468144b..8beeedfd 100644 --- a/template.json +++ b/template.json @@ -147,21 +147,21 @@ "type": "number", "max": 10, "value": 10, - "label": "Points de Vie", + "label": "Vie", "derivee": true }, "endurance": { "type": "number", "max": 10, "value": 10, - "label": "Points d'Endurance", + "label": "Endurance", "derivee": true }, "fatigue": { "type": "number", - "max": 40, - "value": 10, - "label": "Points de Fatigue", + "max": 0, + "value": 0, + "label": "Fatigue", "derivee": true }, "legeres": { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index a3a87309..bb9ef98e 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -5,7 +5,7 @@

-
+
Vie /{{data.sante.vie.max}} @@ -14,6 +14,10 @@ Endurance /{{data.sante.fatigue.max}}
+
+ Fatigue + {{{data.fatigueHTML}}} +