diff --git a/test/spec/services/statServicesSpec.js b/test/spec/services/statServicesSpec.js index a8fbe5f6f8..568b44ae91 100644 --- a/test/spec/services/statServicesSpec.js +++ b/test/spec/services/statServicesSpec.js @@ -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; diff --git a/website/public/js/services/statServices.js b/website/public/js/services/statServices.js index 6fbe6d4f73..2eea238da1 100644 --- a/website/public/js/services/statServices.js +++ b/website/public/js/services/statServices.js @@ -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 } } }());