added standings to league object and began collecting them from prestige.py
This commit is contained in:
parent
31930aab63
commit
df09a2cf97
18
leagues.py
18
leagues.py
|
@ -10,13 +10,12 @@ import database as db
|
||||||
|
|
||||||
class league_structure(object):
|
class league_structure(object):
|
||||||
def __init__(self, name, league_dic, division_games = 1, inter_division_games = 1, inter_league_games = 1, games_per_hour = 2):
|
def __init__(self, name, league_dic, division_games = 1, inter_division_games = 1, inter_league_games = 1, games_per_hour = 2):
|
||||||
self.league = league_dic #key: subleague, value: {division, teams}
|
self.league = league_dic #key: subleague, value: {division : teams}
|
||||||
self.constraints = {
|
self.constraints = {
|
||||||
"division_games" : division_games,
|
"division_games" : division_games,
|
||||||
"inter_div_games" : inter_division_games,
|
"inter_div_games" : inter_division_games,
|
||||||
"inter_league_games" : inter_league_games
|
"inter_league_games" : inter_league_games
|
||||||
}
|
}
|
||||||
self.season_length = 0
|
|
||||||
self.day = 1
|
self.day = 1
|
||||||
self.name = name
|
self.name = name
|
||||||
self.schedule = {}
|
self.schedule = {}
|
||||||
|
@ -24,6 +23,14 @@ class league_structure(object):
|
||||||
self.game_length = None
|
self.game_length = None
|
||||||
self.active = False
|
self.active = False
|
||||||
self.games_per_hour = games_per_hour
|
self.games_per_hour = games_per_hour
|
||||||
|
self.standings = {}
|
||||||
|
|
||||||
|
for this_team in self.teams_in_league():
|
||||||
|
self.standings[this_team.name] = {
|
||||||
|
"wins" : 0,
|
||||||
|
"losses" : 0,
|
||||||
|
"run differential" : 0,
|
||||||
|
}
|
||||||
|
|
||||||
def last_series_check(self):
|
def last_series_check(self):
|
||||||
return day + 1 in self.schedule.keys()
|
return day + 1 in self.schedule.keys()
|
||||||
|
@ -125,7 +132,6 @@ class league_structure(object):
|
||||||
matchups.append([team_a, team_b])
|
matchups.append([team_a, team_b])
|
||||||
a_home != a_home
|
a_home != a_home
|
||||||
|
|
||||||
self.season_length = self.constraints["division_games"]*(division_max) + self.constraints["inter_div_games"] + self.constraints["inter_league_games"]
|
|
||||||
|
|
||||||
for subleague in self.league.keys():
|
for subleague in self.league.keys():
|
||||||
for division in self.league[subleague].values(): #generate round-robin matchups
|
for division in self.league[subleague].values(): #generate round-robin matchups
|
||||||
|
@ -168,14 +174,10 @@ class league_structure(object):
|
||||||
scheduled = True
|
scheduled = True
|
||||||
day += 1
|
day += 1
|
||||||
|
|
||||||
class division(object):
|
|
||||||
def __init__(self):
|
|
||||||
self.teams = {} #key: team object, value: {wins; rd (run diff)}
|
|
||||||
|
|
||||||
class tournament(object):
|
class tournament(object):
|
||||||
def __init__(self, name, team_dic, series_length = 5, finals_series_length = 7, max_innings = 9, id = None, secs_between_games = 300, secs_between_rounds = 600):
|
def __init__(self, name, team_dic, series_length = 5, finals_series_length = 7, max_innings = 9, id = None, secs_between_games = 300, secs_between_rounds = 600):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.teams = team_dic #same format as division, wins/losses will be used for seeding later
|
self.teams = team_dic #key: team object, value: wins
|
||||||
self.bracket = None
|
self.bracket = None
|
||||||
self.results = None
|
self.results = None
|
||||||
self.series_length = series_length
|
self.series_length = series_length
|
||||||
|
|
|
@ -1444,9 +1444,14 @@ async def league_day_watcher(channel, league, games_list, filter_url, last = Fal
|
||||||
|
|
||||||
winner_name = game.teams['home'].name if game.teams['home'].score > game.teams['away'].score else game.teams['away'].name
|
winner_name = game.teams['home'].name if game.teams['home'].score > game.teams['away'].score else game.teams['away'].name
|
||||||
loser_name = game.teams['away'].name if game.teams['home'].score > game.teams['away'].score else game.teams['home'].name
|
loser_name = game.teams['away'].name if game.teams['home'].score > game.teams['away'].score else game.teams['home'].name
|
||||||
|
rd = int(math.fabs(game.teams['home'].score - game.teams['away'].score))
|
||||||
|
|
||||||
wins_in_series[winner_name] += 1
|
wins_in_series[winner_name] += 1
|
||||||
|
league.standings[winner_name]["wins"] += 1
|
||||||
|
league.standings[winner_name]["run differential"] += rd
|
||||||
losses_in_series[loser_name] += 1
|
losses_in_series[loser_name] += 1
|
||||||
|
league.standings[loser_name]["losses"] += 1
|
||||||
|
league.standings[loser_name]["run differential"] -= rd
|
||||||
|
|
||||||
final_embed = game_over_embed(game)
|
final_embed = game_over_embed(game)
|
||||||
await channel.send(f"A {league.name} game just ended!")
|
await channel.send(f"A {league.name} game just ended!")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user