Organize stat functions alphabetically

This commit is contained in:
Blade Barringer
2015-07-19 20:19:16 -05:00
parent a139ca8ba5
commit 89bfc83b95
2 changed files with 163 additions and 163 deletions
+116 -116
View File
@@ -15,122 +15,6 @@ 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('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('goldDisplay', function() {
it('displays gold', function() {
var gold = 30;
var goldDisplay = statCalc.goldDisplay(gold);
expect(goldDisplay).to.eql(30);
});
it('Rounds gold down when given a decimal', function() {
var gold = 30.999;
var goldDisplay = statCalc.goldDisplay(gold);
expect(goldDisplay).to.eql(30);
});
});
describe('expDisplay', function() {
it('displays exp as "exp / toNextLevelExp"', function() {
user.stats.exp = 10;
user.stats.lvl = 29;
var expDisplay = statCalc.expDisplay(user);
expect(expDisplay).to.eql('10/640');
});
it('Rounds exp down when given a decimal', function() {
user.stats.exp = 10.999;
user.stats.lvl = 29;
var expDisplay = statCalc.expDisplay(user);
expect(expDisplay).to.eql('10/640');
});
});
describe('levelBonus', function() {
it('calculates bonus as half of level for even numbered level under 100', function() {
var level = 50;
var bonus = statCalc.levelBonus(level);
expect(bonus).to.eql(25);
});
it('calculates bonus as half of level, rounded down, for odd numbered level under 100', function() {
var level = 51;
var bonus = statCalc.levelBonus(level);
expect(bonus).to.eql(25);
});
it('calculates bonus as 50 for levels >= 100', function() {
var level = 150;
var bonus = statCalc.levelBonus(level);
expect(bonus).to.eql(50);
});
it('calculates bonus as 0 for level 1', function() {
var level = 1;
var bonus = statCalc.levelBonus(level);
expect(bonus).to.eql(0);
});
});
describe('equipmentStatBonus', function() {
it('tallies up stats from euqipment that is equipped', function() {
var equippedGear = {
"weapon" : "weapon_special_1",
"shield" : "shield_special_1",
"head" : "head_special_1",
"armor" : "armor_special_1"
};
var strStat = statCalc.equipmentStatBonus('str', equippedGear);
var conStat = statCalc.equipmentStatBonus('con', equippedGear);
var intStat = statCalc.equipmentStatBonus('int', equippedGear);
var perStat = statCalc.equipmentStatBonus('per', equippedGear);
expect(strStat).to.eql(24);
expect(conStat).to.eql(24);
expect(intStat).to.eql(24);
expect(perStat).to.eql(24);
});
});
describe('classBonus', function() {
it('calculates class bonus', function() {
var equippedGear = {
@@ -179,4 +63,120 @@ describe('Stats Service', function() {
expect(classBonus).to.not.exist;
});
});
describe('expDisplay', function() {
it('displays exp as "exp / toNextLevelExp"', function() {
user.stats.exp = 10;
user.stats.lvl = 29;
var expDisplay = statCalc.expDisplay(user);
expect(expDisplay).to.eql('10/640');
});
it('Rounds exp down when given a decimal', function() {
user.stats.exp = 10.999;
user.stats.lvl = 29;
var expDisplay = statCalc.expDisplay(user);
expect(expDisplay).to.eql('10/640');
});
});
describe('equipmentStatBonus', function() {
it('tallies up stats from euqipment that is equipped', function() {
var equippedGear = {
"weapon" : "weapon_special_1",
"shield" : "shield_special_1",
"head" : "head_special_1",
"armor" : "armor_special_1"
};
var strStat = statCalc.equipmentStatBonus('str', equippedGear);
var conStat = statCalc.equipmentStatBonus('con', equippedGear);
var intStat = statCalc.equipmentStatBonus('int', equippedGear);
var perStat = statCalc.equipmentStatBonus('per', equippedGear);
expect(strStat).to.eql(24);
expect(conStat).to.eql(24);
expect(intStat).to.eql(24);
expect(perStat).to.eql(24);
});
});
describe('goldDisplay', function() {
it('displays gold', function() {
var gold = 30;
var goldDisplay = statCalc.goldDisplay(gold);
expect(goldDisplay).to.eql(30);
});
it('Rounds gold down when given a decimal', function() {
var gold = 30.999;
var goldDisplay = statCalc.goldDisplay(gold);
expect(goldDisplay).to.eql(30);
});
});
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;
var bonus = statCalc.levelBonus(level);
expect(bonus).to.eql(25);
});
it('calculates bonus as half of level, rounded down, for odd numbered level under 100', function() {
var level = 51;
var bonus = statCalc.levelBonus(level);
expect(bonus).to.eql(25);
});
it('calculates bonus as 50 for levels >= 100', function() {
var level = 150;
var bonus = statCalc.levelBonus(level);
expect(bonus).to.eql(50);
});
it('calculates bonus as 0 for level 1', function() {
var level = 1;
var bonus = statCalc.levelBonus(level);
expect(bonus).to.eql(0);
});
});
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');
});
});
});