Skip to content

Commit

Permalink
Merge pull request #308 from cwendt94/FB_UpdateTeamOutComes
Browse files Browse the repository at this point in the history
Football Team Outcomes to W/L/U
  • Loading branch information
cwendt94 authored Jan 7, 2022
2 parents 6db1e03 + b08710d commit df29340
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions espn_api/football/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,30 @@ def _fetch_schedule(self, data):
if matchup['away']['teamId'] == self.team_id:
score = matchup['away']['totalPoints']
opponentId = matchup['home']['teamId']
self.outcomes.append(matchup['winner'])
self.outcomes.append(self._get_winner(matchup['winner'], True))
self.scores.append(score)
self.schedule.append(opponentId)
elif matchup['home']['teamId'] == self.team_id:
score = matchup['home']['totalPoints']
opponentId = matchup['away']['teamId']
self.outcomes.append(matchup['winner'])
self.outcomes.append(self._get_winner(matchup['winner'], False))
self.scores.append(score)
self.schedule.append(opponentId)
elif matchup['home']['teamId'] == self.team_id:
score = matchup['home']['totalPoints']
opponentId = matchup['home']['teamId']
self.outcomes.append(matchup['winner'])
self.outcomes.append(self._get_winner(matchup['winner'], False))
self.scores.append(score)
self.schedule.append(opponentId)

def _get_winner(self, winner: str, is_away: bool) -> str:
if winner == 'UNDECIDED':
return 'U'
elif (is_away and winner == 'AWAY') or (not is_away and winner == 'HOME'):
return 'W'
else:
return 'L'

def get_player_name(self, playerId: int) -> str:
for player in self.roster:
if player.playerId == playerId:
Expand Down

0 comments on commit df29340

Please sign in to comment.