This commit is contained in:
Dragon Fire
2021-01-16 18:11:21 -05:00
parent d159e8736c
commit c2e39b9b2e
+5 -3
View File
@@ -100,14 +100,16 @@ module.exports = class MinesweeperCommand extends Command {
const newScore = Date.now() - startTime;
const highScoreGet = await this.client.redis.get(`minesweeper-${size}`);
const highScore = highScoreGet ? Number.parseInt(highScoreGet, 10) : null;
if (!highScore || highScore > newScore) await this.client.redis.set(`minesweeper-${size}`, newScore);
if (win && (!highScore || highScore > newScore)) {
await this.client.redis.set(`minesweeper-${size}`, newScore);
}
this.client.games.delete(msg.channel.id);
if (win === null) return msg.say('Game ended due to inactivity.');
const newDisplayTime = moment.duration(newScore).format('mm:ss');
const displayTime = moment.duration(highScore).format('mm:ss');
return msg.say(stripIndents`
${win ? 'Nice job! You win!' : 'Sorry... You lose.'} (Took ${newDisplayTime})
${!highScore || highScore > newScore ? `**New High Score!** Old:` : `High Score:`} ${displayTime}
${win ? `Nice job! You win! (Took ${newDisplayTime})` : 'Sorry... You lose.'}
${win && (!highScore || highScore > newScore) ? `**New High Score!** Old:` : `High Score:`} ${displayTime}
${this.displayBoard(game.board)}
`);