started recording season champions

This commit is contained in:
Sakimori 2021-01-15 05:12:55 -05:00
parent 016bc2ed24
commit 3d2df59ca1
3 changed files with 7 additions and 0 deletions

View File

@ -87,6 +87,7 @@ def save_league(league):
"series_length" : league.series_length, "series_length" : league.series_length,
"games_per_hour" : league.games_per_hour, "games_per_hour" : league.games_per_hour,
"owner" : league.owner, "owner" : league.owner,
"champions" : league.champions,
"historic" : league.historic "historic" : league.historic
} }
with open(os.path.join(data_dir, league_dir, league.name, f"{league.name}.state"), "w") as state_file: with open(os.path.join(data_dir, league_dir, league.name, f"{league.name}.state"), "w") as state_file:

View File

@ -14,6 +14,7 @@ class league_structure(object):
self.owner = None self.owner = None
self.season = 1 self.season = 1
self.autoplay = -1 self.autoplay = -1
self.champions = {}
def setup(self, league_dic, division_games = 1, inter_division_games = 1, inter_league_games = 1, games_per_hour = 2): def setup(self, league_dic, division_games = 1, inter_division_games = 1, inter_league_games = 1, games_per_hour = 2):
self.league = league_dic # { subleague name : { division name : [team object] } } self.league = league_dic # { subleague name : { division name : [team object] } }
@ -460,4 +461,8 @@ def load_league_file(league_name):
this_league.games_per_hour = state_dic["games_per_hour"] this_league.games_per_hour = state_dic["games_per_hour"]
this_league.historic = state_dic["historic"] this_league.historic = state_dic["historic"]
this_league.season = state_dic["season"] this_league.season = state_dic["season"]
try:
this_league.champions = state_dic["champions"]
except:
this_league.champions = {}
return this_league return this_league

View File

@ -1914,6 +1914,7 @@ async def league_postseason(channel, league):
await channel.send(f"The {league.name} Championship Series is starting in {math.ceil(wait_seconds/60)} minutes!") await channel.send(f"The {league.name} Championship Series is starting in {math.ceil(wait_seconds/60)} minutes!")
await asyncio.sleep(wait_seconds) await asyncio.sleep(wait_seconds)
await start_tournament_round(channel, world_series) await start_tournament_round(channel, world_series)
league.champions[str(league.season)] = world_series.winner.name