More automatism

This commit is contained in:
LeRatierBretonnien 2020-05-28 23:36:09 +02:00
parent de4a9024fe
commit 15342a65fc
7 changed files with 112 additions and 44 deletions

View File

@ -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

View File

@ -54,7 +54,7 @@ export class RdDActorSheet extends ActorSheet {
list.push(item);
}
}
data.data.fatigueHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.fatigue.max ).html() +"</table>";
data.data.fatigueHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.fatigue.max ).html() + "</table>";
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);
}

View File

@ -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 ) {

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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": {

View File

@ -5,17 +5,17 @@
<img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" height="100" width="100"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name"/></h1>
<div class="grid grid-3col">
<div class="flexrow">
<div class="flex-group-center">
Vie
<input class="resource-content flexrow flex-center flex-between" type="text" name="data.sante.vie.value" value="{{data.sante.vie.value}}" data-dtype="Number"/>/{{data.sante.vie.max}}
Vie <a id="vie-plus">+</a> / <a id="vie-moins">-</a>
<input class="resource-content" type="text" name="data.sante.vie.value" value="{{data.sante.vie.value}}" data-dtype="Number"/>/{{data.sante.vie.max}}
</div>
<div class="flex-group-center">
Endurance
<input class="resource-content flexrow flex-center flex-between" type="text" name="data.sante.fatigue.value" value="{{data.sante.fatigue.value}}" data-dtype="Number"/>/{{data.sante.fatigue.max}}
Endurance <a id="endurance-plus">+</a> / <a id="endurance-moins">-</a>
<input class="resource-content" type="text" name="data.sante.endurance.value" value="{{data.sante.endurance.value}}" data-dtype="Number"/>/{{data.sante.endurance.max}}
</div>
<div class="flex-group-center">
Fatigue
<div class="flex-group-center flex-fatigue">
Fatigue <a id="fatigue-plus">+</a> / <a id="fatigue-moins">-</a>
<span>{{{data.fatigueHTML}}}</span>
</div>
</div>
@ -61,7 +61,7 @@
{{/each}}
{{#each data.sante as |point key|}}
<li class="competence flexrow" data-attribute="{{key}}">
<span class="competence-label flexrow" name="data.attributs.{{key}}.label">{{point.label}} : {{point.value}}</span>
<span class="competence-label flexrow" name="data.attributs.{{key}}.label">{{point.label}} : {{point.value}} / {{point.max}}</span>
</li>
{{/each}}
</ol>