update scores

This commit is contained in:
Astro 2010-09-20 03:23:13 +02:00
parent 0c89cebbc5
commit c583639c49
1 changed files with 11 additions and 0 deletions

11
quiz.js
View File

@ -84,6 +84,16 @@ function switchToScoreboard() {
$('#scoreboard').fadeIn(300);
}
function updateScores() {
for(var i = 0; i < playerNames.length; i++) {
if (!playerNames[i])
continue;
$('#scoreboard dl dd').eq(i).text(playerScores[i]);
$('#players .player'+i+' .score').text(playerScores[i]);
}
}
// Game screen is the one with the question in question
function switchToGame() {
var i, q = questions[currentQuestion];
@ -139,6 +149,7 @@ function switchToGame() {
var isRight = choice !== null && q.answers[choice].right === true;
if (isRight) {
playerScores[activePlayer] += q.tier;
updateScores();
} else if (choice) {
// Hilight the wrong choice
answerEl.addClass('wrong');