1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-12 08:38:20 +08:00
This commit is contained in:
sui-feng-cb
2026-01-23 17:02:56 +08:00
57 changed files with 975 additions and 1264 deletions

View File

@@ -109,14 +109,10 @@ class ActionPointHandler(UI, MapEventHandler):
def is_current_ap_visible(self):
return self.match_template_color(CURRENT_AP_CHECK, offset=(40, 5), threshold=15)
def action_point_use(self, skip_first_screenshot=True):
def action_point_use(self):
prev = self._action_point_current
self.interval_clear(ACTION_POINT_USE)
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
for _ in self.loop():
if self.appear_then_click(ACTION_POINT_USE, offset=(20, 20), interval=3):
self.device.sleep(0.3)
@@ -149,14 +145,9 @@ class ActionPointHandler(UI, MapEventHandler):
self._action_point_box = box
self._action_point_total = total
def action_point_safe_get(self, skip_first_screenshot=True):
def action_point_safe_get(self):
timeout = Timer(3, count=6).start()
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
for _ in self.loop():
# End
if self.is_current_ap_visible():
break
@@ -249,52 +240,34 @@ class ActionPointHandler(UI, MapEventHandler):
logger.warning('Unable to find an active action point box button')
return 1
def action_point_set_button(self, index, skip_first_screenshot=True):
def action_point_set_button(self, index):
"""
Args:
index (int): 0 to 3. 0 for oil, 1 for 20 ap box, 2 for 50 ap box, 3 for 100 ap box.
skip_first_screenshot (bool):
Returns:
bool: If success.
"""
for _ in range(3):
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
for _ in self.loop(timeout=2):
if self.action_point_get_active_button() == index:
return True
else:
self.device.click(ACTION_POINT_GRID[index, 0])
self.device.sleep(0.3)
else:
logger.warning('FSet action point button timeout')
return False
logger.warning('Failed to set action point button after 3 trial')
return False
def action_point_get_buy_remain(self, skip_first_screenshot=True):
def action_point_get_buy_remain(self):
"""
Args:
skip_first_screenshot:
Returns:
int: Remaining number of purchases of action points
Pages:
in: ACTION_POINT_USE
"""
timeout = Timer(1, count=2).start()
current = 0
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
if timeout.reached():
logger.warning('Get action points buy remain timeout')
break
for _ in self.loop(timeout=1):
current, _, total = OCR_ACTION_POINT_BUY_REMAIN.ocr(self.device.image)
@@ -303,6 +276,8 @@ class ActionPointHandler(UI, MapEventHandler):
continue
break
else:
logger.warning('Get action points buy remain timeout')
return current
@@ -337,18 +312,13 @@ class ActionPointHandler(UI, MapEventHandler):
logger.info('Not enough oil to buy')
return False
def action_point_quit(self, skip_first_screenshot=True):
def action_point_quit(self):
"""
Pages:
in: ACTION_POINT_USE
out: page_os
"""
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
for _ in self.loop():
# End
# sometimes you have action point popup without black-blurred background
# ACTION_POINT_CANCEL and OS_CHECK both appears
@@ -457,18 +427,13 @@ class ActionPointHandler(UI, MapEventHandler):
logger.warning('Failed to get action points after 12 trial')
return False
def action_point_enter(self, skip_first_screenshot=True):
def action_point_enter(self):
"""
Pages:
in: OS_CHECK
out: ACTION_POINT_USE
"""
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
for _ in self.loop():
if self.appear(ACTION_POINT_USE, offset=(20, 20)):
break
@@ -503,10 +468,10 @@ class ActionPointHandler(UI, MapEventHandler):
if not self.handle_action_point(zone, pinned, cost, keep_current_ap, check_rest_ap):
return False
while 1:
# wait until AP popup closed
for _ in self.loop():
if self.appear(IN_MAP, offset=(200, 5)):
break
self.device.screenshot()
return True
@@ -528,9 +493,8 @@ class ActionPointHandler(UI, MapEventHandler):
logger.info(f'Not having {amount} action points')
self.action_point_quit()
while 1:
for _ in self.loop():
if self.appear(IN_MAP, offset=(200, 5)):
break
self.device.screenshot()
return enough