fix: triviaduel — one guess per player, auto-advance when both wrong
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:
@@ -3521,6 +3521,7 @@ async def _tduel_next_question(client: AsyncClient, room_id: str):
|
|||||||
game["round"] += 1
|
game["round"] += 1
|
||||||
game["current_question"] = None
|
game["current_question"] = None
|
||||||
game["answered_by"] = None
|
game["answered_by"] = None
|
||||||
|
game["wrong_answers"] = set() # tracks who has already guessed wrong this round
|
||||||
|
|
||||||
q_data = await _generate_trivia_question("general")
|
q_data = await _generate_trivia_question("general")
|
||||||
if not q_data:
|
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"):
|
if game.get("answered_by"):
|
||||||
await send_text(client, room_id, "Someone already answered — wait for the next question!")
|
await send_text(client, room_id, "Someone already answered — wait for the next question!")
|
||||||
return
|
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"]
|
q = game["current_question"]
|
||||||
guess = args.strip()
|
guess = args.strip()
|
||||||
@@ -3598,7 +3602,15 @@ async def cmd_da(client: AsyncClient, room_id: str, sender: str, args: str):
|
|||||||
|
|
||||||
if not is_correct:
|
if not is_correct:
|
||||||
player_name = sender.split(":")[0].lstrip("@")
|
player_name = sender.split(":")[0].lstrip("@")
|
||||||
|
game["wrong_answers"].add(sender)
|
||||||
await send_text(client, room_id, f"❌ {player_name}: Wrong!")
|
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
|
return
|
||||||
|
|
||||||
# Correct!
|
# Correct!
|
||||||
|
|||||||
Reference in New Issue
Block a user