Fix game recovery (#88)
* drive by fix, discord config bug * drive by fix for game recovery * add info screenshot * fix game recovery?
This commit is contained in:
@@ -27,12 +27,12 @@ class GameRecovery:
|
||||
return self._ui_manager.save_and_exit()
|
||||
# we must be ingame, but maybe we are at vendor or on stash, press "esc" until we find a save and exit btn (max 5 times)
|
||||
for _ in range(5):
|
||||
keyboard.press("esc")
|
||||
keyboard.send("esc")
|
||||
time.sleep(1)
|
||||
templates = ["SAVE_AND_EXIT_NO_HIGHLIGHT","SAVE_AND_EXIT_HIGHLIGHT"]
|
||||
found, _ = self._template_finder.search_and_wait(templates, roi=self._config.ui_roi["save_and_exit"], time_out=1.5, take_ss=False)
|
||||
if found:
|
||||
keyboard.press("esc")
|
||||
keyboard.send("esc")
|
||||
time.sleep(1)
|
||||
return self._ui_manager.save_and_exit()
|
||||
return False
|
||||
|
||||
@@ -12,6 +12,7 @@ import threading
|
||||
from beautifultable import BeautifulTable
|
||||
import time
|
||||
import logging
|
||||
import cv2
|
||||
|
||||
|
||||
def run_bot(config: Config):
|
||||
@@ -27,14 +28,15 @@ def run_bot(config: Config):
|
||||
Logger.info(f"Max game length reached. Attempting to restart {config.general['name']}!")
|
||||
bot.stop()
|
||||
kill_thread(bot_thread)
|
||||
if game_recovery.go_to_hero_selection():
|
||||
do_restart = False
|
||||
do_restart = game_recovery.go_to_hero_selection()
|
||||
break
|
||||
time.sleep(0.04)
|
||||
time.sleep(0.5)
|
||||
bot_thread.join()
|
||||
if do_restart:
|
||||
run_bot(config)
|
||||
else:
|
||||
if config.general["info_screenshots"]:
|
||||
cv2.imwrite("./info_screenshots/info_could_not_recover_" + time.strftime("%Y%m%d_%H%M%S") + ".png", bot._screen.grab())
|
||||
Logger.error(f"{config.general['name']} could not recover from a max game length violation. Shutting down everything.")
|
||||
if config.general["custom_discord_hook"]:
|
||||
send_discord(f"{config.general['name']} got stuck and can not resume", config.general["custom_discord_hook"])
|
||||
|
||||
@@ -377,8 +377,8 @@ class UiManager():
|
||||
self._curr_stash += 1
|
||||
if self._curr_stash > 3:
|
||||
Logger.error("All stash is full, quitting")
|
||||
if config.general["custom_discord_hook"]:
|
||||
send_discord(f"{config.general['name']} all stash is full, quitting", config.general["custom_discord_hook"])
|
||||
if self._config.general["custom_discord_hook"]:
|
||||
send_discord(f"{self._config.general['name']} all stash is full, quitting", self._config.general["custom_discord_hook"])
|
||||
os._exit(1)
|
||||
else:
|
||||
# move to next stash
|
||||
|
||||
Reference in New Issue
Block a user