From 47bd6dcb79778d90d6f3ddeb003c3d8e45433333 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Wed, 22 Jan 2014 00:27:55 -0800 Subject: [PATCH] fix(spells): more $rootScope spell-casting bug fixes --- public/js/controllers/rootCtrl.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/public/js/controllers/rootCtrl.js b/public/js/controllers/rootCtrl.js index b500855072..220654bfa7 100644 --- a/public/js/controllers/rootCtrl.js +++ b/public/js/controllers/rootCtrl.js @@ -168,9 +168,13 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ if ($scope.spell.target != type) return Notification.text("Invalid target"); $scope.spell.cast(User.user, target); User.save(); + var spell = $scope.spell; - var targetId = type == 'party' ? '' : type == 'task' ? target.id : target._id; - $http.post('/api/v2/user/class/cast/' + spell.key, {params:{targetType:type, targetId:targetId}}) + var targetId = (type == 'party' || type == 'self') ? '' : type == 'task' ? target.id : target._id; + $scope.spell = null; + $rootScope.applyingAction = false; + + $http.post('/api/v2/user/class/cast/'+spell.key+'?targetType='+type+'&targetId='+targetId) .success(function(){ var msg = "You cast " + spell.text; switch (type) { @@ -180,8 +184,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ } Notification.text(msg); }); - $scope.spell = null; - $rootScope.applyingAction = false; + } $rootScope.castCancel = function(){