feat: add hand detail API and enrich hand summary fields
- HandSummary: add hole_cards, starting_stacks, ending_stacks, pot_contributions - Engine: capture all players' hole cards (not just showdown), pre/post hand stacks, per-level pot contributions - Server: new GET /game/<game_id>/hands/<hand_number> route - Service: add get_hand_state() method - Tests: add ServerTests for new endpoint, update existing tests - Existing GET /game/<game_id> auto-inherits new fields via shared to_dict()
This commit is contained in:
@@ -78,6 +78,13 @@ class GameManager:
|
||||
def get_game_state(self, game_id: str) -> dict[str, object]:
|
||||
return self.get_game(game_id).snapshot_completed()
|
||||
|
||||
def get_hand_state(self, game_id: str, hand_number: int) -> dict[str, object]:
|
||||
state = self.get_game_state(game_id)
|
||||
for hand in state.get("hands", []):
|
||||
if hand.get("hand_number") == hand_number:
|
||||
return hand
|
||||
raise KeyError(f"hand not found: {game_id} #{hand_number}")
|
||||
|
||||
def list_games(self) -> list[dict[str, object]]:
|
||||
with self._lock:
|
||||
games = list(self._games.values())
|
||||
|
||||
Reference in New Issue
Block a user