mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-22 03:34:14 +00:00
Add count function for remaining items in gear set
This commit is contained in:
parent
73e1764413
commit
20660f50c0
2 changed files with 43 additions and 1 deletions
|
|
@ -26,7 +26,21 @@ function mountMasterProgress(mounts) {
|
|||
return count;
|
||||
}
|
||||
|
||||
function remainingGearInSet(userGear, set) {
|
||||
var gear = _.filter(content.gear.flat, function(item) {
|
||||
var setMatches = item.klass === set;
|
||||
var hasItem = _.has(userGear, item.key);
|
||||
|
||||
return setMatches && !hasItem;
|
||||
});
|
||||
|
||||
var count = _.size(gear);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
beastMasterProgress: beastMasterProgress,
|
||||
mountMasterProgress: mountMasterProgress
|
||||
mountMasterProgress: mountMasterProgress,
|
||||
remainingGearInSet: remainingGearInSet
|
||||
};
|
||||
|
|
|
|||
|
|
@ -84,4 +84,32 @@ describe('count', function() {
|
|||
expect(mountMasterTotal).to.eql(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('remainingGearInSet', function() {
|
||||
it('counts remaining gear based on set', function() {
|
||||
var gear = {
|
||||
'weapon_wizard_0':true,
|
||||
'weapon_wizard_1':true,
|
||||
'weapon_warrior_0':true,
|
||||
'weapon_warrior_1':true,
|
||||
'weapon_armor_0':true,
|
||||
'weapon_armor_1':true
|
||||
};
|
||||
|
||||
var armoireCount = count.remainingGearInSet(gear, 'warrior');
|
||||
expect(armoireCount).to.eql(20);
|
||||
});
|
||||
|
||||
it('includes previously owned items in count', function() {
|
||||
var gear = {
|
||||
'weapon_warrior_0':false,
|
||||
'weapon_warrior_1':false,
|
||||
'weapon_armor_0':true,
|
||||
'weapon_armor_1':true
|
||||
};
|
||||
|
||||
var armoireCount = count.remainingGearInSet(gear, 'warrior');
|
||||
expect(armoireCount).to.eql(20);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue