|
@@ -12,6 +12,7 @@ var disconnect = true;
|
12
|
12
|
var scoreAdversaire = 0;
|
13
|
13
|
var pseudo ='';
|
14
|
14
|
var reponseUser = -1, bonneReponse;
|
|
15
|
+var againstLoser = false;
|
15
|
16
|
|
16
|
17
|
function init() {
|
17
|
18
|
|
|
@@ -55,8 +56,9 @@ var setEventHandlers = function() {
|
55
|
56
|
socket.on("questions", play);
|
56
|
57
|
socket.on("lolheded", endGame);
|
57
|
58
|
socket.on("end", onEnd);
|
58
|
|
- socket.on("qpass", function() {
|
|
59
|
+ socket.on("qpass", function(gotAPoint) {
|
59
|
60
|
reponseUser = -1;
|
|
61
|
+ againstLoser = gotAPoint;
|
60
|
62
|
checkAnswer();
|
61
|
63
|
})
|
62
|
64
|
};
|
|
@@ -128,11 +130,11 @@ function quest(id) {
|
128
|
130
|
$("#question-count").html("Question "+currentQuestion+"/"+nbQuestions);
|
129
|
131
|
if(canClick) {
|
130
|
132
|
$("#rep1").off('click');
|
131
|
|
- $("#rep1").one("click", function() { reponseUser = 1; checkAnswer(); socket.emit('nextQuestion'); });
|
|
133
|
+ $("#rep1").one("click", function() { reponseUser = 1; checkAnswer(); socket.emit('nextQuestion', reponseUser == bonneReponse); });
|
132
|
134
|
$("#rep2").off('click');
|
133
|
|
- $("#rep2").one("click", function() { reponseUser = 2; checkAnswer(); socket.emit('nextQuestion'); });
|
|
135
|
+ $("#rep2").one("click", function() { reponseUser = 2; checkAnswer(); socket.emit('nextQuestion', reponseUser == bonneReponse); });
|
134
|
136
|
$("#both").off('click');
|
135
|
|
- $("#both").one("click", function() { reponseUser = 0; checkAnswer(); socket.emit('nextQuestion'); });
|
|
137
|
+ $("#both").one("click", function() { reponseUser = 0; checkAnswer(); socket.emit('nextQuestion', reponseUser == bonneReponse); });
|
136
|
138
|
}
|
137
|
139
|
}
|
138
|
140
|
|
|
@@ -142,8 +144,9 @@ function checkAnswer() {
|
142
|
144
|
$("#rep2").off('click');
|
143
|
145
|
$("#both").off('click');
|
144
|
146
|
stopTimer();
|
145
|
|
- if(reponseUser == bonneReponse) {
|
|
147
|
+ if(reponseUser == bonneReponse || againstLoser) {
|
146
|
148
|
score += secRestantes+1;
|
|
149
|
+ againstLoser = false;
|
147
|
150
|
}
|
148
|
151
|
if(score > 1) {
|
149
|
152
|
$("#score").html("Score : "+score+" miams");
|