mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-29 03:53:00 +00:00
Add test mode support to MLB manager with live game simulation
This commit is contained in:
@@ -269,6 +269,31 @@ class MBLLiveManager(BaseMLBManager):
|
||||
self.last_display_update = 0 # Track when we last updated the display
|
||||
self.last_log_time = 0
|
||||
self.log_interval = 300 # Only log status every 5 minutes
|
||||
self.test_mode = self.mlb_config.get('test_mode', False)
|
||||
|
||||
# Initialize with test game only if test mode is enabled
|
||||
if self.test_mode:
|
||||
self.current_game = {
|
||||
"home_team": "TB",
|
||||
"away_team": "TEX",
|
||||
"home_score": "3",
|
||||
"away_score": "2",
|
||||
"inning": 5,
|
||||
"inning_half": "top",
|
||||
"balls": 2,
|
||||
"strikes": 1,
|
||||
"outs": 1,
|
||||
"bases_occupied": [True, False, True], # 1st and 3rd base occupied
|
||||
"home_logo_path": os.path.join(self.logo_dir, "TB.png"),
|
||||
"away_logo_path": os.path.join(self.logo_dir, "TEX.png"),
|
||||
"game_time": "7:30 PM",
|
||||
"game_date": "Apr 17",
|
||||
"status": "live"
|
||||
}
|
||||
self.live_games = [self.current_game]
|
||||
self.logger.info("Initialized MBLLiveManager with test game: TB vs TEX")
|
||||
else:
|
||||
self.logger.info("Initialized MBLLiveManager in live mode")
|
||||
|
||||
def update(self):
|
||||
"""Update live game data."""
|
||||
@@ -279,6 +304,36 @@ class MBLLiveManager(BaseMLBManager):
|
||||
if current_time - self.last_update >= interval:
|
||||
self.last_update = current_time
|
||||
|
||||
if self.test_mode:
|
||||
# For testing, we'll just update the game state to show it's working
|
||||
if self.current_game:
|
||||
# Update inning half
|
||||
if self.current_game["inning_half"] == "top":
|
||||
self.current_game["inning_half"] = "bottom"
|
||||
else:
|
||||
self.current_game["inning_half"] = "top"
|
||||
self.current_game["inning"] += 1
|
||||
|
||||
# Update count
|
||||
self.current_game["balls"] = (self.current_game["balls"] + 1) % 4
|
||||
self.current_game["strikes"] = (self.current_game["strikes"] + 1) % 3
|
||||
|
||||
# Update outs
|
||||
self.current_game["outs"] = (self.current_game["outs"] + 1) % 3
|
||||
|
||||
# Update bases
|
||||
self.current_game["bases_occupied"] = [
|
||||
not self.current_game["bases_occupied"][0],
|
||||
not self.current_game["bases_occupied"][1],
|
||||
not self.current_game["bases_occupied"][2]
|
||||
]
|
||||
|
||||
# Update score occasionally
|
||||
if self.current_game["inning"] % 2 == 0:
|
||||
self.current_game["home_score"] = str(int(self.current_game["home_score"]) + 1)
|
||||
else:
|
||||
self.current_game["away_score"] = str(int(self.current_game["away_score"]) + 1)
|
||||
else:
|
||||
# Fetch live game data from MLB API
|
||||
games = self._fetch_mlb_api_data()
|
||||
if games:
|
||||
|
||||
Reference in New Issue
Block a user