forked from public/foundryvtt-reve-de-dragon
More automatism
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
@ -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 ) {
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user