Add WPM to typing-race/typing-test

This commit is contained in:
Dragon Fire
2021-02-07 22:30:21 -05:00
parent 1725c83935
commit 0baf9d4efe
4 changed files with 6 additions and 4 deletions
+2 -1
View File
@@ -59,8 +59,9 @@ module.exports = class TypingRaceCommand extends Command {
}
this.client.games.delete(msg.channel.id);
if (!winner.size) return msg.say('Oh... No one won.');
const wpm = (sentence.length / 5) / ((newScore / 1000) / 60);
return msg.say(stripIndents`
The winner is ${winner.first().author}! (Took ${newScore / 1000} seconds)
The winner is ${winner.first().author}! (Took ${newScore / 1000} seconds, ${wpm} WPM)
${scoreBeat ? `**New High Score!** Old:` : `High Score:`} ${highScore / 1000} (Held by ${user})
`);
} catch (err) {
+2 -1
View File
@@ -39,8 +39,9 @@ module.exports = class TypingTestCommand extends Command {
}
if (!msgs.size) return msg.reply('Sorry! You lose!');
if (msgs.first().content.toLowerCase() !== sentence) return msg.reply('Sorry! You made a typo, so you lose!');
const wpm = (sentence.length / 5) / ((newScore / 1000) / 60);
return msg.reply(stripIndents`
Nice job! 10/10! You deserve some cake! (Took ${newScore / 1000} seconds)
Nice job! 10/10! You deserve some cake! (Took ${newScore / 1000} seconds, ${wpm} WPM)
${scoreBeat ? `**New High Score!** Old:` : `High Score:`} ${highScore / 1000} (Held by ${user})
`);
}