From 1178c43d9a18db5dd26a5a2eb3cebeb75f9901a5 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Wed, 21 May 2025 03:01:58 +0800 Subject: [PATCH] Fix: Check strategy options with green tick instead of mean color (#4810) --- module/os_handler/strategic.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/module/os_handler/strategic.py b/module/os_handler/strategic.py index 07eb97aa1..c8c0cf1fd 100644 --- a/module/os_handler/strategic.py +++ b/module/os_handler/strategic.py @@ -63,6 +63,12 @@ class StrategicSearchHandler(MapEventHandler): logger.warning('STRATEGIC_SEARCH_SCROLL disappeared confirm') return False + def _strategy_option_selected(self, button): + """ + Check if a button is selected + """ + return self.image_color_count(button.button, color=(156, 255, 82), count=30) + def strategic_search_set_option(self, skip_first_screenshot=True): """ Args: @@ -78,10 +84,11 @@ class StrategicSearchHandler(MapEventHandler): else: self.device.screenshot() - if self.appear(STRATEGIC_SEARCH_ZONEMODE_RANDOM): + if self._strategy_option_selected(STRATEGIC_SEARCH_ZONEMODE_RANDOM): logger.attr('zone_mode', 'random') self.device.click(STRATEGIC_SEARCH_ZONEMODE_REPEAT) - if self.appear(STRATEGIC_SEARCH_MERCHANT_CONTINUE): + continue + if self._strategy_option_selected(STRATEGIC_SEARCH_MERCHANT_CONTINUE): logger.attr('encounter_merchant', 'continue') self.device.click(STRATEGIC_SEARCH_MERCHANT_STOP) continue @@ -107,11 +114,11 @@ class StrategicSearchHandler(MapEventHandler): STRATEGIC_SEARCH_DEVICE_STOP.load_offset(STRATEGIC_SEARCH_DEVICE_CHECK) STRATEGIC_SEARCH_DEVICE_CONTINUE.load_offset(STRATEGIC_SEARCH_DEVICE_CHECK) - if self.image_color_count(STRATEGIC_SEARCH_DEVICE_CONTINUE.button, color=(156, 255, 82), count=30): + if self._strategy_option_selected(STRATEGIC_SEARCH_DEVICE_CONTINUE): logger.attr('encounter_device', 'continue') self.device.click(STRATEGIC_SEARCH_DEVICE_STOP) continue - if self.image_color_count(STRATEGIC_SEARCH_DEVICE_STOP.button, color=(156, 255, 82), count=30): + if self._strategy_option_selected(STRATEGIC_SEARCH_DEVICE_STOP): logger.attr('encounter_device', 'stop') skip_first_screenshot = True break @@ -132,11 +139,11 @@ class StrategicSearchHandler(MapEventHandler): STRATEGIC_SEARCH_SUBMIT_OFF.load_offset(STRATEGIC_SEARCH_SUBMIT_CHECK) STRATEGIC_SEARCH_SUBMIT_ON.load_offset(STRATEGIC_SEARCH_SUBMIT_CHECK) - if self.image_color_count(STRATEGIC_SEARCH_SUBMIT_OFF.button, color=(156, 255, 82), count=30): + if self._strategy_option_selected(STRATEGIC_SEARCH_SUBMIT_OFF): logger.attr('auto_submit', 'off') self.device.click(STRATEGIC_SEARCH_SUBMIT_ON) continue - if self.image_color_count(STRATEGIC_SEARCH_SUBMIT_ON.button, color=(156, 255, 82), count=30): + if self._strategy_option_selected(STRATEGIC_SEARCH_SUBMIT_ON): logger.attr('auto_submit', 'on') break