1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-04-02 00:16:21 +08:00

Chore: equipment function names

This commit is contained in:
2025-10-18 03:36:35 +08:00
parent 1cd3a1f386
commit 90a7853560
8 changed files with 65 additions and 79 deletions

View File

@@ -26,7 +26,7 @@ class Equipment(StorageHandler):
if equipping_filter.set('on' if enable else 'off', main=self):
self.wait_until_stable(SWIPE_AREA)
def _equip_view_swipe(self, distance, check_button=EQUIPMENT_OPEN):
def _ship_view_swipe(self, distance, check_button=EQUIPMENT_OPEN):
swipe_count = 0
swipe_timer = Timer(5, count=10)
self.handle_info_bar()
@@ -37,7 +37,7 @@ class Equipment(StorageHandler):
if not swipe_timer.started() or swipe_timer.reached():
swipe_timer.reset()
self.device.swipe_vector(vector=(distance, 0), box=SWIPE_AREA.area, random_range=SWIPE_RANDOM_RANGE,
padding=0, duration=(0.1, 0.12), name='EQUIP_SWIPE')
padding=0, duration=(0.1, 0.12), name='SHIP_SWIPE')
# self.wait_until_appear(check_button, offset=(30, 30))
skip_first_screenshot = True
while 1:
@@ -48,7 +48,7 @@ class Equipment(StorageHandler):
if self.appear(check_button, offset=(30, 30)):
break
if self.appear(RETIRE_EQUIP_CONFIRM, offset=(30, 30)):
logger.info('RETIRE_EQUIP_CONFIRM popup in _equip_view_swipe()')
logger.info('RETIRE_EQUIP_CONFIRM popup in _ship_view_swipe()')
return False
# Popup when enhancing a NPC ship
if self.handle_popup_confirm('SHIP_VIEW_SWIPE'):
@@ -58,7 +58,7 @@ class Equipment(StorageHandler):
self.device.screenshot()
if self.appear(RETIRE_EQUIP_CONFIRM, offset=(30, 30)):
logger.info('RETIRE_EQUIP_CONFIRM popup in _equip_view_swipe()')
logger.info('RETIRE_EQUIP_CONFIRM popup in _ship_view_swipe()')
return False
if SWIPE_CHECK.match(self.device.image):
if swipe_count > 1:
@@ -70,13 +70,13 @@ class Equipment(StorageHandler):
logger.info('New ship detected on swipe')
return True
def equip_view_next(self, check_button=EQUIPMENT_OPEN):
return self._equip_view_swipe(distance=-SWIPE_DISTANCE, check_button=check_button)
def ship_view_next(self, check_button=EQUIPMENT_OPEN):
return self._ship_view_swipe(distance=-SWIPE_DISTANCE, check_button=check_button)
def equip_view_prev(self, check_button=EQUIPMENT_OPEN):
return self._equip_view_swipe(distance=SWIPE_DISTANCE, check_button=check_button)
def ship_view_prev(self, check_button=EQUIPMENT_OPEN):
return self._ship_view_swipe(distance=SWIPE_DISTANCE, check_button=check_button)
def equip_enter(self, click_button, check_button=EQUIPMENT_OPEN, long_click=True, skil_first_screenshot=True):
def ship_info_enter(self, click_button, check_button=EQUIPMENT_OPEN, long_click=True, skil_first_screenshot=True):
enter_timer = Timer(10)
while 1:
@@ -105,7 +105,7 @@ class Equipment(StorageHandler):
continue
@cached_property
def _equip_side_navbar(self):
def _ship_side_navbar(self):
"""
pry_sidebar 3 options
research.
@@ -125,14 +125,14 @@ class Equipment(StorageHandler):
equipment.
detail.
"""
equip_side_navbar = ButtonGrid(
origin=(21, 118), delta=(0, 94.5), button_shape=(60, 75), grid_shape=(1, 5), name='DETAIL_SIDE_NAVBAR')
ship_side_navbar = ButtonGrid(
origin=(21, 118), delta=(0, 94.5), button_shape=(60, 75), grid_shape=(1, 5), name='SHIP_SIDE_NAVBAR')
return Navbar(grids=equip_side_navbar,
return Navbar(grids=ship_side_navbar,
active_color=(247, 255, 173), active_threshold=221,
inactive_color=(140, 162, 181), inactive_threshold=221)
def equip_side_navbar_ensure(self, upper=None, bottom=None):
def ship_side_navbar_ensure(self, upper=None, bottom=None):
"""
Ensure able to transition to page
Whether page has completely loaded is handled
@@ -159,16 +159,16 @@ class Equipment(StorageHandler):
Returns:
bool: if side_navbar set ensured
"""
if self._equip_side_navbar.get_total(main=self) == 3:
if self._ship_side_navbar.get_total(main=self) == 3:
if upper == 1 or bottom == 3:
logger.warning('Transitions to "research" is not supported')
return False
if self._equip_side_navbar.set(self, upper=upper, bottom=bottom):
if self._ship_side_navbar.set(self, upper=upper, bottom=bottom):
return True
return False
def _equip_take_off_one(self, skip_first_screenshot=True):
def ship_equipment_take_off(self, skip_first_screenshot=True):
logger.info('Equipment take off')
bar_timer = Timer(5)
off_timer = Timer(5)
@@ -209,28 +209,26 @@ class Equipment(StorageHandler):
logger.info('Equipment take off ended')
def equipment_take_off(self, enter, out, fleet):
def fleet_equipment_take_off(self, enter, long_click, out):
"""
Args:
enter (Button): Long click to edit equipment.
enter (Button): Button to edit equipment.
long_click (bool): How to click enter
out (Button): Button to confirm exit success.
fleet (list[int]): list of equipment record. [3, 1, 1, 1, 1, 1]
"""
logger.hr('Equipment take off')
self.equip_enter(enter)
self.ship_info_enter(enter, long_click=long_click)
for index in '9'.join([str(x) for x in fleet if x > 0]):
index = int(index)
if index == 9:
self.equip_view_next()
else:
self._equip_take_off_one()
self.ui_click(click_button=EQUIPMENT_CLOSE, check_button=EQUIPMENT_OPEN, offset=None)
while True:
self.ship_equipment_take_off()
self.ui_click(EQUIPMENT_CLOSE, check_button=EQUIPMENT_OPEN, skip_first_screenshot=True)
if not self.ship_view_next():
break
self.ui_back(out)
self.equipment_has_take_on = False
def _equip_take_on_one(self, index, skip_first_screenshot=True):
def ship_equipment_take_on_preset(self, index, skip_first_screenshot=True):
logger.info('Equipment take on preset')
bar_timer = Timer(5)
on_timer = Timer(5)
@@ -267,7 +265,7 @@ class Equipment(StorageHandler):
logger.info('Equipment take on ended')
def equipment_take_on(self, enter, out, fleet):
def fleet_equipment_take_on_preset(self, enter, out, fleet):
"""
Args:
enter (Button): Long click to edit equipment.
@@ -275,14 +273,14 @@ class Equipment(StorageHandler):
fleet (list[int]): list of equipment record. [3, 1, 1, 1, 1, 1]
"""
logger.hr('Equipment take on')
self.equip_enter(enter)
self.ship_info_enter(enter)
for index in '9'.join([str(x) for x in fleet if x > 0]):
index = int(index)
if index == 9:
self.equip_view_next()
self.ship_view_next()
else:
self._equip_take_on_one(index=index)
self.ship_equipment_take_on_preset(index=index)
self.ui_click(click_button=EQUIPMENT_CLOSE, check_button=EQUIPMENT_OPEN, offset=None)
self.ui_back(out)