feat(lobby): canonical backend round flow for issue #287 #298
@@ -247,6 +247,16 @@ def _maybe_promote_reveal_to_scoreboard(session: GameSession) -> GameSession:
|
||||
if current_round_question is None:
|
||||
return session
|
||||
|
||||
players_count = Player.objects.filter(session=session).count()
|
||||
guess_count = Guess.objects.filter(round_question=current_round_question).count()
|
||||
has_score_events = ScoreEvent.objects.filter(
|
||||
session=session,
|
||||
meta__round_question_id=current_round_question.id,
|
||||
).exists()
|
||||
reveal_is_resolved = has_score_events or (players_count > 0 and guess_count >= players_count)
|
||||
if not reveal_is_resolved:
|
||||
return session
|
||||
|
||||
with transaction.atomic():
|
||||
locked_session = GameSession.objects.select_for_update().get(pk=session.pk)
|
||||
if locked_session.status != GameSession.Status.REVEAL:
|
||||
|
||||
Reference in New Issue
Block a user