diff --git a/bot.py b/bot.py index e935f9c..ae1b4c2 100644 --- a/bot.py +++ b/bot.py @@ -93,6 +93,7 @@ def run(): max_val = 0 max_image_file = None max_coords = None + max_games_flag = False for image_file, img_template in template_images.items(): result = image_service.find_image(img_screenshot, img_template) if result: @@ -102,13 +103,19 @@ def run(): val, coords = 0, None # Update the maximum value and corresponding image file and coordinates if necessary - if val > max_val: + # if val > max_val: + if ('max_number_of_games_played_text.en.png' == image_file and val > 0.42): + max_val = val + max_image_file = image_file + max_coords = coords + max_games_flag = True + elif (val > max_val and not max_games_flag): max_val = val max_image_file = image_file max_coords = coords # Check if the maximum value is above a certain threshold - if max_val > 0.95: + if max_val > 0.90 or max_games_flag: logging.info(f"Image {max_image_file} matches with {max_val * 100}%") # If not ingame reset timer diff --git a/requirements.txt b/requirements.txt index d814dfa..13460b0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -numpy==1.24.1 +numpy==1.26.0 opencv-python==4.7.0.68 diff --git a/screenshot.py b/screenshot.py index b576311..aec47e2 100644 --- a/screenshot.py +++ b/screenshot.py @@ -1,4 +1,5 @@ import os +import platform def capture_screenshot(filename): @@ -6,6 +7,9 @@ def capture_screenshot(filename): Captures a screenshot of the Android screen using adb and saves it to a file. Returns True if the adb command was successful, False otherwise. """ - adb_command = "adb exec-out screencap -p > {} 2> /dev/null".format(filename) + if platform.system() == "Windows": + adb_command = "adb exec-out screencap -p > {}".format(filename) + else: + adb_command = "adb exec-out screencap -p > {} 2> /dev/null".format(filename) error_code = os.system(adb_command) return error_code == 0