Skip to content

Commit

Permalink
Added highlight for high scores that are winners
Browse files Browse the repository at this point in the history
  • Loading branch information
grant committed Mar 13, 2014
1 parent 7a5cfe3 commit 24a02c6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
11 changes: 7 additions & 4 deletions private/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ module.exports = {
// Resets the game
restart: function (callback) {
// Add score once
var score = gameManager.getGameData().score;
var gameData = gameManager.getGameData();
var score = gameData.score;
var won = gameData.won;
if (!isRestarting) {
isRestarting = true;
addScore(score);
addScore(score, won);
// Restart the game after a short duration
setTimeout(function () {
isRestarting = false;
Expand All @@ -48,10 +50,11 @@ module.exports = {
};

// Add a score to the high score list
function addScore (score) {
function addScore (score, won) {
scores.push({
date: new Date(),
score: score
score: score,
won: won
});

// Keep scores sorted
Expand Down
2 changes: 2 additions & 0 deletions private/sass/main.sass
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ hr
margin-bottom: 10px
.score
padding-right: 5px
.won
color: #edcf72

.userInputs
li
Expand Down
7 changes: 6 additions & 1 deletion public/js/multiplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ function setHighscores (highscores) {
for (var i = 0; i < highscores.length; ++i) {
var hsElement = document.createElement('li');
var hs = highscores[i];
hsElement.innerHTML = '<strong class="score">' + hs.score + '</strong>' + prettyDate(new Date(hs.date));
var hsString = '<strong class="score">' + hs.score + '</strong>' + prettyDate(new Date(hs.date));
if (hs.won) {
hsElement.innerHTML = '<span class="won">' + hsString + '</span>';
} else {
hsElement.innerHTML = hsString;
}
highscoreList.appendChild(hsElement);
}
}
Expand Down
2 changes: 1 addition & 1 deletion public/style/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

0 comments on commit 24a02c6

Please sign in to comment.