mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 21:57:22 +01:00
refactor: Extract play reward sound logic into function
This commit is contained in:
@@ -12,10 +12,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
$scope.score = function(task, direction) {
|
||||
switch (task.type) {
|
||||
case 'reward':
|
||||
//Covers custom rewards
|
||||
if(task.value <= User.user.stats.gp){
|
||||
$rootScope.playSound('Reward');
|
||||
}
|
||||
playRewardSound(task);
|
||||
break;
|
||||
case 'daily':
|
||||
$rootScope.playSound('Daily');
|
||||
@@ -224,11 +221,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
|
||||
$scope.buy = function(item) {
|
||||
User.user.ops.buy({params:{key:item.key}});
|
||||
//Plays sound for built in rewards (armor, potions etc)
|
||||
if(item.value <= User.user.stats.gp){
|
||||
$rootScope.playSound('Reward');
|
||||
}
|
||||
|
||||
playRewardSound(item);
|
||||
};
|
||||
|
||||
|
||||
@@ -259,4 +252,10 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function playRewardSound (task) {
|
||||
if (task.value <= User.user.stats.gp){
|
||||
$rootScope.playSound('Reward');
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
Reference in New Issue
Block a user