fix: triviaduel — one guess per player, auto-advance when both wrong
Lint / Shell (shellcheck) (push) Successful in 8s
Lint / JS (eslint) (push) Successful in 7s
Lint / Python (ruff) (push) Successful in 4s
Lint / Python deps (pip-audit) (push) Successful in 41s
Lint / Secret scan (gitleaks) (push) Successful in 5s

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 <noreply@anthropic.com>
This commit is contained in:
2026-04-26 20:15:56 -04:00
parent 121e160535
commit 3ed15de5ce
+12
View File
@@ -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!