Add mpdisplay function

This commit is contained in:
Blade Barringer
2015-07-18 14:08:25 -05:00
parent 17ef7e2885
commit 2eb62de056
2 changed files with 28 additions and 1 deletions

View File

@@ -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() { describe('levelBonus', function() {
it('calculates bonus as half of level for even numbered level under 100', function() { it('calculates bonus as half of level for even numbered level under 100', function() {
var level = 50; var level = 50;

View File

@@ -20,6 +20,14 @@
return display; 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) { function levelBonus(level) {
// Level bonus is derived by taking the level, subtracting one, // Level bonus is derived by taking the level, subtracting one,
// taking the smaller of it or maxLevel (100), // taking the smaller of it or maxLevel (100),
@@ -68,7 +76,8 @@
classBonus: classBonus, classBonus: classBonus,
equipmentStatBonus: equipmentStatBonus, equipmentStatBonus: equipmentStatBonus,
hpDisplay: hpDisplay, hpDisplay: hpDisplay,
levelBonus: levelBonus levelBonus: levelBonus,
mpDisplay: mpDisplay
} }
} }
}()); }());