mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-24 03:15:55 +08:00
Merge branch 'master' of https://github.com/LmeSzinc/AzurLaneAutoScript
This commit is contained in:
@@ -6,6 +6,10 @@ from module.equipment.equipment import Equipment
|
||||
from module.logger import logger
|
||||
from module.ui.assets import BACK_ARROW
|
||||
from module.ui.scroll import Scroll
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
from module.ui.switch import Switch
|
||||
>>>>>>> 24aa3e00bd9af9a6a050df54c6a0cef959a9c6c0
|
||||
|
||||
# Button of 5 equipments
|
||||
EQUIP_INFO_BAR = ButtonGrid(
|
||||
@@ -16,6 +20,7 @@ EQUIPMENT_GRID = ButtonGrid(
|
||||
EQUIPMENT_SCROLL = Scroll(EQUIP_SCROLL, color=(247, 211, 66), name='EQUIP_SCROLL')
|
||||
SIM_VALUE = 0.90
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
class EquipmentChange(Equipment):
|
||||
equip_list = {}
|
||||
@@ -34,12 +39,50 @@ class EquipmentChange(Equipment):
|
||||
index = 0
|
||||
self.equipping_list = []
|
||||
for button in EQUIPMENT_GRID.buttons:
|
||||
=======
|
||||
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):
|
||||
equipment_list = {}
|
||||
|
||||
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)
|
||||
|
||||
# Ensure EQUIPMENT_GRID in the right place
|
||||
skip_first_screenshot = True
|
||||
while True:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
if self.appear(EQUIPMENT_OPEN, offset=(5, 5)):
|
||||
break
|
||||
|
||||
self.equipment_list = {}
|
||||
info_bar_disappeared = False
|
||||
for index, button in enumerate(EQUIPMENT_GRID.buttons):
|
||||
if index not in index_list:
|
||||
continue
|
||||
>>>>>>> 24aa3e00bd9af9a6a050df54c6a0cef959a9c6c0
|
||||
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:
|
||||
<<<<<<< HEAD
|
||||
self.equipping_list.append(index)
|
||||
index += 1
|
||||
logger.info(f"Equipping list: {self.equipping_list}")
|
||||
@@ -78,6 +121,38 @@ class EquipmentChange(Equipment):
|
||||
|
||||
for index in index_list:
|
||||
if index in self.equipping_list:
|
||||
=======
|
||||
# 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)
|
||||
# Save equipment template
|
||||
if not info_bar_disappeared:
|
||||
self.handle_info_bar()
|
||||
info_bar_disappeared = True
|
||||
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)
|
||||
else:
|
||||
logger.info(f"Equipment {index} is empty")
|
||||
|
||||
logger.info(f"Recorded equipment index list: {list(self.equipment_list.keys())}")
|
||||
|
||||
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.ship_side_navbar_ensure(bottom=2)
|
||||
|
||||
for index in index_list:
|
||||
if index in self.equipment_list:
|
||||
>>>>>>> 24aa3e00bd9af9a6a050df54c6a0cef959a9c6c0
|
||||
logger.info(f'Take on {index}')
|
||||
enter_button = globals()[
|
||||
'EQUIP_TAKE_ON_{index}'.format(index=index)]
|
||||
@@ -85,7 +160,11 @@ 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()
|
||||
<<<<<<< HEAD
|
||||
self._find_equip(index)
|
||||
=======
|
||||
self._find_equipment(index)
|
||||
>>>>>>> 24aa3e00bd9af9a6a050df54c6a0cef959a9c6c0
|
||||
|
||||
@Config.when(DEVICE_CONTROL_METHOD='minitouch')
|
||||
def _equipment_swipe(self, distance=190):
|
||||
@@ -108,13 +187,21 @@ class EquipmentChange(Equipment):
|
||||
self.device.screenshot()
|
||||
|
||||
def _equip_equipment(self, point, offset=(100, 100)):
|
||||
<<<<<<< HEAD
|
||||
'''
|
||||
=======
|
||||
"""
|
||||
>>>>>>> 24aa3e00bd9af9a6a050df54c6a0cef959a9c6c0
|
||||
Equip Equipment then back to ship details
|
||||
Confirm the popup
|
||||
Pages:
|
||||
in: EQUIPMENT STATUS
|
||||
out: SHIP_SIDEBAR_EQUIPMENT
|
||||
<<<<<<< HEAD
|
||||
'''
|
||||
=======
|
||||
"""
|
||||
>>>>>>> 24aa3e00bd9af9a6a050df54c6a0cef959a9c6c0
|
||||
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 +209,44 @@ class EquipmentChange(Equipment):
|
||||
logger.info('Equip confirm')
|
||||
self.ui_click(click_button=EQUIP_CONFIRM, check_button=SHIP_INFO_EQUIPMENT_CHECK)
|
||||
|
||||
<<<<<<< HEAD
|
||||
def _find_equip(self, index):
|
||||
'''
|
||||
Find the equipment previously recorded
|
||||
Pages:
|
||||
in: EQUIPMENT STATUS
|
||||
'''
|
||||
=======
|
||||
def _find_equipment(self, index):
|
||||
"""
|
||||
Find the equipment previously recorded
|
||||
Pages:
|
||||
in: EQUIPMENT STATUS
|
||||
"""
|
||||
>>>>>>> 24aa3e00bd9af9a6a050df54c6a0cef959a9c6c0
|
||||
|
||||
self.equipping_set(False)
|
||||
|
||||
res = cv2.matchTemplate(self.device.screenshot(), np.array(
|
||||
<<<<<<< HEAD
|
||||
self.equip_list[index]), cv2.TM_CCOEFF_NORMED)
|
||||
=======
|
||||
self.equipment_list[index]), cv2.TM_CCOEFF_NORMED)
|
||||
>>>>>>> 24aa3e00bd9af9a6a050df54c6a0cef959a9c6c0
|
||||
_, sim, _, point = cv2.minMaxLoc(res)
|
||||
|
||||
if sim > SIM_VALUE:
|
||||
self._equip_equipment(point)
|
||||
return
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
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
|
||||
|
||||
>>>>>>> 24aa3e00bd9af9a6a050df54c6a0cef959a9c6c0
|
||||
for _ in range(0, 15):
|
||||
self._equipment_swipe()
|
||||
|
||||
@@ -146,7 +254,11 @@ class EquipmentChange(Equipment):
|
||||
self.device.click(BACK_ARROW)
|
||||
continue
|
||||
res = cv2.matchTemplate(self.device.screenshot(), np.array(
|
||||
<<<<<<< HEAD
|
||||
self.equip_list[index]), cv2.TM_CCOEFF_NORMED)
|
||||
=======
|
||||
self.equipment_list[index]), cv2.TM_CCOEFF_NORMED)
|
||||
>>>>>>> 24aa3e00bd9af9a6a050df54c6a0cef959a9c6c0
|
||||
_, sim, _, point = cv2.minMaxLoc(res)
|
||||
|
||||
if sim > SIM_VALUE:
|
||||
|
||||
Reference in New Issue
Block a user