From fe0ad4d276fd1f2dd6ba6e8d98081611b52372aa Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sat, 4 Jan 2014 12:24:18 +0100 Subject: [PATCH] added a score threshold to prevent users from cheating their highscores --- lib/stats.js | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/stats.js b/lib/stats.js index e279549..d4fa7e3 100644 --- a/lib/stats.js +++ b/lib/stats.js @@ -57,11 +57,18 @@ module.exports = function(username, stats) { , 'bestscore' , 'bestguesstime' , 'worstguesstime' + , 'totguesstime' + , 'guessed' ]; db.hmget(args, function(err, replies) { if (err) { return console.error(err.message); } + if (stats.guesstime < 1000) { + stats.guesstime = replies[4] !== '0' + ? Math.round(replies[3] / replies[4]) + : 15000; + } if (stats.userscore > replies[0]) { // Set personal best multi.hset(key, 'bestscore', stats.userscore); diff --git a/package.json b/package.json index 3489123..1ec3689 100644 --- a/package.json +++ b/package.json @@ -30,5 +30,5 @@ "start": "node app.js" }, "subdomain": "binb", - "version": "0.4.0" + "version": "0.4.1" } -- 2.54.0