1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-04-10 05:12:09 +08:00

Revert "Revert "Merge branch 'dev' of https://github.com/LmeSzinc/AzurLaneAutoScript into dev""

This reverts commit ac9303012c.
This commit is contained in:
whoamikyo
2020-08-18 20:48:14 -03:00
parent ac9303012c
commit 09d3f695de
741 changed files with 18944 additions and 8381 deletions

View File

@@ -3,7 +3,7 @@ from module.base.timer import Timer
from module.equipment.assets import *
from module.handler.info_handler import InfoHandler
from module.logger import logger
from module.ui.assets import BACK_ARROW
from module.ui.ui import UI
from module.base.utils import color_similarity_2d
import numpy as np
@@ -13,33 +13,40 @@ DETAIL_SIDEBAR = ButtonGrid(
origin=(21, 118), delta=(0, 94.5), button_shape=(60, 75), grid_shape=(1, 5), name='DETAIL_SIDEBAR')
class Equipment(InfoHandler):
class Equipment(UI):
equipment_has_take_on = False
def _view_swipe(self, distance, check_button=EQUIPMENT_OPEN):
swipe_timer = Timer(3, count=5)
swipe_count = 0
swipe_timer = Timer(5, count=10)
self.ensure_no_info_bar()
SWIPE_CHECK.load_color(self.device.image)
while 1:
if not swipe_timer.started() or swipe_timer.reached():
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))
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 > 1:
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(5)
enter_timer = Timer(10)
while 1:
if enter_timer.reached():
@@ -55,23 +62,6 @@ class Equipment(InfoHandler):
if self.appear(check_button):
break
def equip_quit(self, out):
quit_timer = Timer(3)
while 1:
self.device.screenshot()
# End
if self.appear(out):
break
if quit_timer.reached() and self.appear(BACK_ARROW):
# self.device.sleep(1)
self.device.click(BACK_ARROW)
self.device.sleep((0.2, 0.3))
quit_timer.reset()
continue
def _equip_sidebar_click(self, index):
"""
Args:
@@ -85,6 +75,10 @@ class Equipment(InfoHandler):
Returns:
bool: if changed.
"""
if index <= 0 or index > 5:
logger.warning(f'Sidebar index cannot be clicked, {index}, limit to 1 through 5 only')
return False
current = 0
total = 0
@@ -106,6 +100,7 @@ class Equipment(InfoHandler):
current = 6 - current
else:
logger.warning('Ship details sidebar total count error.')
return True
logger.attr('Detail_sidebar', f'{current}/{total}')
if current == index:
@@ -123,7 +118,17 @@ class Equipment(InfoHandler):
3 for limit break.
2 for gem / equipment.
1 for detail.
Returns:
bool: whether sidebar could be ensured
at most 3 attempts are made before
return False otherwise True
"""
if index <= 0 or index > 5:
logger.warning(f'Sidebar index cannot be ensured, {index}, limit 1 through 5 only')
return False
counter = 0
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
@@ -131,10 +136,14 @@ class Equipment(InfoHandler):
self.device.screenshot()
if self._equip_sidebar_click(index):
if counter > 2:
logger.warning('Sidebar could not be ensured')
return False
counter += 1
self.device.sleep((0.3, 0.5))
continue
else:
break
return True
def _equip_take_off_one(self):
bar_timer = Timer(5)
@@ -179,7 +188,7 @@ class Equipment(InfoHandler):
else:
self._equip_take_off_one()
self.equip_quit(out)
self.ui_back(out)
self.equipment_has_take_on = False
def _equip_take_on_one(self, index):
@@ -229,5 +238,5 @@ class Equipment(InfoHandler):
else:
self._equip_take_on_one(index=index)
self.equip_quit(out)
self.ui_back(out)
self.equipment_has_take_on = True