mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 02:48:23 +08:00
Merge branch 'master' of https://github.com/LmeSzinc/AzurLaneAutoScript
This commit is contained in:
@@ -9,7 +9,6 @@ from module.base.timer import Timer
|
||||
from module.base.utils import point_limit
|
||||
from module.config.utils import dict_to_kv
|
||||
from module.exception import MapWalkError
|
||||
from module.exercise.assets import QUIT_RECONFIRM
|
||||
from module.handler.assets import MAINTENANCE_ANNOUNCE
|
||||
from module.logger import logger
|
||||
from module.map.fleet import Fleet
|
||||
@@ -273,12 +272,7 @@ class OSFleet(OSCamera, Combat, Fleet, OSAsh):
|
||||
logger.hr('Wait until camera stable')
|
||||
record = None
|
||||
confirm_timer = Timer(0.6, count=2).start()
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
for _ in self.loop(skip_first=skip_first_screenshot):
|
||||
self.update_os()
|
||||
current = self.view.backend.homo_loca
|
||||
logger.attr('homo_loca', current)
|
||||
@@ -325,12 +319,7 @@ class OSFleet(OSCamera, Combat, Fleet, OSAsh):
|
||||
clicked_story_count = 0
|
||||
stuck_timer = Timer(20, count=5).start()
|
||||
confirm_timer.reset()
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
for _ in self.loop(skip_first=skip_first_screenshot):
|
||||
# Map event
|
||||
event = self.handle_map_event(drop=drop)
|
||||
if event:
|
||||
@@ -762,7 +751,7 @@ class OSFleet(OSCamera, Combat, Fleet, OSAsh):
|
||||
button = Button(area=area, color=(), button=area, name='BOSS_LEAVE')
|
||||
return button
|
||||
|
||||
def boss_leave(self, skip_first_screenshot=True):
|
||||
def boss_leave(self):
|
||||
"""
|
||||
Pages:
|
||||
in: is_in_map(), or combat_appear()
|
||||
@@ -774,12 +763,7 @@ class OSFleet(OSCamera, Combat, Fleet, OSAsh):
|
||||
|
||||
click_timer = Timer(3)
|
||||
pause_interval = Timer(0.5, count=1)
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
for _ in self.loop():
|
||||
# End
|
||||
if self.is_in_map():
|
||||
self.predict_radar()
|
||||
@@ -804,7 +788,7 @@ class OSFleet(OSCamera, Combat, Fleet, OSAsh):
|
||||
self.interval_reset(MAINTENANCE_ANNOUNCE)
|
||||
pause_interval.reset()
|
||||
continue
|
||||
if self.appear_then_click(QUIT_RECONFIRM, offset=True, interval=5):
|
||||
if self.handle_combat_quit_reconfirm():
|
||||
self.interval_reset(MAINTENANCE_ANNOUNCE)
|
||||
pause_interval.reset()
|
||||
continue
|
||||
|
||||
@@ -89,14 +89,9 @@ class GlobeOperation(ActionPointHandler):
|
||||
|
||||
return False
|
||||
|
||||
def ensure_no_zone_pinned(self, skip_first_screenshot=True):
|
||||
def ensure_no_zone_pinned(self):
|
||||
confirm_timer = Timer(1, count=2).start()
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
for _ in self.loop():
|
||||
if self.handle_zone_pinned():
|
||||
confirm_timer.reset()
|
||||
else:
|
||||
@@ -189,12 +184,14 @@ class GlobeOperation(ActionPointHandler):
|
||||
in: is_in_zone_select
|
||||
out: is_zone_pinned
|
||||
"""
|
||||
|
||||
def appear():
|
||||
return self.appear(button, offset=self._zone_select_offset, threshold=self._zone_select_similarity)
|
||||
|
||||
self.ui_click(button, appear_button=appear, check_button=self.is_zone_pinned,
|
||||
skip_first_screenshot=True)
|
||||
logger.info(f'Zone select: {button}')
|
||||
for _ in self.loop():
|
||||
# End
|
||||
if self.is_zone_pinned():
|
||||
break
|
||||
if self.appear_then_click(
|
||||
button, offset=self._zone_select_offset, threshold=self._zone_select_similarity, interval=5):
|
||||
continue
|
||||
|
||||
def zone_type_select(self, types=('SAFE', 'DANGEROUS')):
|
||||
"""
|
||||
@@ -282,23 +279,17 @@ class GlobeOperation(ActionPointHandler):
|
||||
return self.ui_click(GLOBE_GOTO_MAP, check_button=self.is_in_map, offset=(20, 20),
|
||||
retry_wait=3, skip_first_screenshot=skip_first_screenshot)
|
||||
|
||||
def os_map_goto_globe(self, unpin=True, skip_first_screenshot=True):
|
||||
def os_map_goto_globe(self, unpin=True):
|
||||
"""
|
||||
Args:
|
||||
unpin (bool):
|
||||
skip_first_screenshot (bool):
|
||||
|
||||
Pages:
|
||||
in: is_in_map
|
||||
out: is_in_globe
|
||||
"""
|
||||
click_count = 0
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
for _ in self.loop():
|
||||
# End
|
||||
if self.is_in_globe():
|
||||
break
|
||||
@@ -335,15 +326,9 @@ class GlobeOperation(ActionPointHandler):
|
||||
if self.handle_popup_confirm('GOTO_GLOBE'):
|
||||
continue
|
||||
|
||||
skip_first_screenshot = True
|
||||
confirm_timer = Timer(1, count=2).start()
|
||||
unpinned = 0
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
for _ in self.loop():
|
||||
if unpin:
|
||||
if self.handle_zone_pinned():
|
||||
unpinned += 1
|
||||
@@ -355,11 +340,10 @@ class GlobeOperation(ActionPointHandler):
|
||||
if self.is_zone_pinned():
|
||||
break
|
||||
|
||||
def globe_enter(self, zone, skip_first_screenshot=True):
|
||||
def globe_enter(self, zone):
|
||||
"""
|
||||
Args:
|
||||
zone (Zone): Zone to enter.
|
||||
skip_first_screenshot (bool):
|
||||
|
||||
Raises:
|
||||
OSExploreError: If zone locked.
|
||||
@@ -371,11 +355,7 @@ class GlobeOperation(ActionPointHandler):
|
||||
click_timer = Timer(10)
|
||||
click_count = 0
|
||||
pinned = None
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
for _ in self.loop():
|
||||
if pinned is None:
|
||||
pinned = self.get_zone_pinned_name()
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import inflection
|
||||
from module.base.timer import Timer
|
||||
from module.config.utils import get_os_reset_remain
|
||||
from module.exception import CampaignEnd, GameTooManyClickError, MapWalkError, RequestHumanTakeover, ScriptError
|
||||
from module.exercise.assets import QUIT_RECONFIRM
|
||||
from module.handler.login import LoginHandler, MAINTENANCE_ANNOUNCE
|
||||
from module.logger import logger
|
||||
from module.map.map import Map
|
||||
@@ -637,13 +636,12 @@ class OSMap(OSFleet, Map, GlobeCamera, StorageHandler, StrategicSearchHandler):
|
||||
logger.attr('CL1 time cost', f'{cost}s/round')
|
||||
self._auto_search_round_timer = time.time()
|
||||
|
||||
def os_auto_search_daemon(self, drop=None, strategic=False, interrupt=None, skip_first_screenshot=True):
|
||||
def os_auto_search_daemon(self, drop=None, strategic=False, interrupt=None):
|
||||
"""
|
||||
Args:
|
||||
drop (DropRecord):
|
||||
strategic (bool): True if running in strategic search
|
||||
interrupt (callable):
|
||||
skip_first_screenshot:
|
||||
|
||||
Returns:
|
||||
int: Number of finished battle
|
||||
@@ -678,12 +676,7 @@ class OSMap(OSFleet, Map, GlobeCamera, StorageHandler, StrategicSearchHandler):
|
||||
finished_combat = 0
|
||||
died_timer = Timer(1.5, count=3)
|
||||
self.hp_reset()
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
for _ in self.loop():
|
||||
# End
|
||||
if not unlock_checked and unlock_check_timer.reached():
|
||||
logger.critical('Unable to use auto search in current zone')
|
||||
@@ -744,7 +737,7 @@ class OSMap(OSFleet, Map, GlobeCamera, StorageHandler, StrategicSearchHandler):
|
||||
|
||||
return finished_combat
|
||||
|
||||
def interrupt_auto_search(self, goto_main=True, skip_first_screenshot=True):
|
||||
def interrupt_auto_search(self, goto_main=True):
|
||||
"""
|
||||
Args:
|
||||
goto_main (bool): If go to the page_main
|
||||
@@ -761,12 +754,8 @@ class OSMap(OSFleet, Map, GlobeCamera, StorageHandler, StrategicSearchHandler):
|
||||
pause_interval = Timer(0.5, count=1)
|
||||
in_main_timer = Timer(3, count=6)
|
||||
in_map_timer = Timer(1, count=6)
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
for _ in self.loop():
|
||||
# End
|
||||
if self.is_in_main():
|
||||
logger.info('Auto search interrupted')
|
||||
@@ -797,7 +786,7 @@ class OSMap(OSFleet, Map, GlobeCamera, StorageHandler, StrategicSearchHandler):
|
||||
in_main_timer.reset()
|
||||
in_map_timer.reset()
|
||||
continue
|
||||
if self.appear_then_click(QUIT_RECONFIRM, offset=True, interval=5):
|
||||
if self.handle_combat_quit_reconfirm():
|
||||
self.interval_reset(MAINTENANCE_ANNOUNCE)
|
||||
pause_interval.reset()
|
||||
in_main_timer.reset()
|
||||
@@ -845,7 +834,7 @@ class OSMap(OSFleet, Map, GlobeCamera, StorageHandler, StrategicSearchHandler):
|
||||
backup = self.config.temporary(Campaign_UseAutoSearch=True)
|
||||
try:
|
||||
if strategic:
|
||||
self.strategic_search_start(skip_first_screenshot=True)
|
||||
self.strategic_search_start()
|
||||
combat = self.os_auto_search_daemon(drop=drop, strategic=strategic, interrupt=interrupt)
|
||||
finished_combat += combat
|
||||
except CampaignEnd:
|
||||
|
||||
@@ -93,18 +93,13 @@ class FleetSelector:
|
||||
index = numbers - index
|
||||
return Button(area=(), color=(), button=area, name='%s_INDEX_%s' % (str(self._bar), str(index)))
|
||||
|
||||
def open(self, skip_first_screenshot=True):
|
||||
def open(self):
|
||||
"""
|
||||
Activate dropdown menu for fleet selection.
|
||||
"""
|
||||
main = self.main
|
||||
click_timer = Timer(3, count=6)
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
main.device.screenshot()
|
||||
|
||||
for _ in main.loop():
|
||||
if main.handle_map_event():
|
||||
click_timer.reset()
|
||||
continue
|
||||
@@ -118,18 +113,13 @@ class FleetSelector:
|
||||
main.device.click(self._choose)
|
||||
click_timer.reset()
|
||||
|
||||
def close(self, skip_first_screenshot=True):
|
||||
def close(self):
|
||||
"""
|
||||
Deactivate dropdown menu for fleet selection.
|
||||
"""
|
||||
main = self.main
|
||||
click_timer = Timer(3, count=6)
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
main.device.screenshot()
|
||||
|
||||
for _ in main.loop():
|
||||
# End
|
||||
if not self.bar_opened():
|
||||
break
|
||||
@@ -139,23 +129,17 @@ class FleetSelector:
|
||||
main.device.click(self._choose)
|
||||
click_timer.reset()
|
||||
|
||||
def click(self, index, skip_first_screenshot=True):
|
||||
def click(self, index):
|
||||
"""
|
||||
Choose a fleet on dropdown menu, and dropdown deactivated.
|
||||
|
||||
Args:
|
||||
index (int): Fleet index, 1-6.
|
||||
skip_first_screenshot (bool):
|
||||
"""
|
||||
main = self.main
|
||||
button = self.get_button(index)
|
||||
click_timer = Timer(3, count=6)
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
main.device.screenshot()
|
||||
|
||||
for _ in main.loop():
|
||||
if main.handle_map_event():
|
||||
click_timer.reset()
|
||||
continue
|
||||
@@ -173,25 +157,19 @@ class FleetSelector:
|
||||
main.device.click(button)
|
||||
click_timer.reset()
|
||||
|
||||
def ensure_to_be(self, index, skip_first_screenshot=True):
|
||||
def ensure_to_be(self, index):
|
||||
"""
|
||||
Set to a specific fleet.
|
||||
|
||||
Args:
|
||||
index (int): Fleet index, 1-4.
|
||||
skip_first_screenshot (bool):
|
||||
|
||||
Returns:
|
||||
bool: If fleet switched.
|
||||
"""
|
||||
confirm_timer = Timer(1.5, count=5).start()
|
||||
main = self.main
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
main.device.screenshot()
|
||||
|
||||
for _ in main.loop():
|
||||
if confirm_timer.reached():
|
||||
break
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ class OSMapOperation(MapOrderHandler, MissionHandler, PortHandler, StorageHandle
|
||||
self.config.HOMO_EDGE_COLOR_RANGE = (0, 33)
|
||||
self.config.MAP_ENSURE_EDGE_INSIGHT_CORNER = ''
|
||||
|
||||
def zone_init(self, fallback_init=True, skip_first_screenshot=True):
|
||||
def zone_init(self, fallback_init=True):
|
||||
"""
|
||||
Wrap get_current_zone(), set self.zone to the current zone.
|
||||
This method must be called after entering a new zone.
|
||||
@@ -176,7 +176,6 @@ class OSMapOperation(MapOrderHandler, MissionHandler, PortHandler, StorageHandle
|
||||
|
||||
Args:
|
||||
fallback_init (bool): Whether to get zone from globe map when unable to parse zone name.
|
||||
skip_first_screenshot (bool):
|
||||
|
||||
Returns:
|
||||
Zone: Current zone.
|
||||
@@ -188,12 +187,7 @@ class OSMapOperation(MapOrderHandler, MissionHandler, PortHandler, StorageHandle
|
||||
self.wait_os_map_buttons()
|
||||
logger.info('Get zone name')
|
||||
timeout = Timer(1.5, count=5).start()
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
for _ in self.loop():
|
||||
# Handle popups
|
||||
if self.handle_map_event():
|
||||
timeout.reset()
|
||||
@@ -246,13 +240,10 @@ class OSMapOperation(MapOrderHandler, MissionHandler, PortHandler, StorageHandle
|
||||
"""
|
||||
return self.appear(MAP_EXIT, offset=(20, 20))
|
||||
|
||||
def map_exit(self, skip_first_screenshot=True):
|
||||
def map_exit(self):
|
||||
"""
|
||||
Exit from an obscure zone, abyssal zone, or stronghold.
|
||||
|
||||
Args:
|
||||
skip_first_screenshot:
|
||||
|
||||
Pages:
|
||||
in: is_in_map
|
||||
out: is_in_map, zone that you came from
|
||||
@@ -260,12 +251,7 @@ class OSMapOperation(MapOrderHandler, MissionHandler, PortHandler, StorageHandle
|
||||
logger.hr('Map exit')
|
||||
confirm_timer = Timer(1, count=2)
|
||||
changed = False
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
for _ in self.loop():
|
||||
# End
|
||||
if changed and self.is_in_map():
|
||||
if confirm_timer.reached():
|
||||
|
||||
@@ -35,7 +35,7 @@ class OperationSiren(
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
self = OperationSiren('month_test', task='OpsiMonthBoss')
|
||||
self = OperationSiren('alas', task='OpsiMonthBoss')
|
||||
|
||||
self.config = self.config.merge(OSConfig())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user