mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-30 09:43:51 +08:00
Upd: Opsi tasks
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
from module.config.config import TaskEnd
|
||||
from module.logger import logger
|
||||
from module.os.fleet import BossFleet
|
||||
from module.os.map import OSMap
|
||||
from module.os_handler.assets import OS_SUBMARINE_EMPTY
|
||||
from module.ui.page import page_os
|
||||
|
||||
|
||||
class OpsiStronghold(OSMap):
|
||||
@@ -16,22 +19,30 @@ class OpsiStronghold(OSMap):
|
||||
RequestHumanTakeover: If unable to clear boss, fleets exhausted.
|
||||
"""
|
||||
logger.hr('OS clear stronghold', level=1)
|
||||
self.cl1_ap_preserve()
|
||||
with self.config.multi_set():
|
||||
self.config.OpsiStronghold_HasStronghold = True
|
||||
self.cl1_ap_preserve()
|
||||
|
||||
self.os_map_goto_globe()
|
||||
self.globe_update()
|
||||
zone = self.find_siren_stronghold()
|
||||
if zone is None:
|
||||
# No siren stronghold, delay next run to tomorrow.
|
||||
self.config.task_delay(server_update=True)
|
||||
self.config.task_stop()
|
||||
self.os_map_goto_globe()
|
||||
self.globe_update()
|
||||
zone = self.find_siren_stronghold()
|
||||
if zone is None:
|
||||
# No siren stronghold, delay next run to tomorrow.
|
||||
self.config.OpsiStronghold_HasStronghold = False
|
||||
self.config.task_delay(server_update=True)
|
||||
self.config.task_stop()
|
||||
|
||||
self.globe_enter(zone)
|
||||
self.zone_init()
|
||||
self.os_order_execute(recon_scan=True, submarine_call=False)
|
||||
self.run_stronghold()
|
||||
self.run_stronghold(submarine=self.config.OpsiStronghold_SubmarineEveryCombat)
|
||||
|
||||
self.fleet_repair(revert=False)
|
||||
if self.config.OpsiStronghold_SubmarineEveryCombat:
|
||||
if self.zone.is_azur_port:
|
||||
logger.info('Already in azur port')
|
||||
else:
|
||||
self.globe_goto(self.zone_nearest_azur_port(self.zone))
|
||||
self.handle_fleet_repair_by_config(revert=False)
|
||||
self.handle_fleet_resolve(revert=False)
|
||||
|
||||
def os_stronghold(self):
|
||||
@@ -39,10 +50,17 @@ class OpsiStronghold(OSMap):
|
||||
self.clear_stronghold()
|
||||
self.config.check_task_switch()
|
||||
|
||||
def run_stronghold_one_fleet(self, fleet):
|
||||
def os_sumbarine_empty(self):
|
||||
return self.match_template_color(OS_SUBMARINE_EMPTY, offset=(20, 20))
|
||||
|
||||
def stronghold_interrupt_check(self):
|
||||
return self.os_sumbarine_empty() and self.no_meowfficer_searching()
|
||||
|
||||
def run_stronghold_one_fleet(self, fleet, submarine=False):
|
||||
"""
|
||||
Args
|
||||
fleet (BossFleet):
|
||||
submarine (bool): If use submarine every combat
|
||||
|
||||
Returns:
|
||||
bool: If all cleared.
|
||||
@@ -52,11 +70,15 @@ class OpsiStronghold(OSMap):
|
||||
HOMO_EDGE_DETECT=False,
|
||||
STORY_OPTION=0
|
||||
)
|
||||
interrupt = [self.stronghold_interrupt_check, self.is_meowfficer_searching] if submarine else None
|
||||
# Try 3 times, because fleet may stuck in fog.
|
||||
for _ in range(3):
|
||||
# Attack
|
||||
self.fleet_set(fleet.fleet_index)
|
||||
self.run_auto_search(question=False, rescan=False)
|
||||
try:
|
||||
self.run_auto_search(question=False, rescan=False, interrupt=interrupt)
|
||||
except TaskEnd:
|
||||
self.ui_ensure(page_os)
|
||||
self.hp_reset()
|
||||
self.hp_get()
|
||||
|
||||
@@ -72,6 +94,10 @@ class OpsiStronghold(OSMap):
|
||||
self.handle_fog_block(repair=True)
|
||||
self.globe_goto(prev, types='STRONGHOLD')
|
||||
return False
|
||||
elif submarine and self.os_sumbarine_empty():
|
||||
logger.info('Submarine ammo exhausted, wait for the next clear')
|
||||
self.globe_goto(self.zone_nearest_azur_port(self.zone))
|
||||
return True
|
||||
else:
|
||||
logger.info('Auto search stopped, because fleet stuck')
|
||||
# Re-enter to reset fleet position
|
||||
@@ -81,9 +107,11 @@ class OpsiStronghold(OSMap):
|
||||
self.globe_goto(prev, types='STRONGHOLD')
|
||||
continue
|
||||
|
||||
def run_stronghold(self):
|
||||
def run_stronghold(self, submarine=False):
|
||||
"""
|
||||
All fleets take turns in attacking siren stronghold.
|
||||
Args:
|
||||
submarine (bool): If use submarine every combat
|
||||
|
||||
Returns:
|
||||
bool: If success to clear.
|
||||
@@ -101,7 +129,7 @@ class OpsiStronghold(OSMap):
|
||||
self.os_order_execute(recon_scan=False, submarine_call=True)
|
||||
continue
|
||||
|
||||
result = self.run_stronghold_one_fleet(fleet)
|
||||
result = self.run_stronghold_one_fleet(fleet, submarine=submarine)
|
||||
if result:
|
||||
return True
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user