Skip to content

Commit 7bd0a78

Browse files
committed
Made score match server response so they are synced correctly - Issue #12
1 parent ee86ce9 commit 7bd0a78

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

public_html/src/css/GameScreen.css

+9
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@
116116
animation-duration: 800ms;
117117
}
118118

119+
.flashInOut.long {
120+
-webkit-animation-name: flashInOut;
121+
-moz-animation-name: flashInOut;
122+
animation-name: flashInOut;
123+
-webkit-animation-duration: 3000ms;
124+
-moz-animation-duration: 3000ms;
125+
animation-duration: 3000ms;
126+
}
127+
119128
/* Game Completed UI */
120129

121130
#gameCompletedUI {

public_html/src/js/GameScreen.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@
157157
while the loading screen is up (< 10 seconds) or if there
158158
is a corrupted file.
159159
*/
160-
/* TODO Contact? Hack in error message? */
161160
alert('A fatal error has occurred. Please log-in to the wifi! Error 407.\n\n' +
162161
'Please contact ' + 'saschlac' + '@udel' + '.edu' + ' if this problem persists.');
163162
this.loadingState--;
@@ -230,13 +229,13 @@
230229
}
231230

232231
if(data.correct === 'true') {
233-
this.scoreManager.correct(RIGHT_ANSWER_POINTS);
232+
this.scoreManager.correct(data.score - this.scoreManager.score);
234233
this.nextQuestion();
235234
} else {
236-
this.scoreManager.incorrect(WRONG_ANSWER_POINTS);
235+
this.scoreManager.incorrect(data.score - this.scoreManager.score);
237236
$('#scoreChange, #' + this.currentAnswer).addClass('incorrect');
238237
}
239-
$('#scoreChange').text(this.scoreManager.text()).addClass('flashInOut')
238+
$('#scoreChange').text(this.scoreManager.text()).addClass('flashInOut');
240239
};
241240

242241
GameScreen.prototype.pollAnswer = function(userAnswer, currentQuestion) {
@@ -256,17 +255,18 @@
256255
$('#finalScore').text('Final Score: ' + response.final_score);
257256
$('#rank').text('Rank: #' + response.rank);
258257
$('#gameCompletedUI').addClass('in active');
258+
259+
this.scoreManager.correct(response.final_score - this.scoreManager.score);
260+
setTimeout(
261+
function( ref ) {
262+
$('#scoreChange').text('+Time: ' + ref.scoreManager.text()).addClass('flashInOut long');
263+
},
264+
1000, this);
259265
}
260266
disableButtons( );
261267
this.scene.remove(this.currentQuestion[ QUESTION_MOLECULE ]);
262268
this.currentQuestion = undefined;
263269
this.timer.stop( );
264-
$('#scoreChange')
265-
.stop(true, true)
266-
.animate({
267-
opacity: 0
268-
},
269-
300);
270270
FCCommunicationManager.endFlashcardGame(UserData.auth,
271271
this.gameData.game_session_id,
272272
this.timer.getElapsedMs(),
@@ -292,7 +292,7 @@
292292
});
293293

294294
$('#scoreChange').on('animationend webkitAnimationEnd ', function() {
295-
$(this).removeClass('flashInOut incorrect');
295+
$(this).removeClass('flashInOut incorrect long');
296296
});
297297
}
298298

0 commit comments

Comments
 (0)