Add a plethora of errors to the leaderboard updater

This commit is contained in:
Matt Basta 2013-12-18 12:50:56 -08:00
Родитель 97f511b8ff
Коммит 4c1b1b6481
1 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -131,12 +131,13 @@ user.prototype.donePlaying = function() {
clearInterval(this.get('playTimer'));
};
user.prototype.updateLeaderboard = function(board, value) {
user.prototype.updateLeaderboard = function(board, value, callback) {
// TODO: Throttle this function.
var currentlyPlaying = this.get('currentlyPlaying');
// Check that the user is playing a game.
if (!currentlyPlaying) {
callback('not_playing_a_game');
return;
}
@ -145,6 +146,7 @@ user.prototype.updateLeaderboard = function(board, value) {
value === 0 ||
value < -1 * MAX_LEADERBOARD_INCR ||
value > MAX_LEADERBOARD_INCR) {
callback('invalid_increment');
return;
}
@ -154,7 +156,10 @@ user.prototype.updateLeaderboard = function(board, value) {
currentlyPlaying,
board,
function(exists) {
if (!exists) return;
if (!exists) {
callback('invalid_board');
return;
}
leaderboard.updateLeaderboard(
this.dataChannel,