diff --git a/matrixbot/commands.py b/matrixbot/commands.py
index 40d3f8f..ef4f710 100644
--- a/matrixbot/commands.py
+++ b/matrixbot/commands.py
@@ -1226,8 +1226,8 @@ _HANGMAN_STAGES = [
def _hangman_display(game: dict) -> str:
word = game["word"]
- guessed = game["guessed_letters"]
- return " ".join(c if c in guessed else "_" for c in word.upper())
+ guessed = game["guessed_letters"] # stored lowercase
+ return " ".join(c if c.lower() in guessed else "_" for c in word.upper())
async def _generate_hangman_word() -> dict | None:
@@ -1340,24 +1340,36 @@ async def cmd_guess(client: AsyncClient, room_id: str, sender: str, args: str):
# Full word guess
if len(guess) > 1:
+ winner = sender.split(":")[0].lstrip("@")
if guess == word:
del _HANGMAN_GAMES[room_id]
- plain = f"🎉 {sender.split(':')[0].lstrip('@')} got it! The word was: {word.upper()}"
+ plain = f"🎉 {winner} got it! The word was: {word.upper()}"
html = (
- f'🎉 Correct! The word was: {word.upper()}
'
- f'Guessed by {sender.split(":")[0].lstrip("@")}!'
+ f'🎉 {winner} got it! The word was: {word.upper()}'
)
await send_html(client, room_id, plain, html)
else:
game["wrong_count"] += 1
+ display = _hangman_display(game)
if game["wrong_count"] >= 6:
del _HANGMAN_GAMES[room_id]
- plain = f"❌ Wrong! Game over — the word was: {word.upper()}"
+ plain = f"❌ '{guess.upper()}' is wrong! Game over — the word was: {word.upper()}"
html = f'❌ Wrong! Game over — the word was: {word.upper()}'
await send_html(client, room_id, plain, html)
else:
remaining = 6 - game["wrong_count"]
- await send_text(client, room_id, f"❌ '{guess.upper()}' is wrong! {remaining} wrong guesses remaining.")
+ plain = (
+ f"❌ '{guess.upper()}' is wrong! {remaining} guesses remaining.\n"
+ f"{_HANGMAN_STAGES[game['wrong_count']]}\n"
+ f"Word: {display}\nHint: {game['hint']}"
+ )
+ html = (
+ f'❌ \'{guess.upper()}\' is wrong! '
+ f'{remaining} guesses remaining.
'
+ f'Word: {display}
'
+ f'Hint: {game["hint"]}'
+ )
+ await send_html(client, room_id, plain, html)
return
# Single letter guess