mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-16 03:02:24 +00:00
Add hpDisplay function
This commit is contained in:
parent
f9304bd28f
commit
17ef7e2885
2 changed files with 26 additions and 0 deletions
|
|
@ -15,6 +15,23 @@ describe('Stats Service', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('hpDisplay', function() {
|
||||
it('displays hp as "hp / totalHP"', function() {
|
||||
var hp = 34;
|
||||
var hpDisplay = statCalc.hpDisplay(hp);
|
||||
|
||||
expect(hpDisplay).to.eql('34/50');
|
||||
});
|
||||
|
||||
it('Rounds hp up when given a decimal', function() {
|
||||
|
||||
var hp = 34.4;
|
||||
var hpDisplay = statCalc.hpDisplay(hp);
|
||||
|
||||
expect(hpDisplay).to.eql('35/50');
|
||||
});
|
||||
});
|
||||
|
||||
describe('levelBonus', function() {
|
||||
it('calculates bonus as half of level for even numbered level under 100', function() {
|
||||
var level = 50;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,14 @@
|
|||
|
||||
function statsFactory(Content, Shared) {
|
||||
|
||||
function hpDisplay(hp) {
|
||||
var remainingHP = Math.ceil(hp);
|
||||
var totalHP = Shared.maxHealth;
|
||||
var display = remainingHP + '/' + totalHP;
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
function levelBonus(level) {
|
||||
// Level bonus is derived by taking the level, subtracting one,
|
||||
// taking the smaller of it or maxLevel (100),
|
||||
|
|
@ -59,6 +67,7 @@
|
|||
return {
|
||||
classBonus: classBonus,
|
||||
equipmentStatBonus: equipmentStatBonus,
|
||||
hpDisplay: hpDisplay,
|
||||
levelBonus: levelBonus
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue