mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Add mpdisplay function
This commit is contained in:
@@ -32,6 +32,24 @@ describe('Stats Service', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('mpDisplay', function() {
|
||||
it('displays mp as "mp / totalMP"', function() {
|
||||
user._statsComputed = { maxMP: 100 };
|
||||
user.stats.mp = 30;
|
||||
var mpDisplay = statCalc.mpDisplay(user);
|
||||
|
||||
expect(mpDisplay).to.eql('30/100');
|
||||
});
|
||||
|
||||
it('Rounds mp down when given a decimal', function() {
|
||||
user._statsComputed = { maxMP: 100 };
|
||||
user.stats.mp = 30.99;
|
||||
var mpDisplay = statCalc.mpDisplay(user);
|
||||
|
||||
expect(mpDisplay).to.eql('30/100');
|
||||
});
|
||||
});
|
||||
|
||||
describe('levelBonus', function() {
|
||||
it('calculates bonus as half of level for even numbered level under 100', function() {
|
||||
var level = 50;
|
||||
|
||||
@@ -20,6 +20,14 @@
|
||||
return display;
|
||||
}
|
||||
|
||||
function mpDisplay(user) {
|
||||
var remainingMP = Math.floor(user.stats.mp);
|
||||
var totalMP = user._statsComputed.maxMP;
|
||||
var display = remainingMP + '/' + totalMP;
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
function levelBonus(level) {
|
||||
// Level bonus is derived by taking the level, subtracting one,
|
||||
// taking the smaller of it or maxLevel (100),
|
||||
@@ -68,7 +76,8 @@
|
||||
classBonus: classBonus,
|
||||
equipmentStatBonus: equipmentStatBonus,
|
||||
hpDisplay: hpDisplay,
|
||||
levelBonus: levelBonus
|
||||
levelBonus: levelBonus,
|
||||
mpDisplay: mpDisplay
|
||||
}
|
||||
}
|
||||
}());
|
||||
|
||||
Reference in New Issue
Block a user