mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
feat(hourglass): Individual filter functions
This commit is contained in:
@@ -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() {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user