Permalink
Browse files

comments, video link in readme

  • Loading branch information...
1 parent 4f031ea commit abb7525a0dbe3d29f78f9046a98ed0c19a77b069 @iloire committed Mar 21, 2012
Showing with 10 additions and 6 deletions.
  1. +2 −0 README.md
  2. +1 −0 config.js
  3. +7 −6 lib/modules/race.js
View
2 README.md
@@ -20,6 +20,8 @@ Enjoy!
[http://letsnode.com:8090/](http://letsnode.com:8090/)
+[You can also watch a short video to see the game being played](http://www.youtube.com/watch?v=LXbYSJfLUW8&feature=youtu.be)
+
##Installation
###Install dependencies with npm:
View
1 config.js
@@ -7,6 +7,7 @@ exports.values={
}
,
game : {
+ show_hall_of_fame: 20,
show_history_games: 20,
duration: 30 //seconds
}
View
13 lib/modules/race.js
@@ -32,10 +32,11 @@ function createRace(server){
hall_of_fame.push(score); //add all scores
};
- //sort
+ //sort by score
util.sort(hall_of_fame, 'score', true);
- return hall_of_fame.slice(0,10);
+ //and slice array!
+ return hall_of_fame.slice(0,config.game.show_hall_of_fame);
}
function broadcast(sessions, command, data, exception){
@@ -80,12 +81,12 @@ function createRace(server){
}
scores = {}; //reset
game_started = new Date(); //start game again!
- broadcast (sessions, 'scores', format_scores(scores)); //reset scores in client
- broadcast (sessions, 'hall_of_fame', hall_of_fame); //reset scores in client
+ broadcast (sessions, 'scores', format_scores(scores)); //broadcast scores
+ broadcast (sessions, 'hall_of_fame', hall_of_fame); //broadcast "hall of fame"
broadcast (sessions, 'new_game', null); //flash 'new game!'
}
else
- broadcast (sessions, 'time', remaining); //broacast time
+ broadcast (sessions, 'time', remaining); //broacast time ticks
}, 1000);
@@ -106,7 +107,7 @@ function createRace(server){
client.emit ('result_operation', 1); //msg to winner
broadcast (sessions, 'result_operation', 2, client.id); //msg to rest of players. someone else won!
- var safe_name = data.name.slice(0,25);
+ var safe_name = data.name.slice(0,25); //avoid long names
scores[safe_name] = (scores[safe_name] || 0) + 1 //credit score to client
broadcast (sessions, 'scores', format_scores(scores)); //broacast scores

0 comments on commit abb7525

Please sign in to comment.