-
Notifications
You must be signed in to change notification settings - Fork 7
refactor: expose public current_time() and trigger_early_reveal_if_complete() on GameState (closes #452) #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -793,8 +793,8 @@ async def _handle_submit( | |
| bet = data.get("bet", False) | ||
| player.bet = bool(bet) | ||
|
|
||
| # Record submission — Issue #419: use game_state._now() for clock consistency | ||
| submission_time = game_state._now() | ||
| # Record submission — Issue #419: use game_state.current_time() for clock consistency | ||
| submission_time = game_state.current_time() | ||
| player.submit_guess(year, submission_time) | ||
|
|
||
| # Send acknowledgment | ||
|
|
@@ -809,16 +809,13 @@ async def _handle_submit( | |
| await self.broadcast_state() | ||
|
|
||
| # Story 20.9: Check for early reveal when all guesses are complete | ||
| # Note: _trigger_early_reveal() calls end_round() which broadcasts via callback | ||
| all_complete = game_state.check_all_guesses_complete() | ||
| # Note: trigger_early_reveal_if_complete() calls end_round() which broadcasts via callback | ||
| _LOGGER.debug( | ||
| "Early reveal check: phase=%s, all_complete=%s, artist_challenge=%s", | ||
| "Early reveal check: phase=%s, artist_challenge=%s", | ||
| game_state.phase.value, | ||
| all_complete, | ||
| game_state.artist_challenge_enabled, | ||
| ) | ||
| if game_state.phase == GamePhase.PLAYING and all_complete: | ||
| await game_state._trigger_early_reveal() | ||
| await game_state.trigger_early_reveal_if_complete() | ||
|
Comment on lines
813
to
+818
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This debug log is now redundant and incomplete compared to the original implementation, as it no longer includes the await game_state.trigger_early_reveal_if_complete() |
||
|
|
||
| _LOGGER.info( | ||
| "Player %s submitted guess: %d at %.2f", player.name, year, submission_time | ||
|
|
@@ -1163,8 +1160,8 @@ async def _handle_artist_guess( | |
| ) | ||
| return | ||
|
|
||
| # Submit guess — Issue #419: use game_state._now() for clock consistency | ||
| guess_time = game_state._now() | ||
| # Submit guess — Issue #419: use game_state.current_time() for clock consistency | ||
| guess_time = game_state.current_time() | ||
| result = game_state.submit_artist_guess(player.name, artist, guess_time) | ||
|
|
||
| # Story 20.9: Track that player has made an artist guess | ||
|
|
@@ -1190,12 +1187,8 @@ async def _handle_artist_guess( | |
| await self.broadcast_state() | ||
|
|
||
| # Story 20.9: Check for early reveal when all guesses are complete | ||
| # Note: _trigger_early_reveal() calls end_round() which broadcasts via callback | ||
| if ( | ||
| game_state.phase == GamePhase.PLAYING | ||
| and game_state.check_all_guesses_complete() | ||
| ): | ||
| await game_state._trigger_early_reveal() | ||
| # Note: trigger_early_reveal_if_complete() calls end_round() which broadcasts via callback | ||
| await game_state.trigger_early_reveal_if_complete() | ||
|
|
||
| _LOGGER.debug( | ||
| "Artist guess from %s: '%s' -> correct=%s, first=%s", | ||
|
|
@@ -1263,8 +1256,8 @@ async def _handle_movie_guess( | |
| ) | ||
| return | ||
|
|
||
| # Submit guess with server-side timing — Issue #419: use game_state._now() | ||
| guess_time = game_state._now() | ||
| # Submit guess with server-side timing — Issue #419: use game_state.current_time() | ||
| guess_time = game_state.current_time() | ||
| result = game_state.submit_movie_guess(player.name, movie, guess_time) | ||
|
|
||
| # Issue #28: Track that player has made a movie guess | ||
|
|
@@ -1284,12 +1277,8 @@ async def _handle_movie_guess( | |
| await ws.send_json(response) | ||
|
|
||
| # Issue #28: Check for early reveal when all guesses are complete | ||
| # Note: _trigger_early_reveal() calls end_round() which broadcasts via callback | ||
| if ( | ||
| game_state.phase == GamePhase.PLAYING | ||
| and game_state.check_all_guesses_complete() | ||
| ): | ||
| await game_state._trigger_early_reveal() | ||
| # Note: trigger_early_reveal_if_complete() calls end_round() which broadcasts via callback | ||
| await game_state.trigger_early_reveal_if_complete() | ||
|
|
||
| _LOGGER.debug( | ||
| "Movie guess from %s: '%s' -> correct=%s, rank=%s", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactored
trigger_early_reveal_if_completemethod loses the observability previously present inwebsocket.py. Specifically, theall_completestatus is no longer logged, making it harder to debug why an early reveal might not have triggered. Moving the debug logging into this method ensures all call sites (submit, artist guess, movie guess) benefit from consistent observability without duplicating logic.