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:
 | 
			
		||||
                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.close()
 | 
			
		||||
 | 
			
		||||
def save_league(league):
 | 
			
		||||
    if league_exists(league.name):
 | 
			
		||||
        state_dic = {
 | 
			
		||||
                "season" : league.season,
 | 
			
		||||
                "day" : league.day,
 | 
			
		||||
                "schedule" : league.schedule,
 | 
			
		||||
                "game_length" : league.game_length,
 | 
			
		||||
                "series_length" : league.series_length,
 | 
			
		||||
                "games_per_hour" : league.games_per_hour,
 | 
			
		||||
                "owner" : league.owner,
 | 
			
		||||
                "historic" : league.historic,
 | 
			
		||||
                "season" : league.season
 | 
			
		||||
                "historic" : league.historic               
 | 
			
		||||
            }
 | 
			
		||||
        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)
 | 
			
		||||
 | 
			
		||||
@ -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:
 | 
			
		||||
            league_json_string = jsonpickle.encode(this_league.league, keys=True)
 | 
			
		||||
            json.dump(league_json_string, league_file, indent=4)
 | 
			
		||||
        return True
 | 
			
		||||
    else:
 | 
			
		||||
        league_db.save_league(this_league)
 | 
			
		||||
    league_db.save_league(this_league)
 | 
			
		||||
 | 
			
		||||
def load_league_file(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."""
 | 
			
		||||
 | 
			
		||||
    async def execute(self, msg, command):
 | 
			
		||||
        league_name = command.split("-").strip()
 | 
			
		||||
        league_name = command.split("-")[0].strip()
 | 
			
		||||
        autoplay = None
 | 
			
		||||
 | 
			
		||||
        try:
 | 
			
		||||
            if "--queue " in command:
 | 
			
		||||
                autoplay = int(command.split("--queue ")[1])
 | 
			
		||||
            elif "-q " in command:
 | 
			
		||||
                autoplay = int(command.split("--queue ")[1])
 | 
			
		||||
                autoplay = int(command.split("-q ")[1])
 | 
			
		||||
            if autoplay is not None and autoplay <= 0:
 | 
			
		||||
                raise ValueError
 | 
			
		||||
            elif autoplay is None:
 | 
			
		||||
@ -808,6 +808,7 @@ commands = [
 | 
			
		||||
    SearchTeamsCommand(),
 | 
			
		||||
    StartGameCommand(),
 | 
			
		||||
    StartTournamentCommand(),
 | 
			
		||||
    StartLeagueCommand(),
 | 
			
		||||
    StartRandomGameCommand(),
 | 
			
		||||
    CreditCommand(),
 | 
			
		||||
    RomanCommand(),
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user