Some progression work, and fixed start rank level to 1
This commit is contained in:
@@ -39,33 +39,45 @@ export class CharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
getData() {
|
||||
const sheetData = super.getData();
|
||||
|
||||
// Sort Items by rank 0->6 for advancements tab
|
||||
// Sort Items by rank 1->6 for advancements tab
|
||||
sheetData.items.sort((a, b) => {
|
||||
return (a.data.bought_at_rank || 0) - (b.data.bought_at_rank || 0);
|
||||
return (a.data.bought_at_rank || 1) - (b.data.bought_at_rank || 1);
|
||||
});
|
||||
|
||||
// Min rank = 1
|
||||
this.actor.data.data.identity.school_rank = Math.max(1, this.actor.data.data.identity.school_rank);
|
||||
|
||||
// Xp spent only in current rank
|
||||
sheetData.data.xp_spent_rank = this.getXpSpentInThisRank();
|
||||
const totalXp = this._getXpSpent();
|
||||
sheetData.data.xp_spent_rank = totalXp.rank;
|
||||
sheetData.data.xp_spent = totalXp.total;
|
||||
sheetData.data.xp_saved = sheetData.data.xp_total - sheetData.data.xp_spent;
|
||||
sheetData.data.xp_goal = CONFIG.l5r5e.xpPerRank[this.actor.data.data.identity.school_rank - 1] || null;
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current total xp spent for this rank
|
||||
* Return the total xp spent and the current total xp spent for this rank
|
||||
*/
|
||||
getXpSpentInThisRank() {
|
||||
const currentRank = this.actor.data.data.identity.school_rank || 0;
|
||||
return this.actor.items.reduce((tot, item) => {
|
||||
if (currentRank + 1 === item.data.data.rank) {
|
||||
let xp = item.data.data.xp_used || 0;
|
||||
_getXpSpent() {
|
||||
const total = {
|
||||
total: 0,
|
||||
rank: 0,
|
||||
};
|
||||
const currentRank = this.actor.data.data.identity.school_rank;
|
||||
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);
|
||||
}
|
||||
return tot + xp;
|
||||
total.rank = total.rank + xp;
|
||||
}
|
||||
return tot;
|
||||
}, 0);
|
||||
});
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user