fixed some blocking bugs in startleague
This commit is contained in:
parent
5826574a1d
commit
da8607e295
|
@ -72,34 +72,20 @@ def init_league_db(league):
|
||||||
for pitcher in team.rotation:
|
for pitcher in team.rotation:
|
||||||
c.execute(player_string, (pitcher.name, team.name))
|
c.execute(player_string, (pitcher.name, team.name))
|
||||||
|
|
||||||
state_dic = {
|
|
||||||
"day" : league.day,
|
|
||||||
"schedule" : league.schedule,
|
|
||||||
"game_length" : league.game_length,
|
|
||||||
"series_length" : league.series_length,
|
|
||||||
"games_per_hour" : league.games_per_hour,
|
|
||||||
"owner" : None,
|
|
||||||
"historic" : False
|
|
||||||
}
|
|
||||||
if not os.path.exists(os.path.dirname(os.path.join(data_dir, league_dir, league.name, f"{league.name}.state"))):
|
|
||||||
os.makedirs(os.path.dirname(os.path.join(data_dir, league_dir, league.name, f"{league.name}.state")))
|
|
||||||
with open(os.path.join(data_dir, league_dir, league.name, f"{league.name}.state"), "w") as state_file:
|
|
||||||
json.dump(state_dic, state_file, indent=4)
|
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
def save_league(league):
|
def save_league(league):
|
||||||
if league_exists(league.name):
|
if league_exists(league.name):
|
||||||
state_dic = {
|
state_dic = {
|
||||||
|
"season" : league.season,
|
||||||
"day" : league.day,
|
"day" : league.day,
|
||||||
"schedule" : league.schedule,
|
"schedule" : league.schedule,
|
||||||
"game_length" : league.game_length,
|
"game_length" : league.game_length,
|
||||||
"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,
|
||||||
"historic" : league.historic,
|
"historic" : league.historic
|
||||||
"season" : league.season
|
|
||||||
}
|
}
|
||||||
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:
|
||||||
json.dump(state_dic, state_file, indent=4)
|
json.dump(state_dic, state_file, indent=4)
|
||||||
|
|
|
@ -315,9 +315,7 @@ def save_league(this_league):
|
||||||
with open(os.path.join(data_dir, league_dir, this_league.name, f"{this_league.name}.league"), "w") as league_file:
|
with open(os.path.join(data_dir, league_dir, this_league.name, f"{this_league.name}.league"), "w") as league_file:
|
||||||
league_json_string = jsonpickle.encode(this_league.league, keys=True)
|
league_json_string = jsonpickle.encode(this_league.league, keys=True)
|
||||||
json.dump(league_json_string, league_file, indent=4)
|
json.dump(league_json_string, league_file, indent=4)
|
||||||
return True
|
league_db.save_league(this_league)
|
||||||
else:
|
|
||||||
league_db.save_league(this_league)
|
|
||||||
|
|
||||||
def load_league_file(league_name):
|
def load_league_file(league_name):
|
||||||
if league_db.league_exists(league_name):
|
if league_db.league_exists(league_name):
|
||||||
|
|
|
@ -759,14 +759,14 @@ class StartLeagueCommand(Command):
|
||||||
Plays a league with a given name, provided that league has been saved on the website."""
|
Plays a league with a given name, provided that league has been saved on the website."""
|
||||||
|
|
||||||
async def execute(self, msg, command):
|
async def execute(self, msg, command):
|
||||||
league_name = command.split("-").strip()
|
league_name = command.split("-")[0].strip()
|
||||||
autoplay = None
|
autoplay = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if "--queue " in command:
|
if "--queue " in command:
|
||||||
autoplay = int(command.split("--queue ")[1])
|
autoplay = int(command.split("--queue ")[1])
|
||||||
elif "-q " in command:
|
elif "-q " in command:
|
||||||
autoplay = int(command.split("--queue ")[1])
|
autoplay = int(command.split("-q ")[1])
|
||||||
if autoplay is not None and autoplay <= 0:
|
if autoplay is not None and autoplay <= 0:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
elif autoplay is None:
|
elif autoplay is None:
|
||||||
|
@ -808,6 +808,7 @@ commands = [
|
||||||
SearchTeamsCommand(),
|
SearchTeamsCommand(),
|
||||||
StartGameCommand(),
|
StartGameCommand(),
|
||||||
StartTournamentCommand(),
|
StartTournamentCommand(),
|
||||||
|
StartLeagueCommand(),
|
||||||
StartRandomGameCommand(),
|
StartRandomGameCommand(),
|
||||||
CreditCommand(),
|
CreditCommand(),
|
||||||
RomanCommand(),
|
RomanCommand(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user