diff --git a/bot.user.js b/bot.user.js index 8c7f228f..85b2850a 100644 --- a/bot.user.js +++ b/bot.user.js @@ -1223,19 +1223,23 @@ var userInterface = window.userInterface = (function() { // Update stats overlay. updateStats: function() { var oContent = []; - var median; if (bot.scores.length === 0) return; - median = Math.round((bot.scores[Math.floor((bot.scores.length - 1) / 2)] + - bot.scores[Math.ceil((bot.scores.length - 1) / 2)]) / 2); + + var avg = Math.round(bot.scores.reduce(function (a, b) { return a + b.score; }, 0) / + (bot.scores.length)); + + var median = Math.round((bot.scores[Math.floor((bot.scores.length - 1) / 2)].score + + bot.scores[Math.ceil((bot.scores.length - 1) / 2)].score) / 2); + oContent.push('games played: ' + bot.scores.length); - oContent.push('a: ' + Math.round( - bot.scores.reduce(function(a, b) { return a + b; }) / (bot.scores.length)) + + oContent.push('a: ' + avg + ' m: ' + median); for (var i = 0; i < bot.scores.length && i < 10; i++) { - oContent.push(i + 1 + '. ' + bot.scores[i]); + oContent.push(i + 1 + '. ' + bot.scores[i].score + + ' in ' + Math.round(bot.scores[i].duration / 1000) + 's'); } userInterface.overlays.statsOverlay.innerHTML = oContent.join('
'); @@ -1325,14 +1329,20 @@ var userInterface = window.userInterface = (function() { } else if (bot.isBotEnabled && bot.isBotRunning) { bot.isBotRunning = false; if (window.lastscore && window.lastscore.childNodes[1]) { - bot.scores.push(parseInt(window.lastscore.childNodes[1].innerHTML)); + var score = parseInt(window.lastscore.childNodes[1].innerHTML); + var duration = Date.now() - bot.startTime; + bot.scores.push({ + score: score, + duration: duration + }); bot.scores.sort(function(a, b) { - return b - a; + return b.score - a.score; }); userInterface.updateStats(); } if (window.autoRespawn) { + bot.startTime = Date.now(); window.connect(); } } @@ -1456,5 +1466,6 @@ var userInterface = window.userInterface = (function() { setInterval(userInterface.framesPerSecond.fpsTimer, 80); // Start! + bot.startTime = Date.now(); userInterface.oefTimer(); })();