Create method to calculate whether or not user has attained all mystery equipment

This commit is contained in:
Blade Barringer
2015-09-13 16:26:29 -05:00
parent b6f02d388f
commit 5553d74334
3 changed files with 21 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ describe('Inventory Controller', function() {
user = specHelper.newUser({
balance: 4,
items: {
gear: { owned: {} },
eggs: { Cactus: 1 },
hatchingPotions: { Base: 1 },
food: { Meat: 1 },
@@ -155,4 +156,16 @@ describe('Inventory Controller', function() {
expect(possibleValues).to.contain(cardsModalScope.cardMessage);
});
});
describe('#hasAllTimeTravelerItems', function() {
it('returns false if there are items left in the time traveler store', function() {
expect(scope.hasAllTimeTravelerItems()).to.eql(false);
});
it('returns true if there are no items left to purchase', inject(function(Content) {
sandbox.stub(Content, 'timeTravelerStore').returns({});
expect(scope.hasAllTimeTravelerItems()).to.eql(true);
}));
});
});

View File

@@ -228,6 +228,13 @@ habitrpg.controller("InventoryCtrl",
});
};
$scope.hasAllTimeTravelerItems = function(items) {
var itemsLeftInTimeTravlerStore = Content.timeTravelerStore(user.items.gear.owned);
var keys = Object.keys(itemsLeftInTimeTravlerStore);
return keys.length === 0;
};
function _updateDropAnimalCount(items) {
$scope.petCount = Shared.count.beastMasterProgress(items.pets);
$scope.mountCount = Shared.count.mountMasterProgress(items.mounts);

View File

@@ -20,7 +20,7 @@
.row: .col-md-12
.row: .col-md-6
.alert.alert-info(ng-if='_.isEmpty(Content.timeTravelerStore(user.items.gear.owned))')=env.t('timeTravelersAlreadyOwned')
.alert.alert-info(ng-if='hasAllTimeTravelerItems()')=env.t('timeTravelersAlreadyOwned')
li.customize-menu.inventory-gear
menu.pets-menu(label='{{::set.text}}', ng-repeat='set in Content.timeTravelerStore(user.items.gear.owned)')