зеркало из https://github.com/mozilla/galaxy-api.git
Add a plethora of errors to the leaderboard updater
This commit is contained in:
Родитель
97f511b8ff
Коммит
4c1b1b6481
|
@ -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,
|
||||
|
|
Загрузка…
Ссылка в новой задаче