-
Notifications
You must be signed in to change notification settings - Fork 0
/
myteam.py
66 lines (55 loc) · 2.35 KB
/
myteam.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from espn_api.football import Team as ESPNTeam
from myboxscore import MyBoxScore
class MyTeam(ESPNTeam):
def build_boxscore(self,box_scores):
if not hasattr(self, 'boxscores'):
self.boxscores = list()
for game in box_scores:
if game.home_team == 0:
if game.away_team.team_id == self.team_id:
self.boxscores.append(MyBoxScore(game,'away','BYE'))
break
if game.away_team == 0:
if game.home_team.team_id == self.team_id:
self.boxscores.append(MyBoxScore(game,'home','BYE'))
break
if game.home_team and game.away_team:
if game.home_team.team_id == self.team_id:
self.boxscores.append(MyBoxScore(game,'home'))
break
if game.away_team.team_id == self.team_id:
self.boxscores.append(MyBoxScore(game,'away'))
break
def get_season_points(self,week):
season_points = 0
season_points = sum(boxscore.points for boxscore in self.boxscores[:week])
return season_points
def get_season_points_against(self,week):
season_points_against = 0
season_points_against = sum(boxscore.opponent_points for boxscore in self.boxscores[:week])
return season_points_against
def get_wins(self,week):
wins = 0
for boxscore in self.boxscores[:week]:
wins += 1 if boxscore.points > boxscore.opponent_points else 0
return wins
def get_losses(self,week):
losses = 0
for boxscore in self.boxscores[:week]:
losses += 1 if boxscore.points < boxscore.opponent_points else 0
return losses
def get_ties(self,week):
ties = 0
for boxscore in self.boxscores[:week]:
ties += 1 if boxscore.points == boxscore.opponent_points else 0
return ties
def top_player(self,week):
return self.boxscores[week - 1].top_player
def bottom_player(self,week):
return self.boxscores[week - 1].bottom_player
def overachiever(self,week):
return self.boxscores[week - 1].overachiever
def underachiever(self,week):
return self.boxscores[week - 1].underachiever
def goose_eggs(self,week):
return self.boxscores[week - 1].goose_eggs