-
Notifications
You must be signed in to change notification settings - Fork 7
refactor: expose subsystems directly on GameState, remove pure proxy properties (closes #480) #485
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 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,7 +40,7 @@ def serialize(gs: GameState) -> dict[str, Any] | None: | |||||||||||||||||||||||||||||
| state: dict[str, Any] = { | ||||||||||||||||||||||||||||||
| "game_id": gs.game_id, | ||||||||||||||||||||||||||||||
| "phase": gs.phase.value, | ||||||||||||||||||||||||||||||
| "player_count": len(gs.players), | ||||||||||||||||||||||||||||||
| "player_count": len(gs._player_registry.players), | ||||||||||||||||||||||||||||||
| "players": gs.get_players_state(), | ||||||||||||||||||||||||||||||
| "language": gs.language, | ||||||||||||||||||||||||||||||
| "difficulty": gs.difficulty, | ||||||||||||||||||||||||||||||
|
|
@@ -89,7 +89,7 @@ def _add_playing_state(gs: GameState, state: dict[str, Any]) -> None: | |||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| # Submission tracking (Story 4.4) | ||||||||||||||||||||||||||||||
| state["submitted_count"] = sum( | ||||||||||||||||||||||||||||||
| 1 for p in gs.players.values() if p.submitted | ||||||||||||||||||||||||||||||
| 1 for p in gs._player_registry.players.values() if p.submitted | ||||||||||||||||||||||||||||||
|
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. |
||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| state["all_submitted"] = gs.all_submitted() | ||||||||||||||||||||||||||||||
| # Song info WITHOUT year during PLAYING (hidden until reveal) | ||||||||||||||||||||||||||||||
|
|
@@ -173,11 +173,11 @@ def _add_end_state(gs: GameState, state: dict[str, Any]) -> None: | |||||||||||||||||||||||||||||
| state["leaderboard"] = gs.get_final_leaderboard() | ||||||||||||||||||||||||||||||
| state["game_stats"] = { | ||||||||||||||||||||||||||||||
| "total_rounds": rm.round, | ||||||||||||||||||||||||||||||
| "total_players": len(gs.players), | ||||||||||||||||||||||||||||||
| "total_players": len(gs._player_registry.players), | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| # Include winner info | ||||||||||||||||||||||||||||||
| if gs.players: | ||||||||||||||||||||||||||||||
| winner = max(gs.players.values(), key=lambda p: p.score) | ||||||||||||||||||||||||||||||
| if gs._player_registry.players: | ||||||||||||||||||||||||||||||
| winner = max(gs._player_registry.players.values(), key=lambda p: p.score) | ||||||||||||||||||||||||||||||
| state["winner"] = {"name": winner.name, "score": winner.score} | ||||||||||||||||||||||||||||||
|
Comment on lines
+176
to
181
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. Multiple instances of private attribute access (
Suggested change
|
||||||||||||||||||||||||||||||
| # Game performance comparison for end screen (Story 14.4 AC5, AC6) | ||||||||||||||||||||||||||||||
| game_performance = gs.get_game_performance() | ||||||||||||||||||||||||||||||
|
|
@@ -204,7 +204,7 @@ def get_reveal_players_state(gs: GameState) -> list[dict[str, Any]]: | |||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||
| rm = gs._round_manager | ||||||||||||||||||||||||||||||
| players = [] | ||||||||||||||||||||||||||||||
| for p in gs.players.values(): | ||||||||||||||||||||||||||||||
| for p in gs._player_registry.players.values(): | ||||||||||||||||||||||||||||||
|
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. |
||||||||||||||||||||||||||||||
| player_data = { | ||||||||||||||||||||||||||||||
| "name": p.name, | ||||||||||||||||||||||||||||||
| "score": p.score, | ||||||||||||||||||||||||||||||
|
|
@@ -231,10 +231,10 @@ def get_reveal_players_state(gs: GameState) -> list[dict[str, Any]]: | |||||||||||||||||||||||||||||
| "steal_available": p.steal_available, | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| # Story 20.4: Add artist bonus if challenge is enabled | ||||||||||||||||||||||||||||||
| if gs.artist_challenge_enabled: | ||||||||||||||||||||||||||||||
| if gs._challenge_manager.artist_challenge_enabled: | ||||||||||||||||||||||||||||||
| player_data["artist_bonus"] = p.artist_bonus | ||||||||||||||||||||||||||||||
| # Issue #28: Add movie bonus if quiz is enabled | ||||||||||||||||||||||||||||||
| if gs.movie_quiz_enabled: | ||||||||||||||||||||||||||||||
| if gs._challenge_manager.movie_quiz_enabled: | ||||||||||||||||||||||||||||||
| player_data["movie_bonus"] = p.movie_bonus | ||||||||||||||||||||||||||||||
|
Comment on lines
+234
to
238
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. The
Suggested change
|
||||||||||||||||||||||||||||||
| # Issue #23: Add intro bonus if mode is enabled | ||||||||||||||||||||||||||||||
| if rm.intro_mode_enabled: | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
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
GameStateclass now exposes theplayer_registrysubsystem via a public property. External callers like this serializer should use the public property instead of accessing the private_player_registryattribute directly to maintain proper encapsulation and consistency with the refactoring goal.