fix: drop game_number by one for finished playoff cards
Scoreboard payloads don't include gameNumber, so the previous fix fell straight through to series_state['game_number'], which is hi+lo+1 — the *next* game. Once a game goes FINAL the win for this game is already banked in seriesStatus, so the card's own number is hi+lo. For the just-played Game 1 of Kings/Avalanche (series now 1-0), this brings the header back to "Game 1 of 7" instead of "Game 2 of 7". Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+7
-2
@@ -93,11 +93,16 @@ def series_state(series_status):
|
||||
|
||||
|
||||
def _game_number(game, state):
|
||||
"""This card's game number. Prefer the raw ``gameNumber`` field so we don't
|
||||
drift forward once ``seriesStatus`` advances after the game ends."""
|
||||
"""This card's game number. seriesStatus counts wins through the current
|
||||
payload, so once a game goes FINAL the win for this game is already banked
|
||||
and state['game_number'] (hi+lo+1) points at the *next* game. For a finished
|
||||
card, pin to hi+lo. The scoreboard payload doesn't carry a raw gameNumber,
|
||||
but we honor it if present (e.g. from the series-detail endpoint)."""
|
||||
raw = game.get("gameNumber")
|
||||
if isinstance(raw, int) and raw > 0:
|
||||
return raw
|
||||
if game.get("gameState") in ("FINAL", "OFF"):
|
||||
return max(1, state["hi"] + state["lo"])
|
||||
return state["game_number"]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user