mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Add hpDisplay function
This commit is contained in:
@@ -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() {
|
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;
|
||||||
|
|||||||
@@ -12,6 +12,14 @@
|
|||||||
|
|
||||||
function statsFactory(Content, Shared) {
|
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) {
|
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),
|
||||||
@@ -59,6 +67,7 @@
|
|||||||
return {
|
return {
|
||||||
classBonus: classBonus,
|
classBonus: classBonus,
|
||||||
equipmentStatBonus: equipmentStatBonus,
|
equipmentStatBonus: equipmentStatBonus,
|
||||||
|
hpDisplay: hpDisplay,
|
||||||
levelBonus: levelBonus
|
levelBonus: levelBonus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user