Refactor how cards are recieved

This commit is contained in:
Blade Barringer
2015-08-12 08:36:57 -05:00
parent 60f92a8997
commit 203a26b6df
7 changed files with 121 additions and 61 deletions

View File

@@ -216,7 +216,17 @@ habitrpg.controller("InventoryCtrl",
$scope.selectedFood = null;
$scope.selectedPotion = null;
$scope.selectedEgg = null;
}
};
$scope.openCardsModal = function(type, numberOfVariations) {
var cardsModalScope = $rootScope.$new();
cardsModalScope.cardType = type;
cardsModalScope.cardMessage = _generateCard(type, numberOfVariations);
$rootScope.openModal('cards', {
scope: cardsModalScope
});
};
function _updateDropAnimalCount(items) {
$scope.petCount = Shared.count.beastMasterProgress(items.pets);
@@ -224,5 +234,11 @@ habitrpg.controller("InventoryCtrl",
$scope.beastMasterProgress = Stats.beastMasterProgress(items.pets);
$scope.mountMasterProgress = Stats.mountMasterProgress(items.mounts);
}
function _generateCard(kind, numberOfVariations) {
var random = Math.random() * numberOfVariations;
var selection = Math.floor(random);
return env.t(kind + selection);
}
}
]);