diff --git a/module/actor-sheet.js b/module/actor-sheet.js index a914bc30..7dc2531d 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -106,7 +106,11 @@ export class RdDActorSheet extends ActorSheet { data.difficultesLibres = CONFIG.RDD.difficultesLibres; // low is normal, this the base used to compute the grid. - data.data.fatigueHTML = "" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "
"; + data.data.fatigue = { + malus: RdDUtility.calculMalusFatigue(data.data.sante.fatigue.value, data.data.sante.endurance.max), + html: "" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "
" + } + RdDUtility.filterItemsPerTypeForSheet(data ); data.data.sortReserve = data.data.reve.reserve.list; diff --git a/module/actor.js b/module/actor.js index 0ed3bca2..d23454a0 100644 --- a/module/actor.js +++ b/module/actor.js @@ -998,7 +998,10 @@ export class RdDActor extends Actor { } let data = { - fatigueHTML:"" + RdDUtility.makeHTMLfatigueMatrix( this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max ).html() + "
", + fatigue: { + malus: RdDUtility.calculMalusFatigue(this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max), + html: "" + RdDUtility.makeHTMLfatigueMatrix( this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max ).html() + "
" + }, draconic: this.getDraconicList(), sort: this.getSortList(), caracReve: this.data.data.carac.reve.value, diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 30fdca98..34aeeb6f 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -31,18 +31,33 @@ const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, 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]]; - for (let i = 0; i <= 40; i++) { + for (let i = 0; i <= max; i++) { const ligneFatigue= duplicate(fatigue[i]); const caseIncrementee = cycle[i % 6]; ligneFatigue[caseIncrementee]++; ligneFatigue[caseIncrementee + 6]++; ligneFatigue.fatigueMax = 2 * (i + 1); fatigue[i + 1] = ligneFatigue ; + } return fatigue; } +function _cumulSegmentsFatigue(matrix) { + let cumulMatrix = []; + for (let line of matrix) + { + let cumul = duplicate(line); + + for (let i = 1; i < 12; i++) { + cumul[i] += cumul[i - 1]; + } + cumulMatrix.push(cumul); + } + return cumulMatrix; +} const fatigueMatrix = _buildAllSegmentsFatigue(30); +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 const fatigueLineSize = [ 3, 6, 7, 8, 9, 10, 11, 12]; @@ -372,20 +387,24 @@ export class RdDUtility { data.compteurs.chance.max = data.carac.chance.value; } - static getSegmentsFatigue(endurance) { - endurance = Math.max(endurance, 1); - endurance = Math.min(endurance, fatigueMatrix.length); - return fatigueMatrix[endurance]; + static getSegmentsFatigue(maxEnd) { + maxEnd = Math.max(maxEnd, 1); + maxEnd = Math.min(maxEnd, fatigueMatrix.length); + return fatigueMatrix[maxEnd]; } - static cumulSegments(segments) { - let cumuls = [segments[0]]; - for (let i = 1; i < 12; i++) { - cumuls[i] = segments[i] + cumuls[i - 1]; + static calculMalusFatigue(fatigue, maxEnd) + { + maxEnd = Math.max(maxEnd, 1); + maxEnd = Math.min(maxEnd, cumulFatigueMatrix.length); + let segments = cumulFatigueMatrix[maxEnd]; + for (let i=0; i<12; i++) { + if (fatigue <= segments[i]) { + return fatigueMalus[i] + } } - return cumuls; + return -7; } - /* -------------------------------------------- */ // Build the nice (?) html table used to manage fatigue. // max should be the endurance max value diff --git a/styles/simple.css b/styles/simple.css index bb30998f..faa6891f 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -871,3 +871,34 @@ background: rgba(0, 0, 0, 0.5); position: relative; bottom: 6px; } + +/* Tooltip container */ +.tooltip { + position: relative; + display: inline-block; + border-bottom: 1px dotted black; /* If you want dots under the hoverable text */ +} + +/* Tooltip text */ +.tooltip .tooltiptext { + visibility: hidden; + width: 360px; + text-align: center; + padding: 5px 0; + border-radius: 6px; + + /* Position the tooltip text */ + position: absolute; + z-index: 1; + left: -100%; + + /* Fade in tooltip */ + opacity: 0; + transition: opacity 0.3s; +} + +/* Show the tooltip text when you mouse over the tooltip container */ +.tooltip:hover .tooltiptext { + visibility: visible; + opacity: 1; +} \ No newline at end of file diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 7c358b3c..1c1f2269 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -8,27 +8,32 @@

-
-
- Vie + / - - /{{data.sante.vie.max}} -
-
- Endurance + / - - /{{data.sante.endurance.max}} -
-
- Sonné : - -
-
+
+
+ Vie + / - + /{{data.sante.vie.max}} +
+
+ Endurance + / - + /{{data.sante.endurance.max}} +
+
+ Fatigue + / - + /{{data.sante.fatigue.max}} +
+
+ Sonné : + +
+
Rêve + / - /{{data.reve.seuil.value}} -
-
- Fatigue + / - - {{{data.fatigueHTML}}} +
+
+
Malus de fatigue : {{data.fatigue.malus}} + {{{data.fatigue.html}}} +
diff --git a/templates/dialog-tmr.html b/templates/dialog-tmr.html index 365c5762..86b3a36e 100644 --- a/templates/dialog-tmr.html +++ b/templates/dialog-tmr.html @@ -25,7 +25,7 @@
Fatigue - {{{fatigueHTML}}} + {{{fatigue.html}}}