mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-05-17 19:28:42 +00:00
Add display experience function
This commit is contained in:
parent
f1453d30c4
commit
53fb0ec8b0
2 changed files with 27 additions and 0 deletions
|
|
@ -66,6 +66,24 @@ describe('Stats Service', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('expDisplay', function() {
|
||||
it('displays exp as "exp / toNextLevelExp"', function() {
|
||||
user.stats.exp = 10;
|
||||
user.stats.lvl = 29;
|
||||
var expDisplay = statCalc.expDisplay(user);
|
||||
|
||||
expect(expDisplay).to.eql('10/640');
|
||||
});
|
||||
|
||||
it('Rounds exp down when given a decimal', function() {
|
||||
user.stats.exp = 10.999;
|
||||
user.stats.lvl = 29;
|
||||
var expDisplay = statCalc.expDisplay(user);
|
||||
|
||||
expect(expDisplay).to.eql('10/640');
|
||||
});
|
||||
});
|
||||
|
||||
describe('levelBonus', function() {
|
||||
it('calculates bonus as half of level for even numbered level under 100', function() {
|
||||
var level = 50;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,14 @@
|
|||
return display;
|
||||
}
|
||||
|
||||
function expDisplay(user) {
|
||||
var exp = Math.floor(user.stats.exp);
|
||||
var toNextLevel = Shared.tnl(user.stats.lvl);
|
||||
var display = exp + '/' + toNextLevel;
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
function levelBonus(level) {
|
||||
// Level bonus is derived by taking the level, subtracting one,
|
||||
// taking the smaller of it or maxLevel (100),
|
||||
|
|
@ -80,6 +88,7 @@
|
|||
return {
|
||||
classBonus: classBonus,
|
||||
equipmentStatBonus: equipmentStatBonus,
|
||||
expDisplay: expDisplay,
|
||||
goldDisplay: goldDisplay,
|
||||
hpDisplay: hpDisplay,
|
||||
levelBonus: levelBonus,
|
||||
|
|
|
|||
Loading…
Reference in a new issue