refactor: Extract play reward sound logic into function

This commit is contained in:
Blade Barringer
2016-03-23 17:37:37 -05:00
parent 7b708f51ba
commit 01a7132b0b

View File

@@ -12,10 +12,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
$scope.score = function(task, direction) { $scope.score = function(task, direction) {
switch (task.type) { switch (task.type) {
case 'reward': case 'reward':
//Covers custom rewards playRewardSound(task);
if(task.value <= User.user.stats.gp){
$rootScope.playSound('Reward');
}
break; break;
case 'daily': case 'daily':
$rootScope.playSound('Daily'); $rootScope.playSound('Daily');
@@ -224,11 +221,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
$scope.buy = function(item) { $scope.buy = function(item) {
User.user.ops.buy({params:{key:item.key}}); User.user.ops.buy({params:{key:item.key}});
//Plays sound for built in rewards (armor, potions etc) playRewardSound(item);
if(item.value <= User.user.stats.gp){
$rootScope.playSound('Reward');
}
}; };
@@ -259,4 +252,10 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
return true; return true;
} }
} }
function playRewardSound (task) {
if (task.value <= User.user.stats.gp){
$rootScope.playSound('Reward');
}
}
}]); }]);