Fatigue management, ongoing work
This commit is contained in:
parent
a6b46cb4ad
commit
63e4e6f91a
@ -54,7 +54,7 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
list.push(item);
|
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.materiel = this._checkNull(data.itemsByType['objet']);
|
data.data.materiel = this._checkNull(data.itemsByType['objet']);
|
||||||
data.data.armes = this._checkNull(data.itemsByType['arme']);
|
data.data.armes = this._checkNull(data.itemsByType['arme']);
|
||||||
data.data.armures = this._checkNull(data.itemsByType['armure']);
|
data.data.armures = this._checkNull(data.itemsByType['armure']);
|
||||||
@ -62,6 +62,8 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
data.data.potions = this._checkNull(data.itemsByType['potions']);
|
data.data.potions = this._checkNull(data.itemsByType['potions']);
|
||||||
data.data.competenceByCategory = data.competenceByCategory;
|
data.data.competenceByCategory = data.competenceByCategory;
|
||||||
|
|
||||||
|
console.log("HTML", data.data.fatigueHTML);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,6 +95,7 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
let compName = event.currentTarget.text;
|
let compName = event.currentTarget.text;
|
||||||
this.actor.rollCompetence( compName);
|
this.actor.rollCompetence( compName);
|
||||||
});
|
});
|
||||||
|
|
||||||
// On carac change
|
// On carac change
|
||||||
$(".competence-value").change((event) => {
|
$(".competence-value").change((event) => {
|
||||||
let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", "");
|
let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", "");
|
||||||
|
@ -39,9 +39,37 @@ const levelDown = [ { "level": -11, "score": 1, "part": 0, "epart": 2, "etotal":
|
|||||||
{ "level": -13, "score": 1, "part": 0, "epart": 2, "etotal": 50 },
|
{ "level": -13, "score": 1, "part": 0, "epart": 2, "etotal": 50 },
|
||||||
{ "level": -14, "score": 1, "part": 0, "epart": 2, "etotal": 30 },
|
{ "level": -14, "score": 1, "part": 0, "epart": 2, "etotal": 30 },
|
||||||
{ "level": -15, "score": 1, "part": 0, "epart": 2, "etotal": 10 },
|
{ "level": -15, "score": 1, "part": 0, "epart": 2, "etotal": 10 },
|
||||||
{ "level": -16, "score": 1, "part": 0, "epart": 2, "etotal": 2 },
|
{ "level": -16, "score": 1, "part": 0, "epart": 2, "etotal": 2 }
|
||||||
];
|
];
|
||||||
|
const fatigueMatrix = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // Dummy filler for the array.
|
||||||
|
[2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3 ],
|
||||||
|
[2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3 ],
|
||||||
|
[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 ],
|
||||||
|
[3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 4 ],
|
||||||
|
[3, 3, 4, 3, 3, 4, 3, 3, 4, 3, 3, 4 ],
|
||||||
|
[3, 3, 4, 3, 4, 4, 3, 3, 4, 3, 4, 4 ],
|
||||||
|
[3, 4, 4, 3, 4, 4, 3, 4, 4, 3, 4, 4 ],
|
||||||
|
[3, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4 ],
|
||||||
|
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ],
|
||||||
|
[4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 5 ],
|
||||||
|
[4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 4, 5 ],
|
||||||
|
[4, 4, 5, 4, 5, 5, 4, 4, 5, 4, 5, 5 ],
|
||||||
|
[4, 5, 5, 4, 5, 5, 4, 5, 5, 4, 5, 5 ],
|
||||||
|
[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 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>\
|
||||||
|
<th><td/><td/><td/><td/><td/></tr>\
|
||||||
|
<th><td/><td/><td/><td/><td/></tr>\
|
||||||
|
<th><td/><td/><td/><td/><td/></tr>\
|
||||||
|
<th><td/><td/><td/><td/><td/></tr>\
|
||||||
|
<th><td/><td/><td/><td/><td/></tr>\
|
||||||
|
<th><td/><td/><td/><td/><td/></tr>\
|
||||||
|
</table>"
|
||||||
|
|
||||||
export class RdDUtility {
|
export class RdDUtility {
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -213,6 +241,42 @@ export class RdDUtility {
|
|||||||
data.attributs.sust.value = 3;
|
data.attributs.sust.value = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static makeHTMLfatigueMatrix( value, max )
|
||||||
|
{
|
||||||
|
max = (max < 16) ? 16 : max;
|
||||||
|
max = (max > 30) ? 30 : max;
|
||||||
|
value = (value > max) ? max : value;
|
||||||
|
let fatigueTab = fatigueMatrix[max];
|
||||||
|
let idx = 0; // Current fatigue slot
|
||||||
|
let remFatigue = value;
|
||||||
|
while ( remFatigue >= fatigueTab[idx] ) { // computes the fatigue segment consumed
|
||||||
|
remFatigue = remFatigue - fatigueTab[idx];
|
||||||
|
idx = idx + 1;
|
||||||
|
}
|
||||||
|
// 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;
|
||||||
|
for (var line=0; line < fatigueLineSize.length; line++) {
|
||||||
|
let row = $("<tr/>");
|
||||||
|
let segmentsPerLine = fatigueLineSize[line];
|
||||||
|
while (segmentIdx < segmentsPerLine) {
|
||||||
|
let freeSize = fatigueTab[segmentIdx];
|
||||||
|
for (let col=0; col <5; col++) {
|
||||||
|
if ( col < freeSize )
|
||||||
|
row.append("<td class='fatigue-free'/>");
|
||||||
|
else
|
||||||
|
row.append("<td class='fatigue-none'/>");
|
||||||
|
}
|
||||||
|
row.append("<td class='fatigue-separator'/>");
|
||||||
|
segmentIdx = segmentIdx + 1;
|
||||||
|
}
|
||||||
|
table.append(row);
|
||||||
|
}
|
||||||
|
console.log("fatigue", table);
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
static findCompetence(compList, compName)
|
static findCompetence(compList, compName)
|
||||||
|
@ -305,9 +305,30 @@
|
|||||||
background-color: lightblue;
|
background-color: lightblue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ======================================== */
|
||||||
|
/* Global UI elements */
|
||||||
select {
|
select {
|
||||||
font-family: "GoudyAcc", sans-serif;
|
font-family: "GoudyAcc", sans-serif;
|
||||||
}
|
}
|
||||||
button {
|
button {
|
||||||
font-family: "GoudyAcc", sans-serif;
|
font-family: "GoudyAcc", sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ======================================== */
|
||||||
|
/* Fatigue CSS */
|
||||||
|
.table-fatigue {
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
.table-fatigue td {
|
||||||
|
table-layout: fixed;
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
}
|
||||||
|
.table-fatigue .fatigue-none {
|
||||||
|
background-color: black;
|
||||||
|
border: 1px solid #999;
|
||||||
|
}
|
||||||
|
.table-fatigue .fatigue-free {
|
||||||
|
border: 1px solid #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -147,21 +147,21 @@
|
|||||||
"type": "number",
|
"type": "number",
|
||||||
"max": 10,
|
"max": 10,
|
||||||
"value": 10,
|
"value": 10,
|
||||||
"label": "Points de Vie",
|
"label": "Vie",
|
||||||
"derivee": true
|
"derivee": true
|
||||||
},
|
},
|
||||||
"endurance": {
|
"endurance": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"max": 10,
|
"max": 10,
|
||||||
"value": 10,
|
"value": 10,
|
||||||
"label": "Points d'Endurance",
|
"label": "Endurance",
|
||||||
"derivee": true
|
"derivee": true
|
||||||
},
|
},
|
||||||
"fatigue": {
|
"fatigue": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"max": 40,
|
"max": 0,
|
||||||
"value": 10,
|
"value": 0,
|
||||||
"label": "Points de Fatigue",
|
"label": "Fatigue",
|
||||||
"derivee": true
|
"derivee": true
|
||||||
},
|
},
|
||||||
"legeres": {
|
"legeres": {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" height="100" width="100"/>
|
<img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" height="100" width="100"/>
|
||||||
<div class="header-fields">
|
<div class="header-fields">
|
||||||
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name"/></h1>
|
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name"/></h1>
|
||||||
<div class="grid grid-2col">
|
<div class="grid grid-3col">
|
||||||
<div class="flex-group-center">
|
<div class="flex-group-center">
|
||||||
Vie
|
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}}
|
<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}}
|
||||||
@ -14,6 +14,10 @@
|
|||||||
Endurance
|
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}}
|
<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}}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex-group-center">
|
||||||
|
Fatigue
|
||||||
|
<span>{{{data.fatigueHTML}}}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
Loading…
Reference in New Issue
Block a user