async def test_stream(): async for event in stream_events(): payload = event print(payload) schedule = { g['id']: Game(g) for g in payload.get('games', {}).get('schedule') } print(schedule)
def load_results(self): if self.day == 1: return games = Game.load_by_day(self.season, self.day) for game in games.values(): self.updates.append( 'Welcome to Splorts Center. ' + f'{game.away_team_name} at {game.home_team_name}, game {game.series_index} of {game.series_length}. ' + f'The {game.winning_team_nickname} defeat the {game.losing_team_nickname} {game.winning_score} to {game.losing_score}.' ) for outcome in game.outcomes: self.updates.append('Welcome to Splorts Center. ' + outcome)
def get_game_outcomes(season, day): games = Game.load_by_day(season, day) games_all_ended = True in (game.finalized for uuid, game in games.items()) print(f'Processing Season {season} Day {day}') if not bool(games) and day != 1: return get_game_outcomes(season + 1, 1) elif bool(games) and (games_all_ended or season != 13): game_record['season'] = season game_record['day'] = day outcomes = [ get_wiki_template_string(game) for uuid, game in games.items() if len(game.outcomes) > 0 ] flat_outcomes = [item for sublist in outcomes for item in sublist] return get_game_outcomes(season, day + 1) + flat_outcomes else: return []
def __init__(self, data, parent): self._parent = parent self.games = {g['id']: Game(g) for g in data} self.fields = [g['id'] for g in data]
from blaseball_mike.models import Team from blaseball_mike.models import Game teams = Team.load_all() games = [] NUM_SEASONS = 14 for i in range(1, NUM_SEASONS + 1): games.append(Game.load_by_season(i)) print(len(games))