[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added top half perc command and updated readme #2

Merged
merged 3 commits into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
initial work for top half percentage stat
  • Loading branch information
coolbrett committed Jan 13, 2023
commit dc2cbfe04edc3275904dd737037ba2c9bdc27dad
2 changes: 0 additions & 2 deletions LeagueData.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ def get_lineup_for_team(self, team_id: int, week: int = None, year: int = None)
return box_score.away_lineup

def get_team_by_abbreviation(self, team_abbreviation: str) -> Team:
print(f"Abbreviation received: {team_abbreviation}")
for team in self.league.teams:
print(f"loop: {team.team_abbrev}")
if team.team_abbrev.casefold() == team_abbreviation.casefold():
print(f"Returning: {team.team_name}")
return team
28 changes: 27 additions & 1 deletion tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def main():
#get_top_scorer(league_data=league_data)
#get_box_scores_and_matchups_of_week(league_data=league_data, week=11)
#league_data.league.scoreboard(matchupPeriod=1)
get_list_of_all_players_rostered(league_data=league_data)
#get_list_of_all_players_rostered(league_data=league_data)
get_top_half_percentage_for_each_team(league_data=league_data)
return

def get_standings(league_data: LeagueData) -> dict:
Expand Down Expand Up @@ -111,5 +112,30 @@ def get_list_of_all_players_rostered(league_data: LeagueData) -> list:
"""
return rostered_players

def get_top_half_percentage_for_each_team(league_data: LeagueData):
rostered_players = get_list_of_all_players_rostered(league_data=league_data)
rostered_players = rostered_players[0:int(len(rostered_players)/2)]
top_half_player_percentages_by_team = dict()
perc = float(1/len(rostered_players))

for roster_player in rostered_players:
for team in league_data.league.teams:
for team_player in team.roster:
if team_player.playerId == roster_player.playerId:
if team.team_id in top_half_player_percentages_by_team.keys():
top_half_player_percentages_by_team[team.team_id] += perc
else:
top_half_player_percentages_by_team.__setitem__(team.team_id, perc)


print("here")
total = 0
for team_id, perc in top_half_player_percentages_by_team.items():
perc = float("%.3f" % perc)
total += perc
percantage = perc * 100
percantage = float("%.3f" % percantage)
print(f"{team_id}:\t\t{percantage}%")
print(f"total: {total}")

main()