|
1 | 1 | from module.base.base import ModuleBase |
2 | 2 | from module.base.button import ButtonGrid |
3 | 3 | from module.base.timer import Timer |
| 4 | +from module.combat.assets import GET_ITEMS_1, GET_SHIP |
4 | 5 | from module.logger import logger |
| 6 | +from module.shop.assets import SHOP_CLICK_SAFE_AREA |
5 | 7 |
|
6 | 8 |
|
7 | 9 | class Navbar: |
@@ -85,6 +87,33 @@ def get_total(self, main): |
85 | 87 | _, left, right = self.get_info(main=main) |
86 | 88 | return right - left + 1 |
87 | 89 |
|
| 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 | + |
88 | 117 | def set(self, main, left=None, right=None, upper=None, bottom=None, skip_first_screenshot=True): |
89 | 118 | """ |
90 | 119 | 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 |
125 | 154 | logger.warning(f'{self.name} failed to set {text.strip()}') |
126 | 155 | return False |
127 | 156 |
|
| 157 | + if self._shop_obstruct_handle(): |
| 158 | + interval.reset() |
| 159 | + timeout.reset() |
| 160 | + continue |
| 161 | + |
128 | 162 | active, minimum, maximum = self.get_info(main=main) |
129 | 163 | logger.info(f'Nav item active: {active} from range ({minimum}, {maximum})') |
130 | 164 | # if active is None: |
|
0 commit comments