Update Football display. Add End of Period text and long down distance for larger screens (#101)

Co-authored-by: Alex Resnick <adr8282@gmail.com>
This commit is contained in:
Alex Resnick
2025-10-05 14:17:49 -05:00
committed by GitHub
parent f3d02e07ea
commit 9ba76b56d7
3 changed files with 11 additions and 7 deletions

View File

@@ -27,6 +27,7 @@ class Football(SportsCore):
# --- Football Specific Details (Likely same for NFL/NCAAFB) ---
down_distance_text = ""
down_distance_text_long = ""
possession_indicator = None # Default to None
scoring_event = "" # Track scoring events
home_timeouts = 0
@@ -37,7 +38,7 @@ class Football(SportsCore):
if situation and status["type"]["state"] == "in":
# down = situation.get("down")
down_distance_text = situation.get("shortDownDistanceText")
# long_text = situation.get("downDistanceText")
down_distance_text_long = situation.get("downDistanceText")
# distance = situation.get("distance")
# Detect scoring events from status detail
@@ -97,6 +98,7 @@ class Football(SportsCore):
"home_timeouts": home_timeouts,
"away_timeouts": away_timeouts,
"down_distance_text": down_distance_text, # Added Down/Distance
"down_distance_text_long": down_distance_text_long,
"is_redzone": is_redzone,
"possession": posession, # ID of team with possession
"possession_indicator": possession_indicator, # Added for easy home/away check
@@ -203,7 +205,10 @@ class FootballLive(Football, SportsLive):
# Period/Quarter and Clock (Top center)
period_clock_text = f"{game.get('period_text', '')} {game.get('clock', '')}".strip()
if game.get("is_halftime"): period_clock_text = "Halftime" # Override for halftime
if game.get("is_halftime"): \
period_clock_text = "Halftime" # Override for halftime
elif game.get("is_period_break"):
period_clock_text = game.get("status_text", "Period Break")
status_width = draw_overlay.textlength(period_clock_text, font=self.fonts['time'])
status_x = (self.display_width - status_width) // 2
@@ -213,6 +218,8 @@ class FootballLive(Football, SportsLive):
# Down & Distance or Scoring Event (Below Period/Clock)
scoring_event = game.get("scoring_event", "")
down_distance = game.get("down_distance_text", "")
if self.display_width > 128:
down_distance = game.get("down_distance_text_long", "")
# Show scoring event if detected, otherwise show down & distance
if scoring_event and game.get("is_live"):

View File

@@ -75,7 +75,6 @@ class Hockey(SportsCore):
home_shots = 0
away_shots = 0
status_short = ""
if home_team_saves_per > 0:
away_shots = round(home_team_saves / home_team_saves_per)
if away_team_saves_per > 0:
@@ -84,7 +83,6 @@ class Hockey(SportsCore):
if situation and status["type"]["state"] == "in":
# Detect scoring events from status detail
# status_detail = status["type"].get("detail", "")
status_short = status["type"].get("shortDetail", "")
powerplay = situation.get("isPowerPlay", False)
penalties = situation.get("penalties", "")
@@ -115,8 +113,6 @@ class Hockey(SportsCore):
"penalties": penalties,
"home_shots": home_shots,
"away_shots": away_shots,
"is_period_break": status["type"]["name"] == "STATUS_END_PERIOD",
"status_short": status_short,
}
)
@@ -229,7 +225,7 @@ class HockeyLive(Hockey, SportsLive):
f"{game.get('period_text', '')} {game.get('clock', '')}".strip()
)
if game.get("is_period_break"):
period_clock_text = game.get("status_short", "Period Break")
period_clock_text = game.get("status_text", "Period Break")
status_width = draw_overlay.textlength(
period_clock_text, font=self.fonts["time"]

View File

@@ -464,6 +464,7 @@ class SportsCore(ABC):
"is_upcoming": (status["type"]["state"] == "pre" or
status["type"]["name"].lower() in ['scheduled', 'pre-game', 'status_scheduled']),
"is_halftime": status["type"]["state"] == "halftime" or status["type"]["name"] == "STATUS_HALFTIME", # Added halftime check
"is_period_break": status["type"]["name"] == "STATUS_END_PERIOD", # Added Period Break check
"home_abbr": home_abbr,
"home_id": home_team["id"],
"home_score": home_team.get("score", "0"),