mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-29 01:15:30 +08:00
Upd: Flagship changing (#3556)
* Upd: Flagship changing asset * Upd: Equipment enter * Upd: Fleet detail check * Refactor: equipment changing * Upd: asset exercise/EQUIP_ENTER * Refactor: rename equipment functions * Fix: avoid GameTooManyClickError when EQUIPMENT_SCROLL disappears * Upd: [CN] assets EQUIP_1/2/3 * Fix: skip first screenshot in equipment.py
This commit is contained in:
@@ -6,6 +6,7 @@ from module.equipment.equipment import Equipment
|
||||
from module.logger import logger
|
||||
from module.ui.assets import BACK_ARROW
|
||||
from module.ui.scroll import Scroll
|
||||
from module.ui.switch import Switch
|
||||
|
||||
# Button of 5 equipments
|
||||
EQUIP_INFO_BAR = ButtonGrid(
|
||||
@@ -16,68 +17,58 @@ EQUIPMENT_GRID = ButtonGrid(
|
||||
EQUIPMENT_SCROLL = Scroll(EQUIP_SCROLL, color=(247, 211, 66), name='EQUIP_SCROLL')
|
||||
SIM_VALUE = 0.90
|
||||
|
||||
equipping_filter = Switch('Equipping_filter')
|
||||
equipping_filter.add_status('on', check_button=EQUIPPING_ON)
|
||||
equipping_filter.add_status('off', check_button=EQUIPPING_OFF)
|
||||
|
||||
|
||||
class EquipmentChange(Equipment):
|
||||
equip_list = {}
|
||||
equipping_list = []
|
||||
equipment_list = {}
|
||||
|
||||
def get_equiping_list(self, skip_first_screenshot=True):
|
||||
'''
|
||||
Pages:
|
||||
in: ship's details
|
||||
'''
|
||||
logger.info("Get equipping list")
|
||||
if skip_first_screenshot:
|
||||
pass
|
||||
else:
|
||||
self.device.screenshot()
|
||||
index = 0
|
||||
self.equipping_list = []
|
||||
for button in EQUIPMENT_GRID.buttons:
|
||||
def equipping_set(self, enable=False):
|
||||
if equipping_filter.set('on' if enable else 'off', main=self):
|
||||
self.wait_until_stable(SWIPE_AREA)
|
||||
|
||||
def ship_equipment_record_image(self, index_list=range(0, 5)):
|
||||
"""
|
||||
Record equipment through upgrade page
|
||||
Notice: The equipment icons in the upgrade page are the same size as the icons in the equipment status
|
||||
"""
|
||||
logger.info('RECORD EQUIPMENT')
|
||||
self.ship_side_navbar_ensure(bottom=1)
|
||||
self.equipment_list = {}
|
||||
for index, button in enumerate(EQUIPMENT_GRID.buttons):
|
||||
if index not in index_list:
|
||||
continue
|
||||
crop_image = self.image_crop(button)
|
||||
edge_value = np.mean(np.abs(cv2.Sobel(crop_image, 3, 1, 1)))
|
||||
# Nothing is 0.15~1
|
||||
# +1 is 40
|
||||
# +10 is 46
|
||||
if edge_value > 10:
|
||||
self.equipping_list.append(index)
|
||||
index += 1
|
||||
logger.info(f"Equipping list: {self.equipping_list}")
|
||||
|
||||
def record_equipment(self, index_list=range(0, 5)):
|
||||
'''
|
||||
Record equipment through upgrade page
|
||||
Notice: The equipment icons in the upgrade page are the same size as the icons in the equipment status
|
||||
'''
|
||||
logger.info('RECORD EQUIPMENT')
|
||||
self.equip_side_navbar_ensure(bottom=1)
|
||||
self.get_equiping_list()
|
||||
|
||||
for index in index_list:
|
||||
if index in self.equipping_list:
|
||||
logger.info(f'Record {index}')
|
||||
logger.info('Enter equipment info')
|
||||
self.ui_click(appear_button=EQUIPMENT_OPEN, click_button=EQUIP_INFO_BAR[(
|
||||
index, 0)], check_button=UPGRADE_ENTER)
|
||||
logger.info('Enter upgrade inform')
|
||||
# Enter equipment info
|
||||
self.ui_click(appear_button=EQUIPMENT_OPEN,
|
||||
click_button=EQUIP_INFO_BAR[(index, 0)],
|
||||
check_button=UPGRADE_ENTER)
|
||||
# Enter upgrade inform
|
||||
self.ui_click(click_button=UPGRADE_ENTER,
|
||||
check_button=UPGRADE_ENTER_CHECK, skip_first_screenshot=True)
|
||||
logger.info('Save equipment tamplate')
|
||||
self.equip_list[index] = self.image_crop(EQUIP_SAVE)
|
||||
logger.info('Quit upgrade inform')
|
||||
self.equipment_list[index] = self.image_crop(EQUIP_SAVE)
|
||||
# Quit upgrade inform
|
||||
self.ui_click(
|
||||
click_button=UPGRADE_QUIT, check_button=EQUIPMENT_OPEN, appear_button=UPGRADE_ENTER_CHECK,
|
||||
skip_first_screenshot=True)
|
||||
logger.info(f"Recorded equipment index list: {list(self.equipment_list.keys())}")
|
||||
|
||||
def equipment_take_on(self, index_list=range(0, 5), skip_first_screenshot=True):
|
||||
'''
|
||||
def ship_equipment_take_on_image(self, index_list=range(0, 5), skip_first_screenshot=True):
|
||||
"""
|
||||
Equip the equipment previously recorded
|
||||
'''
|
||||
"""
|
||||
logger.info('Take on equipment')
|
||||
self.equip_side_navbar_ensure(bottom=2)
|
||||
self.ship_side_navbar_ensure(bottom=2)
|
||||
|
||||
for index in index_list:
|
||||
if index in self.equipping_list:
|
||||
if index in self.equipment_list:
|
||||
logger.info(f'Take on {index}')
|
||||
enter_button = globals()[
|
||||
'EQUIP_TAKE_ON_{index}'.format(index=index)]
|
||||
@@ -85,7 +76,7 @@ class EquipmentChange(Equipment):
|
||||
self.ui_click(enter_button, check_button=EQUIPPING_ON,
|
||||
skip_first_screenshot=skip_first_screenshot, offset=(5, 5))
|
||||
self.handle_info_bar()
|
||||
self._find_equip(index)
|
||||
self._find_equipment(index)
|
||||
|
||||
@Config.when(DEVICE_CONTROL_METHOD='minitouch')
|
||||
def _equipment_swipe(self, distance=190):
|
||||
@@ -108,13 +99,13 @@ class EquipmentChange(Equipment):
|
||||
self.device.screenshot()
|
||||
|
||||
def _equip_equipment(self, point, offset=(100, 100)):
|
||||
'''
|
||||
"""
|
||||
Equip Equipment then back to ship details
|
||||
Confirm the popup
|
||||
Pages:
|
||||
in: EQUIPMENT STATUS
|
||||
out: SHIP_SIDEBAR_EQUIPMENT
|
||||
'''
|
||||
"""
|
||||
logger.info('Equip equipment')
|
||||
button = Button(area=(), color=(), button=(point[0], point[1], point[0] + offset[0], point[1] + offset[1]),
|
||||
name='EQUIPMENT')
|
||||
@@ -122,23 +113,28 @@ class EquipmentChange(Equipment):
|
||||
logger.info('Equip confirm')
|
||||
self.ui_click(click_button=EQUIP_CONFIRM, check_button=SHIP_INFO_EQUIPMENT_CHECK)
|
||||
|
||||
def _find_equip(self, index):
|
||||
'''
|
||||
def _find_equipment(self, index):
|
||||
"""
|
||||
Find the equipment previously recorded
|
||||
Pages:
|
||||
in: EQUIPMENT STATUS
|
||||
'''
|
||||
"""
|
||||
|
||||
self.equipping_set(False)
|
||||
|
||||
res = cv2.matchTemplate(self.device.screenshot(), np.array(
|
||||
self.equip_list[index]), cv2.TM_CCOEFF_NORMED)
|
||||
self.equipment_list[index]), cv2.TM_CCOEFF_NORMED)
|
||||
_, sim, _, point = cv2.minMaxLoc(res)
|
||||
|
||||
if sim > SIM_VALUE:
|
||||
self._equip_equipment(point)
|
||||
return
|
||||
|
||||
if not EQUIPMENT_SCROLL.appear(main=self):
|
||||
logger.warning('No recorded equipment was found.')
|
||||
self.ui_back(check_button=globals()[f'EQUIP_TAKE_ON_{index}'], appear_button=EQUIPPING_OFF)
|
||||
return
|
||||
|
||||
for _ in range(0, 15):
|
||||
self._equipment_swipe()
|
||||
|
||||
@@ -146,7 +142,7 @@ class EquipmentChange(Equipment):
|
||||
self.device.click(BACK_ARROW)
|
||||
continue
|
||||
res = cv2.matchTemplate(self.device.screenshot(), np.array(
|
||||
self.equip_list[index]), cv2.TM_CCOEFF_NORMED)
|
||||
self.equipment_list[index]), cv2.TM_CCOEFF_NORMED)
|
||||
_, sim, _, point = cv2.minMaxLoc(res)
|
||||
|
||||
if sim > SIM_VALUE:
|
||||
|
||||
Reference in New Issue
Block a user