feat(hourglass): Individual filter functions

This commit is contained in:
Sabe Jones
2015-09-16 16:35:04 -04:00
parent 2bde07fa1c
commit 98cd8364c6
2 changed files with 18 additions and 5 deletions

View File

@@ -249,7 +249,7 @@ describe('Inventory Controller', function() {
it('returns true for Mystery Sets if there are no sets left to purchase', inject(function(Content) { it('returns true for Mystery Sets if there are no sets left to purchase', inject(function(Content) {
sandbox.stub(Content, 'timeTravelerStore').returns({}); sandbox.stub(Content, 'timeTravelerStore').returns({});
expect(scope.hasAllTimeTravelerItems('mystery')).to.eql(true); expect(scope.hasAllTimeTravelerItemsOfType('mystery')).to.eql(true);
})); }));
it('returns false for pets if user does not own all pets in the Time Travel Stable', function() { it('returns false for pets if user does not own all pets in the Time Travel Stable', function() {

View File

@@ -250,11 +250,24 @@ habitrpg.controller("InventoryCtrl",
}); });
}; };
$scope.hasAllTimeTravelerItems = function(items) { $scope.hasAllTimeTravelerItems = function() {
var itemsLeftInTimeTravlerStore = Content.timeTravelerStore(user.items.gear.owned); return (hasAllTimeTravelerItemsOfType('mystery') && hasAllTimeTravelerItemsOfType('pets') && hasAllTimeTravelerItemsOfType('mounts'));
var keys = Object.keys(itemsLeftInTimeTravlerStore); };
$scope.hasAllTimeTravelerItemsOfType = function(type) {
if (type === 'mystery') {
var itemsLeftInTimeTravelerStore = Content.timeTravelerStore(user.items.gear.owned);
var keys = Object.keys(itemsLeftInTimeTravelerStore);
return keys.length === 0; return keys.length === 0;
}
if (type === 'pets' || type === 'mounts') {
for (var key in Content.timeTravelStable[type]) {
if (!user.items[type][key]) return false;
}
return true;
}
else return Console.log('Time Traveler item type must be in ["pets","mounts","mystery"]');
}; };
function _updateDropAnimalCount(items) { function _updateDropAnimalCount(items) {