Fix: Strategy search settings exited accidentally

This commit is contained in:
LmeSzinc 2023-05-30 23:48:21 +08:00
parent a6bb4ba7f8
commit d63a03ed6d

View File

@ -27,8 +27,8 @@ class StrategicSearchHandler(MapEventHandler):
self.device.click(STRATEGIC_SEARCH_MAP_OPTION_OFF)
continue
def strategic_search_set_option(self, skip_first_screenshot=False):
logger.info('Strategic search set option')
def strategic_search_set_tab(self, skip_first_screenshot=False):
logger.info('Strategic search set tab')
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
@ -39,9 +39,17 @@ class StrategicSearchHandler(MapEventHandler):
self.device.click(STRATEGIC_SEARCH_TAB_SECURED)
continue
if get_color(self.device.image, STRATEGIC_SEARCH_TAB_SECURED.area)[2] > 150:
skip_first_screenshot = True
break
def strategic_search_set_option(self, skip_first_screenshot=True):
"""
Args:
skip_first_screenshot:
Returns:
If success. False if strategic settings closed for unknown reason.
"""
logger.info('Strategic search set option')
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
@ -64,6 +72,9 @@ class StrategicSearchHandler(MapEventHandler):
STRATEGIC_SEARCH_SCROLL.drag_threshold = 0.1
STRATEGIC_SEARCH_SCROLL.set(0.5, main=self)
if not STRATEGIC_SEARCH_SCROLL.appear(main=self):
return False
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
@ -86,6 +97,9 @@ class StrategicSearchHandler(MapEventHandler):
STRATEGIC_SEARCH_SCROLL.drag_threshold = 0.05
STRATEGIC_SEARCH_SCROLL.edge_add = (0.5, 0.8)
STRATEGIC_SEARCH_SCROLL.set_bottom(main=self)
if not STRATEGIC_SEARCH_SCROLL.appear(main=self):
return False
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
@ -104,6 +118,8 @@ class StrategicSearchHandler(MapEventHandler):
logger.attr('auto_submit', 'on')
break
return True
def strategic_search_confirm(self, skip_first_screenshot=False):
logger.info('Strategic search confirm')
while 1:
@ -121,11 +137,22 @@ class StrategicSearchHandler(MapEventHandler):
def strategic_search_start(self, skip_first_screenshot=False):
"""
Returns:
If success.
Pages:
in: IN_MAP
out: IN_MAP, with strategic search running
"""
logger.hr('Strategic search start')
self.strategy_search_enter(skip_first_screenshot=skip_first_screenshot)
self.strategic_search_set_option(skip_first_screenshot=True)
self.strategic_search_confirm(skip_first_screenshot=True)
for _ in range(3):
self.strategy_search_enter(skip_first_screenshot=skip_first_screenshot)
self.strategic_search_set_tab(skip_first_screenshot=True)
success = self.strategic_search_set_option(skip_first_screenshot=True)
if not success:
continue
self.strategic_search_confirm(skip_first_screenshot=True)
return True
logger.warning('Failed to start strategic search')
return False