Skip to content

Commit

Permalink
#8 and #13 logic update
Browse files Browse the repository at this point in the history
  • Loading branch information
iholston committed May 25, 2023
1 parent 8e07d04 commit 22022f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
18 changes: 6 additions & 12 deletions scripts/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')

6 changes: 3 additions & 3 deletions scripts/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ 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:
log.warning("Window open but cannot connect to game.")
close_game()
sleep(10)
return
sleep(1)
sleep(2)
data = get_game_data()
connection_err += 1

Expand Down Expand Up @@ -191,5 +191,5 @@ def get_game_data():
return {}

def close_game():
os.system(KILL_LEAGUE_CLIENT)
os.system(KILL_LEAGUE)
sleep(5)

0 comments on commit 22022f3

Please sign in to comment.