1
0
mirror of https://github.com/sui-feng-cb/AzurLaneAutoScript1.git synced 2026-08-10 02:27:56 +08:00

Upd: GemsFarming

This commit is contained in:
2026-06-20 00:57:57 +08:00
parent 8cdb84adc6
commit b69311d96b
4 changed files with 206 additions and 427 deletions

View File

@@ -2,16 +2,11 @@ from module.base.button import ButtonGrid
from module.base.decorator import cached_property
from module.base.timer import Timer
from module.equipment.assets import *
from module.equipment.equipment_code import EquipmentCodeHandler
from module.logger import logger
from module.retire.assets import DOCK_CHECK, EQUIP_CONFIRM as RETIRE_EQUIP_CONFIRM
from module.storage.storage import StorageHandler
from module.ui.assets import BACK_ARROW
from module.ui.navbar import Navbar
from module.ui.switch import Switch
equipping_filter = Switch('Equiping_filter')
equipping_filter.add_state('on', check_button=EQUIPPING_ON)
equipping_filter.add_state('off', check_button=EQUIPPING_OFF)
SWIPE_DISTANCE = 250
SWIPE_RANDOM_RANGE = (-40, -20, 40, 20)
@@ -19,13 +14,9 @@ SWIPE_RANDOM_RANGE = (-40, -20, 40, 20)
EQUIPMENT_OPEN.match = EQUIPMENT_OPEN.match_luma
class Equipment(StorageHandler):
class Equipment(EquipmentCodeHandler):
equipment_has_take_on = False
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_view_swipe(self, distance, check_button=EQUIPMENT_OPEN):
swipe_count = 0
swipe_timer = Timer(5, count=10)
@@ -76,23 +67,23 @@ class Equipment(StorageHandler):
def ship_view_prev(self, check_button=EQUIPMENT_OPEN):
return self._ship_view_swipe(distance=SWIPE_DISTANCE, check_button=check_button)
def ship_info_enter(self, click_button, check_button=EQUIPMENT_OPEN, long_click=True, skil_first_screenshot=True):
def ship_info_enter(self, click_button, check_button=EQUIPMENT_OPEN, long_click=True, skip_first_screenshot=True):
enter_timer = Timer(10)
while 1:
if skil_first_screenshot:
skil_first_screenshot = False
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
# End
if self.appear(check_button):
if self.appear(check_button, offset=(5, 5)):
break
# Long click accidentally became normal click, exit from dock
if long_click:
if self.appear(DOCK_CHECK, offset=(20, 20), interval=3):
logger.info(f'equip_enter {DOCK_CHECK} -> {BACK_ARROW}')
logger.info(f'ship_info_enter {DOCK_CHECK} -> {BACK_ARROW}')
self.device.click(BACK_ARROW)
continue
if enter_timer.reached():
@@ -168,120 +159,8 @@ class Equipment(StorageHandler):
return True
return False
def ship_equipment_take_off(self, skip_first_screenshot=True):
logger.info('Equipment take off')
bar_timer = Timer(5)
off_timer = Timer(5)
confirm_timer = Timer(5)
def ship_equipment_take_off(self, name=None):
self.code_clear(name=name)
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
# End
# if self.handle_info_bar():
# break
if off_timer.started() and self.info_bar_count():
break
if self.handle_storage_full():
continue
if confirm_timer.reached() and self.handle_popup_confirm():
confirm_timer.reset()
off_timer.reset()
bar_timer.reset()
continue
if off_timer.reached():
if not self.info_bar_count() and self.appear_then_click(EQUIP_OFF, offset=(20, 20)):
off_timer.reset()
bar_timer.reset()
continue
if bar_timer.reached():
if self.appear(EQUIPMENT_OPEN, offset=(20, 20)) and not self.appear(EQUIP_OFF, offset=(20, 20)):
self.device.click(EQUIPMENT_OPEN)
bar_timer.reset()
continue
logger.info('Equipment take off ended')
def fleet_equipment_take_off(self, enter, long_click, out):
"""
Args:
enter (Button): Button to edit equipment.
long_click (bool): How to click enter
out (Button): Button to confirm exit success.
"""
logger.hr('Equipment take off')
self.ship_info_enter(enter, long_click=long_click)
while True:
self.ship_equipment_take_off()
self.ui_click(EQUIPMENT_CLOSE, check_button=EQUIPMENT_OPEN, skip_first_screenshot=True)
if not self.ship_view_next():
break
self.ui_back(out)
self.equipment_has_take_on = False
def ship_equipment_take_on_preset(self, index, skip_first_screenshot=True):
logger.info('Equipment take on preset')
bar_timer = Timer(5)
on_timer = Timer(5)
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
# End
# if self.handle_info_bar():
# break
if on_timer.started() and self.info_bar_count():
break
if bar_timer.reached() and not self.appear(EQUIP_1, offset=10):
self.device.click(EQUIPMENT_OPEN)
# self.device.sleep(0.3)
bar_timer.reset()
continue
if on_timer.reached() and self.appear(EQUIP_1, offset=10) and not self.info_bar_count():
if index == 1:
self.device.click(EQUIP_1)
elif index == 2:
self.device.click(EQUIP_2)
elif index == 3:
self.device.click(EQUIP_3)
on_timer.reset()
bar_timer.reset()
continue
logger.info('Equipment take on ended')
def fleet_equipment_take_on_preset(self, enter, out, fleet):
"""
Args:
enter (Button): Long click to edit equipment.
out (Button): Button to confirm exit success.
fleet (list[int]): list of equipment record. [3, 1, 1, 1, 1, 1]
"""
logger.hr('Equipment take on')
self.ship_info_enter(enter)
for index in '9'.join([str(x) for x in fleet if x > 0]):
index = int(index)
if index == 9:
self.ship_view_next()
else:
self.ship_equipment_take_on_preset(index=index)
self.ui_click(click_button=EQUIPMENT_CLOSE, check_button=EQUIPMENT_OPEN, offset=None)
self.ui_back(out)
self.equipment_has_take_on = True
def ship_equipment_take_on(self, name=None):
self.code_apply(name=name)