diff --git a/icons/heures/hd05.png b/icons/heures/hd05.png
deleted file mode 100644
index 35a9a1f0..00000000
Binary files a/icons/heures/hd05.png and /dev/null differ
diff --git a/icons/heures/hd05.svg b/icons/heures/hd05.svg
new file mode 100644
index 00000000..d98f1431
--- /dev/null
+++ b/icons/heures/hd05.svg
@@ -0,0 +1,58 @@
+
+
diff --git a/icons/heures/hd05br.png b/icons/heures/hd05br.png
deleted file mode 100644
index bdc5b95f..00000000
Binary files a/icons/heures/hd05br.png and /dev/null differ
diff --git a/icons/heures/hd08.png b/icons/heures/hd08.png
deleted file mode 100644
index 72992426..00000000
Binary files a/icons/heures/hd08.png and /dev/null differ
diff --git a/icons/heures/hd08.svg b/icons/heures/hd08.svg
new file mode 100644
index 00000000..4edd18fc
--- /dev/null
+++ b/icons/heures/hd08.svg
@@ -0,0 +1,58 @@
+
+
diff --git a/icons/heures/hd08br.png b/icons/heures/hd08br.png
deleted file mode 100644
index 31ef014d..00000000
Binary files a/icons/heures/hd08br.png and /dev/null differ
diff --git a/icons/heures/hd12.png b/icons/heures/hd12.png
deleted file mode 100644
index 4cfc61e5..00000000
Binary files a/icons/heures/hd12.png and /dev/null differ
diff --git a/icons/heures/hd12.svg b/icons/heures/hd12.svg
new file mode 100644
index 00000000..7d56c96d
--- /dev/null
+++ b/icons/heures/hd12.svg
@@ -0,0 +1,58 @@
+
+
diff --git a/icons/heures/hd12br.png b/icons/heures/hd12br.png
deleted file mode 100644
index c5ec83c3..00000000
Binary files a/icons/heures/hd12br.png and /dev/null differ
diff --git a/module/actor.js b/module/actor.js
index d23454a0..1687a427 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -332,39 +332,47 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async dormir(heures=1) {
let message = { title : "Récupération", content :"Vous dormez " + heures + " heure" + (heures > 1 ? "s": "") };
- this.recupereEndurance(message);
+ await this.recupereEndurance(message);
for (let i=0; i0) {
- message.content += "
Vous récuperez " + recupere + " points d'endurance";
+ async recupereEndurance(message) {
+ const manquant = this._computeEnduranceMax() - this.data.data.sante.endurance.value;
+ if (manquant > 0) {
+ await this.santeIncDec("endurance", manquant);
+ message.content += "
Vous récuperez " + manquant + " points d'endurance";
}
}
/* -------------------------------------------- */
- async recupererFatigueUneHeure(message) {
+ async recupererFatigue(message) {
let fatigue = duplicate(this.data.data.sante.fatigue)
- if (fatigue.value == 0) {
+ const fatigueMin = this._computeFatigueMin();
+ if (fatigue.value <= fatigueMin) {
message.content += "
Vous êtes déjà reposé";
return;
}
+ fatigue.value = Math.max(fatigueMin, this._calculRecuperationSegment(fatigue.value));
+ console.log("recupererFatigue", fatigue)
+ await this.update( {"data.sante.fatigue": fatigue } );
+ if (fatigue.value == 0)
+ {
+ message.content += "
Vous êtes bien reposé";
+ }
+ }
+ _calculRecuperationSegment(actuel)
+ {
const segments = RdDUtility.getSegmentsFatigue(this.data.data.sante.endurance.max);
let cumul = 0;
- console.log("recupererFatigue", segments);
-
let i;
for (i=0; i <11; i++) {
cumul += segments[i];
- let diff = cumul - fatigue.value ;
+ let diff = cumul - actuel;
if (diff >= 0)
{
const limit2Segments = Math.floor(segments[i] / 2);
@@ -374,17 +382,11 @@ export class RdDActor extends Actor {
cumul -= segments[i];
break;
}
- }
- fatigue.value = cumul;
- await this.update( {"data.sante.fatigue": fatigue } );
- if (fatigue.value == 0)
- {
- message.content += "
Vous êtes bien reposé";
- }
+ };
+ return cumul;
}
-
/* -------------------------------------------- */
- recuperationReve(message) {
+ async recuperationReve(message) {
const seuil = this.data.data.reve.seuil.value;
const reve = this.getReveActuel();
if (reve >= seuil) {
@@ -740,9 +742,9 @@ export class RdDActor extends Actor {
testSiSonne( sante, endurance )
{
let result = new Roll("d20").roll().total;
- if ( result <= endurance.value)
+ if ( result <= endurance)
sante.sonne.value = false;
- if ( result > endurance.value || result == 20) // 20 is always a failure
+ if ( result > endurance || result == 20) // 20 is always a failure
sante.sonne.value = true;
if (result == 1) {
sante.sonne.value = false;
@@ -766,44 +768,51 @@ export class RdDActor extends Actor {
async santeIncDec(name, inc ) {
const sante = duplicate(this.data.data.sante);
let data = sante[name];
- let lastValue = data.value; // Useful for Endurance and Sonné
- data.value = data.value + inc;
- if ( data.value > data.max ) data.value = data.max;
- if ( data.value < 0 ) data.value = 0;
-
+ let minValue = name == "vie" ? - this.data.data.attributs.sconst : 0;
+ let newValue = Math.max(minValue, Math.min(data.value + inc, data.max));
+
if (name == "endurance" && this.data.type != 'entite' ) {
if ( sante.fatigue && inc < 0 ) { // Each endurance lost -> fatigue lost
sante.fatigue.value = sante.fatigue.value - inc
}
- // If endurance is 0 -> -1 vie
- if ( data.value == 0 && sante.vie.value > 0) {
+ if ( newValue == 0 && inc < 0) { // perte endurance et endurance devient 0 -> -1 vie
sante.vie.value = sante.vie.value - 1;
}
- let diffVie = sante.vie.max - sante.vie.value;
- if ( data.value > data.max - (diffVie*2) ) {
- data.value = data.max - (diffVie*2);
+ newValue = Math.max(0, newValue);
+ if (inc>0) { // le max d'endurance s'applique seulement à la récupération
+ newValue = Math.max(newValue, this._computeEnduranceMax())
+ }
+ if (data.value - newValue > 1) {
+ this.testSiSonne(sante, newValue); // Peut-être sonné si 2 points d'endurance perdus d'un coup
+ } else if (inc>0) {
+ sante.sonne.value = false;
}
- if ( data.value < 0 ) data.value = 0; // Security
-
- let blessures = this.data.data.blessures;
- let nbGraves = this.GetNumberBlessures(blessures.graves.liste);
- let nbCritiques = this.GetNumberBlessures(blessures.critiques.liste);
- let maxEnd = Math.floor( data.max / (2*nbGraves));
- if (data.value > maxEnd ) data.value = maxEnd;
- if ( nbCritiques > 0 && data.value > 1) data.value = 1;
-
- if (lastValue - data.value > 1) this.testSiSonne(sante, data); // Peut-être sonné si 2 points d'endurance perdus d'un coup
}
+ data.value = newValue;
//console.log(name, inc, data.value);
-
- let diffEndurance = sante.endurance.max - this.data.data.sante.endurance.value;
- if ( sante.fatigue && sante.fatigue.value < diffEndurance) // If endurance lost, then the same amount of fatigue cannot be recovered
- sante.fatigue.value = diffEndurance;
+ if ( sante.fatigue) { // If endurance lost, then the same amount of fatigue cannot be recovered
+ sante.fatigue.value = Math.max(sante.fatigue.value, this._computeFatigueMin());
+ }
//console.log("SANTE::::", sante);
await this.update( {"data.sante": sante } );
}
+ _computeFatigueMin() {
+ return this.data.data.sante.endurance.max - this.data.data.sante.endurance.value;
+ }
+
+ _computeEnduranceMax() {
+ let blessures = this.data.data.blessures;
+ let diffVie = this.data.data.sante.vie.max - this.data.data.sante.vie.value;
+ let maxEndVie = this.data.data.sante.endurance.max - (diffVie * 2);
+ let nbGraves = this.GetNumberBlessures(blessures.graves.liste);
+ let nbCritiques = this.GetNumberBlessures(blessures.critiques.liste);
+ let maxEndGraves = Math.floor(this.data.data.sante.endurance.max / (2 * nbGraves));
+ let maxEndCritiques = nbCritiques > 0 ? 1 : this.data.data.sante.endurance.max;
+ return Math.max(0, Math.min(maxEndVie, maxEndGraves, maxEndCritiques));
+ }
+
/* -------------------------------------------- */
async manageBlessureFromSheet( bType, index, active ) {
let bList = duplicate(this.data.data.blessures);
diff --git a/styles/simple.css b/styles/simple.css
index faa6891f..451dd31d 100644
--- a/styles/simple.css
+++ b/styles/simple.css
@@ -225,6 +225,12 @@
margin-right: 10px;
}
+.button-img {
+ width: 8%;
+ height: 8%;
+ border-width: 0;
+}
+
.foundryvtt-reve-de-dragon .sheet-header .header-fields {
-webkit-box-flex: 1;
-ms-flex: 1;
@@ -348,8 +354,8 @@
/* ======================================== */
/* Sheet */
-.sheet header.sheet-header .flex-group-center.flex-hp, .sheet header.sheet-header .flex-group-center.flex-fatigue {font-family: "GrenzeGotisch-Regular";}
-.sheet header.sheet-header .flex-hp {text-align: right;}
+.sheet header.sheet-header .flex-group-center.flex-compteurs, .sheet header.sheet-header .flex-group-center.flex-actions-bar {font-family: "GrenzeGotisch-Regular";}
+.sheet header.sheet-header .flex-compteurs {text-align: right;}
.sheet header.sheet-header .resource-content {width: 3rem;}
.window-app.sheet .window-content .sheet-header{
@@ -365,16 +371,6 @@
background: #f5f4f1 url("img/bg_left.jpg") no-repeat left top;
}
-.sheet header.sheet-header img {
- flex: 0 0 64px;
- height: 64px;
- width: 64px;
- object-fit: cover;
- object-position: 50% 0;
- margin: 0.5rem;
- border: none;
-}
-
section.sheet-body{padding: 0.25rem 0.5rem;}
.sheet nav.sheet-tabs {
@@ -556,7 +552,7 @@ button {
.table-fatigue .fatigue-malus {
font-size: 0.8rem;
}
- .flex-fatigue {
+ .flex-actions-bar {
flex-grow: 2;
}
@@ -883,6 +879,7 @@ background: rgba(0, 0, 0, 0.5);
.tooltip .tooltiptext {
visibility: hidden;
width: 360px;
+ background-color: rgba(0,0,0,0.9);
text-align: center;
padding: 5px 0;
border-radius: 6px;
@@ -890,7 +887,8 @@ background: rgba(0, 0, 0, 0.5);
/* Position the tooltip text */
position: absolute;
z-index: 1;
- left: -100%;
+ top: 30px;
+ left: -30%;
/* Fade in tooltip */
opacity: 0;
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html
index 9ff01c19..c63ca260 100644
--- a/templates/actor-sheet.html
+++ b/templates/actor-sheet.html
@@ -2,51 +2,72 @@
{{!-- Sheet Header --}}