mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-11 23:18:22 +08:00
Modify equipment swipe implementation to allow exit on same ship (Only 1 card is on grid so cannot swipe). Also used bool return values to indicate whether successful.
Modify enhanacement to use swipe bool mechanic to exit in case of infinite swipe attempts. Never reaching the 'material exhausted' conditional. Added get_hp() to fleet switch due to possibility of fleet acquiring emergency repair. However in most cases has full HP but the current HP in program belongs to fleet before switch. Thus is parsing an incorrect HP set when deciding to use repair.
This commit is contained in:
@@ -17,6 +17,7 @@ class Equipment(UI):
|
||||
equipment_has_take_on = False
|
||||
|
||||
def _view_swipe(self, distance, check_button=EQUIPMENT_OPEN):
|
||||
swipe_count = 0
|
||||
swipe_timer = Timer(5, count=10)
|
||||
SWIPE_CHECK.load_color(self.device.image)
|
||||
while 1:
|
||||
@@ -24,19 +25,24 @@ class Equipment(UI):
|
||||
swipe_timer.reset()
|
||||
self.device.swipe(vector=(distance, 0), box=SWIPE_AREA.area, random_range=SWIPE_RANDOM_RANGE,
|
||||
padding=0, duration=(0.1, 0.12), name='EQUIP_SWIPE')
|
||||
swipe_count += 1
|
||||
|
||||
self.device.screenshot()
|
||||
if SWIPE_CHECK.match(self.device.image):
|
||||
if swipe_count > 3:
|
||||
logger.warning('Same ship on multiple swipes')
|
||||
return False
|
||||
continue
|
||||
|
||||
if self.appear(check_button, offset=(30, 30)) and not SWIPE_CHECK.match(self.device.image):
|
||||
break
|
||||
logger.info('New ship detected on swipe')
|
||||
return True
|
||||
|
||||
def equip_view_next(self, check_button=EQUIPMENT_OPEN):
|
||||
self._view_swipe(distance=-SWIPE_DISTANCE, check_button=check_button)
|
||||
return self._view_swipe(distance=-SWIPE_DISTANCE, check_button=check_button)
|
||||
|
||||
def equip_view_prev(self, check_button=EQUIPMENT_OPEN):
|
||||
self._view_swipe(distance=SWIPE_DISTANCE, check_button=check_button)
|
||||
return self._view_swipe(distance=SWIPE_DISTANCE, check_button=check_button)
|
||||
|
||||
def equip_enter(self, click_button, check_button=EQUIPMENT_OPEN, long_click=True):
|
||||
enter_timer = Timer(10)
|
||||
|
||||
@@ -80,6 +80,7 @@ class Fleet(Camera, MapOperation, AmbushHandler):
|
||||
self.find_path_initial()
|
||||
self.map.show_cost()
|
||||
self.show_fleet()
|
||||
self.hp_get()
|
||||
self.handle_strategy(index=self.fleet_current_index)
|
||||
|
||||
def switch_to(self):
|
||||
|
||||
@@ -118,14 +118,18 @@ class Enhancement(Dock):
|
||||
if self.info_bar_count():
|
||||
if status > 0.98:
|
||||
logger.info('Fully enhanced for this ship')
|
||||
self.equip_view_next(check_button=ENHANCE_RECOMMEND)
|
||||
swiped = self.equip_view_next(check_button=ENHANCE_RECOMMEND)
|
||||
self.ensure_no_info_bar()
|
||||
if not swiped:
|
||||
return False
|
||||
continue
|
||||
else:
|
||||
if choose:
|
||||
logger.info('Unable to enhance this ship')
|
||||
self.equip_view_next(check_button=ENHANCE_RECOMMEND)
|
||||
swiped = self.equip_view_next(check_button=ENHANCE_RECOMMEND)
|
||||
self.ensure_no_info_bar()
|
||||
if not swiped:
|
||||
return False
|
||||
continue
|
||||
else:
|
||||
logger.info('Enhancement material exhausted')
|
||||
@@ -219,7 +223,7 @@ class Enhancement(Dock):
|
||||
self.ui_back(DOCK_FILTER)
|
||||
|
||||
if exhaust_count > 2:
|
||||
logger.info(f'Mats exhausted, threshold exceeded, terminate early. Last filter was {ship_type}')
|
||||
logger.warning(f'Too many failed enhancements, terminate early')
|
||||
break
|
||||
|
||||
self._enhance_quit()
|
||||
|
||||
Reference in New Issue
Block a user