From c3f1b5941696fb279fc8af06f6d1609248c78328 Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Sun, 30 Oct 2022 04:59:14 +0100 Subject: [PATCH] Hunt only listeners for closely matching words, fixed completion not awarding points, added help. --- src/games/hunt.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/games/hunt.js b/src/games/hunt.js index 5db1ac6..54171a1 100644 --- a/src/games/hunt.js +++ b/src/games/hunt.js @@ -74,7 +74,9 @@ function playLetter(playedLetter, context) { renderBoard(context); if (game.partial.every((letter) => letter !== null)) { - context.sendMessage(style.bold('The word was completed!'), context.room.id); + context.sendMessage(`${style.bold('The word was completed.')} ${context.user.prefixedUsername} gets a point!`, context.room.id); + context.setPoints(context.user); + games.delete(context.room.id); } } @@ -91,8 +93,10 @@ function playWord(word, context) { return; } - context.sendMessage('That\'s not it', context.room.id); - progress(context); + if (Math.abs(game.word.length - word.length) <= 1 && word.split('').some((letter, index) => game.word[index] === letter)) { + context.sendMessage(`That's not it, ${context.user.prefixedUsername}.`, context.room.id); + progress(context); + } } function stop(context) { @@ -124,7 +128,7 @@ function onCommand(args, context) { return; } - context.logger.info(`Hangman played ${word.word} with ${getGuesses(word)} guesses`); + context.logger.info(`Hangman played '${word.word}' with ${getGuesses(word)} guesses`); games.set(context.room.id, { word: word.word, @@ -160,4 +164,5 @@ module.exports = { onCommand, onMessage, commands: ['hangman'], + help: `Guess the word before the predator reaches its prey! Essentially, horizontal Hangman. Try ${config.prefix}hunt [length] for a specific word length.`, };