def get_last_ab( team_name ): overview = mlb_data.get_game_overview_dict(team_name) current_inning = overview['inning'] inning_state = overview['inning_state'].lower() events = mlb_data.get_game_events(team_name) last_event = events[current_inning][inning_state] if last_event == None: return "Nothing happened in this inning yet" return str(last_event[-1])
def get_game_time( team_name ): game_status = mlb_data.get_game_status(team_name) if game_status == "IN_PROGRESS": return "Game is in progress. Hurry up, you can still catch it" overview_dict = mlb_data.get_game_overview_dict(team_name) start_time = overview_dict['time'] time_zone = overview_dict['time_zone'] am_pm = overview_dict['ampm'] message = "Today's " + mlb_data.teams_dictionary[team_name] + " game will start at " + start_time + am_pm + " " + time_zone return message
def is_favorite_team_batting(): import mlb.mlb_data as mlb_data overview = mlb_data.get_game_overview_dict(full_name) inning_state = overview['inning_state'] if inning_state == 'Top' and is_favorite_team_at_home(): return False elif inning_state == 'Top' and not jays_at_home_eh: return False elif is_favorite_team_at_home(): return True
def get_team_record( team_name ): overview = mlb_data.get_game_overview_dict(team_name) if is_team_at_home(team_name): home_win = overview.get('home_win') home_loss = overview.get('home_loss') return mlb_data.teams_dictionary[team_name] + " are "+ home_win + "-" + home_loss else: away_win = overview.get('away_win') away_loss = overview.get('away_loss') return mlb_data.teams_dictionary[team_name] + " are "+ away_win + "-" + away_loss
def get_how_we_score( team_name ): overview = mlb_data.get_game_overview_dict(team_name) current_inning = overview['inning'] inning_state = overview['inning_state'].lower() scoring_plays = [] events = mlb_data.get_game_events(team_name) # print(events['1']['top'][0]) if is_team_at_home(team_name): for inning in events: for event in events[inning]['bottom']: if 'scores' in event.des: scoring_plays.append(event.des) else: for inning in events: for event in events[inning]['top']: if 'scores' in event.des or 'homers' in event.des: scoring_plays.append(event.des) last_3_scoring_plays = scoring_plays[-1:] return ''.join(last_3_scoring_plays)