fixed bug in 5050 joker

enless loop, if more than 2 answers were  correct
This commit is contained in:
john stone 2011-12-16 20:49:42 +01:00
parent 90272948c5
commit da13020ef7
1 changed files with 19 additions and 7 deletions

26
quiz.js
View File

@ -265,13 +265,25 @@ function takeJoker(activePlayer, joker) {
$('#players .player' + activePlayer + ' .' + joker).hide();
if (joker === 'fiftyfifty') {
var h1, h2, answers = questions[currentQuestion].answers;
do {
h1 = Math.floor(Math.random() * 4);
h2 = Math.floor(Math.random() * 4);
} while(answers[h1].right || answers[h2].right || h1 === h2);
$('#answer' + h1).fadeTo(500, 0.1);
$('#answer' + h2).fadeTo(500, 0.1);
var h1, h2, answers = questions[currentQuestion].answers;
var i,rightcount = 0;
for (i=0;i<4;i++){
if (answers[i].right ) {
rightcount++ ;
}
}
if (rightcount >= 3) {
$('#answer' + 1).fadeTo(500, 0.1);
$('#answer' + 2).fadeTo(500, 0.1);
} else {
do {
h1 = Math.floor(Math.random() * 4);
h2 = Math.floor(Math.random() * 4);
} while(answers[h1].right || answers[h2].right || h1 === h2);
$('#answer' + h1).fadeTo(500, 0.1);
$('#answer' + h2).fadeTo(500, 0.1);
}
}
if (joker === 'nedap') {
var q = questions[currentQuestion];