Skip to content

Commit 8c93437

Browse files
authored
Merge pull request #1714 from LmeSzinc/bug_fix
Bug fix
2 parents ae4d5c5 + 81504cb commit 8c93437

4 files changed

Lines changed: 59 additions & 9 deletions

File tree

module/os_ash/meta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def _ensure_meta_level(self):
441441

442442
def _in_meta_assist_page(self):
443443
# AL redirects to unfinished self beacon after assist, so switch back
444-
if self.appear_then_click(BEACON_LIST, offset=(-20, -5, 300, 5)):
444+
if self.appear_then_click(BEACON_LIST, offset=(-20, -5, 300, 5), interval=2):
445445
return False
446446
return self.appear(BEACON_MY, offset=(20, 20))
447447

module/shop/base.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from module.base.decorator import cached_property
66
from module.base.filter import Filter
77
from module.base.timer import Timer
8+
from module.combat.assets import GET_ITEMS_1, GET_SHIP
89
from module.exception import ScriptError
910
from module.logger import logger
1011
from module.shop.assets import *
@@ -161,6 +162,23 @@ def shop_detect_items(self, image=None):
161162
logger.info('No shop items found')
162163
return []
163164

165+
def shop_obstruct_handle(self):
166+
"""
167+
Remove obstructions in shop view if any
168+
169+
Returns:
170+
bool:
171+
"""
172+
# Handle shop obstructions
173+
if self.appear(GET_SHIP, interval=1):
174+
self.device.click(SHOP_CLICK_SAFE_AREA)
175+
return True
176+
if self.appear(GET_ITEMS_1, interval=1):
177+
self.device.click(SHOP_CLICK_SAFE_AREA)
178+
return True
179+
180+
return False
181+
164182
def shop_get_items(self, skip_first_screenshot=True):
165183
"""
166184
Args:
@@ -186,6 +204,10 @@ def shop_get_items(self, skip_first_screenshot=True):
186204
else:
187205
self.device.screenshot()
188206

207+
if self.shop_obstruct_handle():
208+
timeout.reset()
209+
continue
210+
189211
shop_items.predict(
190212
self.device.image,
191213
name=True,

module/shop/clerk.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import cv2
22

33
from module.base.timer import Timer
4-
from module.combat.assets import GET_ITEMS_1, GET_SHIP
54
from module.exception import ScriptError
65
from module.logger import logger
76
from module.ocr.ocr import Digit, DigitCounter
@@ -265,19 +264,14 @@ def shop_buy_execute(self, item, skip_first_screenshot=True):
265264
if self.shop_buy_handle(item):
266265
self.interval_reset(BACK_ARROW)
267266
continue
268-
if self.appear(GET_SHIP, interval=1):
269-
self.device.click(SHOP_CLICK_SAFE_AREA)
270-
self.interval_reset(BACK_ARROW)
271-
continue
272267
if self.handle_retirement():
273268
self.interval_reset(BACK_ARROW)
274269
continue
275-
if self.appear(GET_ITEMS_1, interval=1):
276-
self.device.click(SHOP_CLICK_SAFE_AREA)
270+
if self.handle_info_bar():
277271
self.interval_reset(BACK_ARROW)
278272
success = True
279273
continue
280-
if self.handle_info_bar():
274+
if self.shop_obstruct_handle():
281275
self.interval_reset(BACK_ARROW)
282276
success = True
283277
continue

module/ui/navbar.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from module.base.base import ModuleBase
22
from module.base.button import ButtonGrid
33
from module.base.timer import Timer
4+
from module.combat.assets import GET_ITEMS_1, GET_SHIP
45
from module.logger import logger
6+
from module.shop.assets import SHOP_CLICK_SAFE_AREA
57

68

79
class Navbar:
@@ -85,6 +87,33 @@ def get_total(self, main):
8587
_, left, right = self.get_info(main=main)
8688
return right - left + 1
8789

90+
def _shop_obstruct_handle(self, main):
91+
"""
92+
IFF in shop, then remove obstructions
93+
in shop view if any
94+
95+
Args:
96+
main (ModuleBase):
97+
98+
Returns:
99+
bool:
100+
"""
101+
# Check name, identifies if NavBar
102+
# instance belongs to shop module
103+
if self.name != 'SHOP_BOTTOM_NAVBAR':
104+
return False
105+
106+
# Handle shop obstructions
107+
if main.appear(GET_SHIP, interval=1):
108+
main.device.click(SHOP_CLICK_SAFE_AREA)
109+
return True
110+
if main.appear(GET_ITEMS_1, interval=1):
111+
main.device.click(SHOP_CLICK_SAFE_AREA)
112+
return True
113+
114+
return False
115+
116+
88117
def set(self, main, left=None, right=None, upper=None, bottom=None, skip_first_screenshot=True):
89118
"""
90119
Set nav bar from 1 direction.
@@ -125,6 +154,11 @@ def set(self, main, left=None, right=None, upper=None, bottom=None, skip_first_s
125154
logger.warning(f'{self.name} failed to set {text.strip()}')
126155
return False
127156

157+
if self._shop_obstruct_handle():
158+
interval.reset()
159+
timeout.reset()
160+
continue
161+
128162
active, minimum, maximum = self.get_info(main=main)
129163
logger.info(f'Nav item active: {active} from range ({minimum}, {maximum})')
130164
# if active is None:

0 commit comments

Comments
 (0)