fix #2030, immediately "fulfill" spell cast, don't wait for server response

This commit is contained in:
Tyler Renelle
2013-12-17 19:33:36 -07:00
parent 41cc6ff3bc
commit 04df61fb53

View File

@@ -165,6 +165,8 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
$scope.castEnd = function(target, type, $event){ $scope.castEnd = function(target, type, $event){
if ($scope.spell.target != type) return Notification.text("Invalid target"); if ($scope.spell.target != type) return Notification.text("Invalid target");
$scope.spell.cast(User.user, target); $scope.spell.cast(User.user, target);
$rootScope.applyingAction = false;
$scope.spell = null;
$http.post('/api/v2/user/class/cast/' + $scope.spell.name, {target:target, type:type}).success(function(){ $http.post('/api/v2/user/class/cast/' + $scope.spell.name, {target:target, type:type}).success(function(){
var msg = "You cast " + $scope.spell.text; var msg = "You cast " + $scope.spell.text;
switch (type) { switch (type) {
@@ -173,9 +175,6 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
case 'party': msg += ' on the Party';break; case 'party': msg += ' on the Party';break;
} }
Notification.text(msg); Notification.text(msg);
$rootScope.applyingAction = false;
$scope.spell = null;
//User.sync(); // FIXME push a lot of the server code to also in client, so we can run updates in browser without requiring sync
}) })
$event && $event.stopPropagation(); $event && $event.stopPropagation();
} }