diff --git a/scripts/client.py b/scripts/client.py index f4cc2fe..a151bc3 100644 --- a/scripts/client.py +++ b/scripts/client.py @@ -168,18 +168,12 @@ def handle_game_lobby(): sleep(3) def reconnect(): - log.info("Attempting to reconnect to live game.") - for i in range(15): - try: - utils.click(POPUP_SEND_EMAIL_X_RATIO, LEAGUE_CLIENT_WINNAME, 1) - sleep(1) - utils.click(CLIENT_RECONNECT_BUTTON, LEAGUE_CLIENT_WINNAME) - except: - pass - sleep(3) - if utils.exists(LEAGUE_GAME_CLIENT_WINNAME): + for i in range(3): + r = connection.request('post', '/lol-gameflow/v1/reconnect') + if r.status_code == 200: return - raise ClientError + sleep(2) + log.warning('Could not reconnect to game') # Often times disconnects will happen after a game finishes. The client will indefinitely return # the phase 'WaitingForStats' @@ -365,5 +359,5 @@ def get_account_level(): if r.status_code == 200: level = r.json()['lol']['level'] return int(level) + sleep(1) log.warning('Could not reach endpoint') - diff --git a/scripts/game.py b/scripts/game.py index 5fb789d..f9a7ce0 100644 --- a/scripts/game.py +++ b/scripts/game.py @@ -23,7 +23,7 @@ def play_game(): if get_game_data() == {}: connection_err += 1 - data = {} + data = get_game_data() connection_err = 0 while len(data) == 0: if connection_err == 10: @@ -31,7 +31,7 @@ def play_game(): close_game() sleep(10) return - sleep(1) + sleep(2) data = get_game_data() connection_err += 1 @@ -191,5 +191,5 @@ def get_game_data(): return {} def close_game(): - os.system(KILL_LEAGUE_CLIENT) + os.system(KILL_LEAGUE) sleep(5) \ No newline at end of file