Skip to content

Commit d63a03e

Browse files
committed
Fix: Strategy search settings exited accidentally
1 parent a6bb4ba commit d63a03e

1 file changed

Lines changed: 33 additions & 6 deletions

File tree

module/os_handler/strategic.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def strategy_search_enter(self, skip_first_screenshot=False):
2727
self.device.click(STRATEGIC_SEARCH_MAP_OPTION_OFF)
2828
continue
2929

30-
def strategic_search_set_option(self, skip_first_screenshot=False):
31-
logger.info('Strategic search set option')
30+
def strategic_search_set_tab(self, skip_first_screenshot=False):
31+
logger.info('Strategic search set tab')
3232
while 1:
3333
if skip_first_screenshot:
3434
skip_first_screenshot = False
@@ -39,9 +39,17 @@ def strategic_search_set_option(self, skip_first_screenshot=False):
3939
self.device.click(STRATEGIC_SEARCH_TAB_SECURED)
4040
continue
4141
if get_color(self.device.image, STRATEGIC_SEARCH_TAB_SECURED.area)[2] > 150:
42-
skip_first_screenshot = True
4342
break
4443

44+
def strategic_search_set_option(self, skip_first_screenshot=True):
45+
"""
46+
Args:
47+
skip_first_screenshot:
48+
49+
Returns:
50+
If success. False if strategic settings closed for unknown reason.
51+
"""
52+
logger.info('Strategic search set option')
4553
while 1:
4654
if skip_first_screenshot:
4755
skip_first_screenshot = False
@@ -64,6 +72,9 @@ def strategic_search_set_option(self, skip_first_screenshot=False):
6472

6573
STRATEGIC_SEARCH_SCROLL.drag_threshold = 0.1
6674
STRATEGIC_SEARCH_SCROLL.set(0.5, main=self)
75+
if not STRATEGIC_SEARCH_SCROLL.appear(main=self):
76+
return False
77+
6778
while 1:
6879
if skip_first_screenshot:
6980
skip_first_screenshot = False
@@ -86,6 +97,9 @@ def strategic_search_set_option(self, skip_first_screenshot=False):
8697
STRATEGIC_SEARCH_SCROLL.drag_threshold = 0.05
8798
STRATEGIC_SEARCH_SCROLL.edge_add = (0.5, 0.8)
8899
STRATEGIC_SEARCH_SCROLL.set_bottom(main=self)
100+
if not STRATEGIC_SEARCH_SCROLL.appear(main=self):
101+
return False
102+
89103
while 1:
90104
if skip_first_screenshot:
91105
skip_first_screenshot = False
@@ -104,6 +118,8 @@ def strategic_search_set_option(self, skip_first_screenshot=False):
104118
logger.attr('auto_submit', 'on')
105119
break
106120

121+
return True
122+
107123
def strategic_search_confirm(self, skip_first_screenshot=False):
108124
logger.info('Strategic search confirm')
109125
while 1:
@@ -121,11 +137,22 @@ def strategic_search_confirm(self, skip_first_screenshot=False):
121137

122138
def strategic_search_start(self, skip_first_screenshot=False):
123139
"""
140+
Returns:
141+
If success.
142+
124143
Pages:
125144
in: IN_MAP
126145
out: IN_MAP, with strategic search running
127146
"""
128147
logger.hr('Strategic search start')
129-
self.strategy_search_enter(skip_first_screenshot=skip_first_screenshot)
130-
self.strategic_search_set_option(skip_first_screenshot=True)
131-
self.strategic_search_confirm(skip_first_screenshot=True)
148+
for _ in range(3):
149+
self.strategy_search_enter(skip_first_screenshot=skip_first_screenshot)
150+
self.strategic_search_set_tab(skip_first_screenshot=True)
151+
success = self.strategic_search_set_option(skip_first_screenshot=True)
152+
if not success:
153+
continue
154+
self.strategic_search_confirm(skip_first_screenshot=True)
155+
return True
156+
157+
logger.warning('Failed to start strategic search')
158+
return False

0 commit comments

Comments
 (0)