Advancements better table display
This commit is contained in:
@@ -249,12 +249,13 @@
|
|||||||
"advancements": {
|
"advancements": {
|
||||||
"title": "Advancements",
|
"title": "Advancements",
|
||||||
"title_new": "New advancement",
|
"title_new": "New advancement",
|
||||||
|
"school_rank": "School rank",
|
||||||
"total": "Total",
|
"total": "Total",
|
||||||
"cost": "Cost",
|
"cost": "Cost",
|
||||||
"spent": "Used",
|
"spent": "Used",
|
||||||
"saved": "Saved",
|
"saved": "Saved",
|
||||||
"rank": "Rank Total Xp",
|
"total_xp_rank": "Xp spent",
|
||||||
"curriculum": "in curriculum",
|
"curriculum": "In curriculum",
|
||||||
"curriculum_validate": "Complete this rank"
|
"curriculum_validate": "Complete this rank"
|
||||||
},
|
},
|
||||||
"npc": {
|
"npc": {
|
||||||
|
|||||||
@@ -249,12 +249,13 @@
|
|||||||
"advancements": {
|
"advancements": {
|
||||||
"title": "Advancements",
|
"title": "Advancements",
|
||||||
"title_new": "New advancement",
|
"title_new": "New advancement",
|
||||||
|
"school_rank": "School rank",
|
||||||
"total": "Total",
|
"total": "Total",
|
||||||
"cost": "Cost",
|
"cost": "Cost",
|
||||||
"spent": "Usada",
|
"spent": "Usada",
|
||||||
"saved": "Restante",
|
"saved": "Restante",
|
||||||
"rank": "Rank Total Xp",
|
"total_xp_rank": "Xp spent",
|
||||||
"curriculum": "in curriculum",
|
"curriculum": "In curriculum",
|
||||||
"curriculum_validate": "Complete this rank"
|
"curriculum_validate": "Complete this rank"
|
||||||
},
|
},
|
||||||
"npc": {
|
"npc": {
|
||||||
|
|||||||
@@ -249,11 +249,12 @@
|
|||||||
"advancements": {
|
"advancements": {
|
||||||
"title": "Progressions",
|
"title": "Progressions",
|
||||||
"title_new": "Nouvelle progression",
|
"title_new": "Nouvelle progression",
|
||||||
|
"school_rank": "Rang d'école",
|
||||||
"total": "Totale",
|
"total": "Totale",
|
||||||
"cost": "Coût",
|
"cost": "Coût",
|
||||||
"spent": "Dépensée",
|
"spent": "Dépensée",
|
||||||
"saved": "Restante",
|
"saved": "Restante",
|
||||||
"total_xp_rank": "Xp Total du rang",
|
"total_xp_rank": "Xp dépensée",
|
||||||
"curriculum": "Inclus dans le cursus",
|
"curriculum": "Inclus dans le cursus",
|
||||||
"curriculum_validate": "Valider la progression"
|
"curriculum_validate": "Valider la progression"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -39,20 +39,17 @@ export class CharacterSheetL5r5e extends BaseSheetL5r5e {
|
|||||||
getData() {
|
getData() {
|
||||||
const sheetData = super.getData();
|
const sheetData = super.getData();
|
||||||
|
|
||||||
// Sort Items by rank 1->6 for advancements tab
|
|
||||||
sheetData.items.sort((a, b) => {
|
|
||||||
return (a.data.bought_at_rank || 1) - (b.data.bought_at_rank || 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Min rank = 1
|
// Min rank = 1
|
||||||
this.actor.data.data.identity.school_rank = Math.max(1, this.actor.data.data.identity.school_rank);
|
this.actor.data.data.identity.school_rank = Math.max(1, this.actor.data.data.identity.school_rank);
|
||||||
|
|
||||||
// Xp spent only in current rank
|
// Sort Items by name
|
||||||
const totalXp = this._getXpSpent();
|
sheetData.items.sort((a, b) => {
|
||||||
sheetData.data.xp_spent_rank = totalXp.rank;
|
return a.name.localeCompare(b.name);
|
||||||
sheetData.data.xp_spent = totalXp.total;
|
});
|
||||||
|
|
||||||
|
// split advancements list by rank, and calculate xp spent
|
||||||
|
this._prepareAdvancement(sheetData);
|
||||||
sheetData.data.xp_saved = sheetData.data.xp_total - sheetData.data.xp_spent;
|
sheetData.data.xp_saved = sheetData.data.xp_total - sheetData.data.xp_spent;
|
||||||
sheetData.data.xp_goal = CONFIG.l5r5e.xp.costPerRank[this.actor.data.data.identity.school_rank - 1] || null;
|
|
||||||
|
|
||||||
return sheetData;
|
return sheetData;
|
||||||
}
|
}
|
||||||
@@ -60,24 +57,34 @@ export class CharacterSheetL5r5e extends BaseSheetL5r5e {
|
|||||||
/**
|
/**
|
||||||
* Return the total xp spent and the current total xp spent for this rank
|
* Return the total xp spent and the current total xp spent for this rank
|
||||||
*/
|
*/
|
||||||
_getXpSpent() {
|
_prepareAdvancement(sheetData) {
|
||||||
const total = {
|
const adv = [];
|
||||||
total: 0,
|
sheetData.data.xp_spent = 0;
|
||||||
rank: 0,
|
sheetData.items.forEach((item) => {
|
||||||
};
|
if (!["peculiarity", "technique", "advancement"].includes(item.type)) {
|
||||||
const currentRank = this.actor.data.data.identity.school_rank;
|
return;
|
||||||
this.actor.items.map((item) => {
|
|
||||||
let xp = item.data.data.xp_used || 0;
|
|
||||||
total.total = total.total + xp;
|
|
||||||
|
|
||||||
if (currentRank === item.data.data.rank) {
|
|
||||||
// if not in curriculum, xp spent /2 for this item
|
|
||||||
if (!item.data.data.in_curriculum && xp > 0) {
|
|
||||||
xp = Math.floor(xp / 2);
|
|
||||||
}
|
|
||||||
total.rank = total.rank + xp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let xp = item.data.xp_used || 0;
|
||||||
|
sheetData.data.xp_spent = sheetData.data.xp_spent + xp;
|
||||||
|
|
||||||
|
// if not in curriculum, xp spent /2 for this item
|
||||||
|
if (!item.data.in_curriculum && xp > 0) {
|
||||||
|
xp = Math.floor(xp / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
const rank = Math.max(0, item.data.bought_at_rank - 1);
|
||||||
|
if (!adv[rank]) {
|
||||||
|
adv[rank] = {
|
||||||
|
rank: rank + 1,
|
||||||
|
spent: 0,
|
||||||
|
goal: CONFIG.l5r5e.xp.costPerRank[rank] || null,
|
||||||
|
list: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
adv[rank].list.push(item);
|
||||||
|
adv[rank].spent = adv[rank].spent + xp;
|
||||||
});
|
});
|
||||||
return total;
|
sheetData.advancementsListByRank = adv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,27 +27,28 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="flex">
|
<tbody class="flex">
|
||||||
{{#each actor.items as |advancement advancementId|}}
|
{{#each advancementsListByRank as |rankObject|}}
|
||||||
{{#ifCond '["peculiarity", "technique","advancement"]' 'includes' advancement.type}}
|
<tr class="flexrow row">
|
||||||
{{> 'systems/l5r5e/templates/actors/character/advancement.html' advancement=advancement editable=../editable }}
|
<th>{{localize 'l5r5e.advancements.school_rank'}} {{rankObject.rank}}</th>
|
||||||
{{/ifCond}}
|
</tr>
|
||||||
{{/each}}
|
{{#each rankObject.list as |advancement advancementId|}}
|
||||||
<tfooter class="flex">
|
{{> 'systems/l5r5e/templates/actors/character/advancement.html' advancement=advancement editable=../../editable }}
|
||||||
|
{{/each}}
|
||||||
<tr class="flexrow row">
|
<tr class="flexrow row">
|
||||||
<th class="">
|
<th class="">
|
||||||
{{#ifCond data.xp_spent_rank '>=' data.xp_goal}}
|
{{#ifCond (ifCond ../data.identity.school_rank '==' rankObject.rank) '&&' (ifCond rankObject.spent '>=' rankObject.goal)}}
|
||||||
<button type="button" name="validate-curriculum">
|
<button type="button" name="validate-curriculum">
|
||||||
<i class='fas fa-check-square'></i> {{ localize 'l5r5e.advancements.curriculum_validate' }}
|
<i class='fas fa-check-square'></i> {{ localize 'l5r5e.advancements.curriculum_validate' }}
|
||||||
</button>
|
</button>
|
||||||
{{/ifCond}}
|
{{/ifCond}}
|
||||||
</th>
|
</th>
|
||||||
<th class="">
|
<th class="">
|
||||||
{{ localize 'l5r5e.advancements.total_xp_rank' }} ({{data.identity.school_rank}}) :
|
{{ localize 'l5r5e.advancements.total_xp_rank' }} :
|
||||||
{{ data.xp_spent_rank }}
|
{{ rankObject.spent }}
|
||||||
{{#if data.xp_goal}}/{{data.xp_goal}}{{/if}}
|
{{#if rankObject.goal}}/{{rankObject.goal}}{{/if}}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tfooter>
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
Reference in New Issue
Block a user