From 422707638c532cc7b35caa724d6612f11f7b40ff Mon Sep 17 00:00:00 2001 From: Sakimori Date: Mon, 22 Feb 2021 22:36:41 -0500 Subject: [PATCH 1/3] fixed bug involving non alphanumeric characters --- database.py | 26 ++++++++++++++------------ main_controller.py | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/database.py b/database.py index 8e5df7e..9bb8e0c 100644 --- a/database.py +++ b/database.py @@ -374,21 +374,23 @@ def save_obl_results(winning_team, losing_team): conn = create_connection() if conn is not None: c=conn.cursor() - c.execute("SELECT teams_beaten_list, current_opponent_pool, obl_points FROM one_big_league WHERE team_name = ?", (winning_team.name,)) try: + c.execute("SELECT teams_beaten_list, current_opponent_pool, obl_points FROM one_big_league WHERE team_name = ?", (winning_team.name,)) beaten_string, opponents_string, obl_points = c.fetchone() - except TypeError: #add team to OBL - add_team_obl(winning_team) - add_team_obl(losing_team) - else: - beaten_teams = newline_string_to_list(beaten_string) - opponent_teams = newline_string_to_list(opponents_string) - if losing_team.name in opponent_teams: - beaten_teams.append(losing_team.name) - opponent_teams = sample(get_filtered_teams([winning_team.name]), 5) - obl_points += 1 + except: + return - c.execute("UPDATE one_big_league SET teams_beaten_list = ?, current_opponent_pool = ?, obl_points = ? WHERE team_name = ?", (list_to_newline_string(beaten_teams), list_to_newline_string(opponent_teams), obl_points, winning_team.name)) + beaten_teams = newline_string_to_list(beaten_string) + opponent_teams = newline_string_to_list(opponents_string) + if re.sub('[^A-Za-z0-9 %]+', '', losing_team.name) in opponent_teams: + beaten_teams.append(losing_team.name) + try: + opponent_teams = sample(get_filtered_teams([re.sub('[^A-Za-z0-9 %]+', '', winning_team.name)]), 5) + except ValueError: + opponent_teams = get_filtered_teams([re.sub('[^A-Za-z0-9 %]+', '', winning_team.name)]) + obl_points += 1 + + c.execute("UPDATE one_big_league SET teams_beaten_list = ?, current_opponent_pool = ?, obl_points = ? WHERE team_name = ?", (list_to_newline_string(beaten_teams), list_to_newline_string(opponent_teams), obl_points, winning_team.name)) conn.commit() conn.close() diff --git a/main_controller.py b/main_controller.py index ca693a2..7f5c17f 100644 --- a/main_controller.py +++ b/main_controller.py @@ -236,4 +236,4 @@ def update_loop(): state["update_pause"] -= 1 socketio.emit("states_update", game_states) - time.sleep(8) + time.sleep(1) From de71a70be52df2e92abfa15442b3b2aeb7204391 Mon Sep 17 00:00:00 2001 From: Sakimori Date: Mon, 22 Feb 2021 22:36:52 -0500 Subject: [PATCH 2/3] disabled turbo mode --- main_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main_controller.py b/main_controller.py index 7f5c17f..ca693a2 100644 --- a/main_controller.py +++ b/main_controller.py @@ -236,4 +236,4 @@ def update_loop(): state["update_pause"] -= 1 socketio.emit("states_update", game_states) - time.sleep(1) + time.sleep(8) From 1892eda74ccf3099fa8e27c8cd5490bfcaa1b5e9 Mon Sep 17 00:00:00 2001 From: Sakimori Date: Tue, 23 Feb 2021 00:23:36 -0500 Subject: [PATCH 3/3] added missing error handling to oblrival --- the_prestige.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/the_prestige.py b/the_prestige.py index e8a3626..6e2467d 100644 --- a/the_prestige.py +++ b/the_prestige.py @@ -1306,8 +1306,12 @@ class OBLSetRivalCommand(Command): description = "Sets your team's OBL rival. Can be changed at any time. Requires ownership." async def execute(self, msg, command): - team_i = get_team_fuzzy_search(command.split("\n")[1].strip()) - team_r = get_team_fuzzy_search(command.split("\n")[2].strip()) + try: + team_i = get_team_fuzzy_search(command.split("\n")[1].strip()) + team_r = get_team_fuzzy_search(command.split("\n")[2].strip()) + except IndexError: + await msg.channel.send("You didn't give us enough lines. Command on the top, your team in the middle, and your rival at the bottom.") + return team, owner_id = games.get_team_and_owner(team_i.name) if team is None or team_r is None: await msg.channel.send("Can't find one of those teams, boss. Typo?")