From 3ed15de5ce40e50fe534d8db851a1850accc326a Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sun, 26 Apr 2026 20:15:56 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20triviaduel=20=E2=80=94=20one=20guess=20p?= =?UTF-8?q?er=20player,=20auto-advance=20when=20both=20wrong?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each player now gets exactly one attempt per question. If their guess is wrong it's recorded and they're locked out for that round. If both players have guessed wrong the correct answer is revealed and the game moves to the next question immediately (no need to wait for the 45s timeout). Co-Authored-By: Claude Sonnet 4.6 --- matrixbot/commands.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/matrixbot/commands.py b/matrixbot/commands.py index 6f408f4..de72c40 100644 --- a/matrixbot/commands.py +++ b/matrixbot/commands.py @@ -3521,6 +3521,7 @@ async def _tduel_next_question(client: AsyncClient, room_id: str): game["round"] += 1 game["current_question"] = None game["answered_by"] = None + game["wrong_answers"] = set() # tracks who has already guessed wrong this round q_data = await _generate_trivia_question("general") if not q_data: @@ -3579,6 +3580,9 @@ async def cmd_da(client: AsyncClient, room_id: str, sender: str, args: str): if game.get("answered_by"): await send_text(client, room_id, "Someone already answered — wait for the next question!") return + if sender in game.get("wrong_answers", set()): + await send_text(client, room_id, "You already guessed wrong this round — wait for your opponent!") + return q = game["current_question"] guess = args.strip() @@ -3598,7 +3602,15 @@ async def cmd_da(client: AsyncClient, room_id: str, sender: str, args: str): if not is_correct: player_name = sender.split(":")[0].lstrip("@") + game["wrong_answers"].add(sender) await send_text(client, room_id, f"❌ {player_name}: Wrong!") + # If every player in the duel has now guessed wrong, skip to next question + if game["wrong_answers"] >= set(game["players"]): + game["current_question"] = None + await send_text(client, room_id, + f"Both wrong! The answer was: {correct_letter}) {correct_ans}") + await asyncio.sleep(2) + await _tduel_next_question(client, room_id) return # Correct!