diff --git a/RdD.geany b/RdD.geany index e219c52c..3ffe9624 100644 --- a/RdD.geany +++ b/RdD.geany @@ -28,19 +28,17 @@ long_line_column=72 [files] current_page=4 -FILE_NAME_0=5110;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplate.json;0;2 -FILE_NAME_1=332;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor-sheet.js;0;2 -FILE_NAME_2=1730;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fdialog-competence.html;0;2 -FILE_NAME_3=1479;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor.js;0;2 -FILE_NAME_4=2451;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Factor-sheet.html;0;2 -FILE_NAME_5=6844;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-utility.js;0;2 +FILE_NAME_0=6135;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplate.json;0;2 +FILE_NAME_1=1602;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor-sheet.js;0;2 +FILE_NAME_2=1792;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fdialog-competence.html;0;2 +FILE_NAME_3=4217;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor.js;0;2 +FILE_NAME_4=405;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Factor-sheet.html;0;2 +FILE_NAME_5=12392;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-utility.js;0;2 FILE_NAME_6=335;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fitem-competence-sheet.html;0;2 FILE_NAME_7=985;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Fsimple.js;0;2 FILE_NAME_8=28185;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Fscripts%2Fdice-wfrp4e.js;0;2 FILE_NAME_9=674;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Ftemplates%2Fchat%2Fskill-dialog.html;0;2 -FILE_NAME_10=5952;CSS;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fstyles%2Fsimple.css;0;2 -FILE_NAME_11=2003;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Fscripts%2Factor%2Factor-wfrp4e.js;0;2 -FILE_NAME_12=105669;CSS;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Fcss%2Fwfrp4e.css;0;2 +FILE_NAME_10=6826;CSS;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fstyles%2Fsimple.css;0;2 [VTE] last_dir=/home/sigmar diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 7486cace..f08f9dc9 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.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,7 +62,7 @@ export class RdDActorSheet extends ActorSheet { data.data.potions = this._checkNull(data.itemsByType['potions']); data.data.competenceByCategory = data.competenceByCategory; - console.log("HTML", data.data.fatigueHTML); + //console.log(">>>>> data update"); return data; } @@ -102,7 +102,33 @@ export class RdDActorSheet extends ActorSheet { console.log("Value changed :", event, caracName); this.actor.updateCarac( caracName, parseInt(event.target.value) ); } ); + + $("#vie-plus").click((event) => { + this.actor.santeIncDec("vie", 1); + this.render(true); + }); + $("#vie-moins").click((event) => { + this.actor.santeIncDec("vie", -1); + this.render(true); + }); + $("#endurance-plus").click((event) => { + this.actor.santeIncDec("endurance", 1); + this.render(true); + }); + $("#endurance-moins").click((event) => { + this.actor.santeIncDec("endurance", -1); + this.render(true); + }); + $("#fatigue-plus").click((event) => { + this.actor.santeIncDec("fatigue", 1); + this.render(true); + }); + $("#fatigue-moins").click((event) => { + this.actor.santeIncDec("fatigue", -1); + this.render(true); + }); } + /* -------------------------------------------- */ @@ -120,7 +146,6 @@ export class RdDActorSheet extends ActorSheet { /** @override */ _updateObject(event, formData) { - // Update the Actor return this.object.update(formData); } diff --git a/module/actor.js b/module/actor.js index d203d049..4a04c0d7 100644 --- a/module/actor.js +++ b/module/actor.js @@ -91,7 +91,16 @@ export class RdDActor extends Actor { data.carac[caracName].value = caracValue; // Force update ? RdDUtility.computeCarac( data ); } - + + /* -------------------------------------------- */ + santeIncDec(name, inc ) { + let data = this.data.data.sante[name]; + data.value = data.value + inc; + if ( data.value > data.max ) data.value = data.max; + if ( data.value < 0 ) data.value = 0; + console.log(">>>> NEW VI", name, data.value); + } + /* -------------------------------------------- */ rollCompetence( compName ) { diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 79ce0aac..2d42ec8f 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -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 = "\ \ \ @@ -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 = $("
").addClass('table-fatigue'); let segmentIdx = 0; + let fatigueCount = 0; for (var line=0; line < fatigueLineSize.length; line++) { let row = $(""); let segmentsPerLine = fatigueLineSize[line]; + row.append(""); while (segmentIdx < segmentsPerLine) { let freeSize = fatigueTab[segmentIdx]; for (let col=0; col <5; col++) { - if ( col < freeSize ) - row.append("
" + fatigueLineMalus[line] + ""); - else + if ( col < freeSize ) { + if (fatigueCount < value ) + row.append(""); + else + row.append(""); + fatigueCount++; + } else { row.append(""); + } } row.append(""); segmentIdx = segmentIdx + 1; } table.append(row); } - console.log("fatigue", table); + //console.log("fatigue", table); return table; } diff --git a/styles/simple.css b/styles/simple.css index b2227c5e..c51c65a8 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -321,8 +321,12 @@ button { } .table-fatigue td { table-layout: fixed; - width: 8px; - height: 8px; + width: 4px; + height: 4px; +} +.table-fatigue .fatigue-used { + background-color: DarkRed; + border: 1px solid #999; } .table-fatigue .fatigue-none { background-color: black; @@ -331,4 +335,9 @@ button { .table-fatigue .fatigue-free { border: 1px solid #999; } - +.table-fatigue .fatigue-malus { + font-size:8px; +} + .flex-fatigue { + flex-grow: 2; +} diff --git a/template.json b/template.json index 8beeedfd..659b7e77 100644 --- a/template.json +++ b/template.json @@ -144,7 +144,7 @@ }, "sante": { "vie": { - "type": "number", + "type": "number", "max": 10, "value": 10, "label": "Vie", @@ -163,7 +163,9 @@ "value": 0, "label": "Fatigue", "derivee": true - }, + } + }, + "blessures": "legeres": { "nombre": 0, "liste": [ { "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": "" }, @@ -180,10 +182,6 @@ "critiques": { "nombre": 0, "liste": [ { "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": "" } ] - }, - "ethylisme": { - "value": 0, - "label": "" } }, "attributs": { @@ -221,30 +219,49 @@ "compteurs": { "reve": { "max": 0, - "value": 0 + "value": 0, + "label": "Points de Rêve" }, "sust": { - "value": 0 + "value": 0, + "label": "Sust." }, "eau": { - "value": 0 + "value": 0, + "label": "Eau" }, "moral": { "value": 0, - "exaltation": 0, - "dissolution": 0 + "label": "Moral" + }, + "exaltation": { + "value": 0, + "label": "Exaltation" + }, + "dissolution": { + "value": 0, + "label": "Dissolution" }, "chance": { "value": 0, - "destinee": 0 + "label": "Chance" + }, + "destinee": { + "value": 0, + "label": "Destinée" }, "stress": { - "value": 0 + "value": 0, + "label": "Stress" }, "etat": { "value": 0, - "label": "" - } + "label": "Etat général" + }, + "ethylisme": { + "value": 0, + "label": "Ethylisme" + } }, "argent": { "deniers": { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index bb9ef98e..5610b85d 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -5,17 +5,17 @@

-
+
- Vie - /{{data.sante.vie.max}} + Vie + / - + /{{data.sante.vie.max}}
- Endurance - /{{data.sante.fatigue.max}} + Endurance + / - + /{{data.sante.endurance.max}}
-
- Fatigue +
+ Fatigue + / - {{{data.fatigueHTML}}}
@@ -61,7 +61,7 @@ {{/each}} {{#each data.sante as |point key|}}
  • - {{point.label}} : {{point.value}} + {{point.label}} : {{point.value}} / {{point.max}}
  • {{/each}}