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!