<commit_before>(function(){
  game.state.add('gameOver', {create:create});

  // var addScore;
  var topTenScores;
  getScoresFromFirebase();

  function create(){
    console.log(topTenScores);
    game.add.text(100, 120, 'HIGH SCORE LEADERBOARD', { fontSize: '48px', fill: 'white' });
    game.add.text(200, 170, topTenScores[0].initials + '     ' + topTenScores[0].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 200, topTenScores[1].initials + '     ' + topTenScores[1].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 230, topTenScores[2].initials + '     ' + topTenScores[2].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 260, topTenScores[3].initials + '     ' + topTenScores[3].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 290, topTenScores[4].initials + '     ' + topTenScores[4].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 320, topTenScores[5].initials + '     ' + topTenScores[5].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 350, topTenScores[6].initials + '     ' + topTenScores[6].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 380, topTenScores[7].initials + '     ' + topTenScores[7].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 410, topTenScores[8].initials + '     ' + topTenScores[8].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 440, topTenScores[9].initials + '     ' + topTenScores[9].score, { fontSize: '32px', fill: 'white' });
    game.add.text(130, 490, '- press SPACE to restart -', { fontSize: '32px', fill: 'white' });

    //addScore();
    var spacebar = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
    spacebar.onDown.add(restartGame);
  }

  function restartGame() {
    this.game.state.start('ready');
  }

  function getScoresFromFirebase () {
  var fb = new Firebase('https://bitblaster.firebaseio.com/');
  fb.once('value', function(snapshot) {
    var storedScores = snapshot.val();
    var sortedScores =  _.sortBy(storedScores, 'score');
    topTenScores = sortedScores.slice(sortedScores.length -10, sortedScores.length).reverse();
    _.forEach(topTenScores, function(scoreObj) {
    console.log(scoreObj.initials + ": " + scoreObj.score);
    });
  });
}
})();<commit_msg>high scores update in realtime<commit_after>(function(){
  game.state.add('gameOver', {create:create});


  function create(){
    getScoresFromFirebase();
  }

  function restartGame() {
    this.game.state.start('ready');
  }

  function getScoresFromFirebase () {
  var fb = new Firebase('https://bitblaster.firebaseio.com/');
  fb.once('value', function(snapshot) {
    var storedScores = snapshot.val();
    var sortedScores =  _.sortBy(storedScores, 'score');
    leaderboard = sortedScores.slice(sortedScores.length -10, sortedScores.length).reverse();
    // _.forEach(leaderboard, function(scoreObj) {
    // console.log(scoreObj.initials + ": " + scoreObj.score);
    // });
    game.add.text(100, 120, 'HIGH SCORE LEADERBOARD', { fontSize: '48px', fill: 'white' });
    game.add.text(200, 170, " 1.  " + leaderboard[0].initials + '     ' + leaderboard[0].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 200, " 2.  " +leaderboard[1].initials + '     ' + leaderboard[1].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 230, " 3.  " +leaderboard[2].initials + '     ' + leaderboard[2].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 260, " 4.  " +leaderboard[3].initials + '     ' + leaderboard[3].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 290, " 5.  " +leaderboard[4].initials + '     ' + leaderboard[4].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 320, " 6.  " +leaderboard[5].initials + '     ' + leaderboard[5].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 350, " 7.  " +leaderboard[6].initials + '     ' + leaderboard[6].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 380, " 8.  " +leaderboard[7].initials + '     ' + leaderboard[7].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 410, " 9.  " +leaderboard[8].initials + '     ' + leaderboard[8].score, { fontSize: '32px', fill: 'white' });
    game.add.text(200, 440, "10. " +leaderboard[9].initials + '     ' + leaderboard[9].score, { fontSize: '32px', fill: 'white' });
    game.add.text(130, 490, '- press SPACE to restart -', { fontSize: '32px', fill: 'white' });

    //addScore();
    var spacebar = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
    spacebar.onDown.add(restartGame);
  });
}
})();
{'fraction_non_alphanumeric': 0.20145735105015003, 'fraction_numerical': 0.052936133733390484, 'mean_word_length': 3.733265720081136, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3172361', 'n_tokens_mistral': 1916, 'n_tokens_neox': 1703, 'n_words': 291}