Skip to content

Commit

Permalink
automatically check solved when problem gets solved
Browse files Browse the repository at this point in the history
  • Loading branch information
buzzdecafe committed Sep 25, 2013
1 parent 54d00f2 commit 5af4ff6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ angular.module('kinghunt.controllers', []).
var game = gameSvc.getGame();
var board;

$scope.setStatus = function(status) {
$scope.status = status;
// side effects:
if (status.progress === "SOLVED") {
bookSvc.markSolved($scope.currentId);
} else if (status.progress === "FAILED") {
bookSvc.markUnsolved($scope.currentId);
}
};

$scope.currentId = $routeParams.id;
$scope.book = bookSvc.book;
$scope.problem = bookSvc.getFenById($scope.currentId);
Expand All @@ -26,7 +36,7 @@ angular.module('kinghunt.controllers', []).
game.load($scope.problem.fen);

$scope.board = new ChessBoard('board', gameSvc.getBoardConfig($scope));
$scope.status = gameSvc.getStatus($scope.goalMoves);
$scope.setStatus(gameSvc.getStatus($scope.goalMoves));

// handle boardNav events
$scope.$on('boardNav/prevProblem', function() {
Expand Down
2 changes: 1 addition & 1 deletion app/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ angular.module('kinghunt.services', []).
return 'snapback';
}

scope.status = gameObj.getStatus(scope.goalMoves);
scope.setStatus(gameObj.getStatus(scope.goalMoves));
scope.$apply();
// if (scope.mode === 'auto') {
// opponentMove();
Expand Down

0 comments on commit 5af4ff6

Please sign in to comment.