mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-09 05:47:30 +08:00
Add: Handle shared CD of recon scan and submarine call
- Add entrance of OpSi abyssal and stronghold
This commit is contained in:
parent
770363caf1
commit
6f0e3a38d0
8
alas.py
8
alas.py
@ -223,6 +223,14 @@ class AzurLaneAutoScript:
|
|||||||
from module.campaign.os_run import OSCampaignRun
|
from module.campaign.os_run import OSCampaignRun
|
||||||
OSCampaignRun(config=self.config, device=self.device).opsi_obscure()
|
OSCampaignRun(config=self.config, device=self.device).opsi_obscure()
|
||||||
|
|
||||||
|
def opsi_abyssal(self):
|
||||||
|
from module.campaign.os_run import OSCampaignRun
|
||||||
|
OSCampaignRun(config=self.config, device=self.device).opsi_abyssal()
|
||||||
|
|
||||||
|
def opsi_stronghold(self):
|
||||||
|
from module.campaign.os_run import OSCampaignRun
|
||||||
|
OSCampaignRun(config=self.config, device=self.device).opsi_stronghold()
|
||||||
|
|
||||||
def opsi_meowfficer_farming(self):
|
def opsi_meowfficer_farming(self):
|
||||||
from module.campaign.os_run import OSCampaignRun
|
from module.campaign.os_run import OSCampaignRun
|
||||||
OSCampaignRun(config=self.config, device=self.device).opsi_meowfficer_farming()
|
OSCampaignRun(config=self.config, device=self.device).opsi_meowfficer_farming()
|
||||||
|
@ -24,14 +24,14 @@ class OSCampaignRun(OSMapOperation):
|
|||||||
try:
|
try:
|
||||||
self.campaign.os_explore()
|
self.campaign.os_explore()
|
||||||
except ActionPointLimit:
|
except ActionPointLimit:
|
||||||
self.campaign.config.task_delay(minute=360)
|
self.config.opsi_task_delay(ap_limit=True)
|
||||||
|
|
||||||
def opsi_daily(self):
|
def opsi_daily(self):
|
||||||
self.load_campaign()
|
self.load_campaign()
|
||||||
try:
|
try:
|
||||||
self.campaign.os_daily()
|
self.campaign.os_daily()
|
||||||
except ActionPointLimit:
|
except ActionPointLimit:
|
||||||
self.campaign.config.task_delay(minute=360)
|
self.config.opsi_task_delay(ap_limit=True)
|
||||||
|
|
||||||
def opsi_meowfficer_farming(self):
|
def opsi_meowfficer_farming(self):
|
||||||
self.load_campaign()
|
self.load_campaign()
|
||||||
@ -45,4 +45,18 @@ class OSCampaignRun(OSMapOperation):
|
|||||||
try:
|
try:
|
||||||
self.campaign.os_obscure()
|
self.campaign.os_obscure()
|
||||||
except ActionPointLimit:
|
except ActionPointLimit:
|
||||||
self.campaign.config.task_delay(minute=360)
|
self.config.opsi_task_delay(ap_limit=True)
|
||||||
|
|
||||||
|
def opsi_abyssal(self):
|
||||||
|
self.load_campaign()
|
||||||
|
try:
|
||||||
|
self.campaign.os_abyssal()
|
||||||
|
except ActionPointLimit:
|
||||||
|
self.config.opsi_task_delay(ap_limit=True)
|
||||||
|
|
||||||
|
def opsi_stronghold(self):
|
||||||
|
self.load_campaign()
|
||||||
|
try:
|
||||||
|
self.campaign.os_stronghold()
|
||||||
|
except ActionPointLimit:
|
||||||
|
self.config.opsi_task_delay(ap_limit=True)
|
||||||
|
@ -10,6 +10,7 @@ from module.config.config_updater import ConfigUpdater
|
|||||||
from module.config.utils import *
|
from module.config.utils import *
|
||||||
from module.exception import RequestHumanTakeover, ScriptError
|
from module.exception import RequestHumanTakeover, ScriptError
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
|
from module.map.map_grids import SelectedGrids
|
||||||
|
|
||||||
|
|
||||||
class TaskEnd(Exception):
|
class TaskEnd(Exception):
|
||||||
@ -304,6 +305,53 @@ class AzurLaneConfig(ConfigUpdater, ManualConfig, GeneratedConfig):
|
|||||||
else:
|
else:
|
||||||
raise ScriptError('Missing argument in delay_next_run, should set at least one')
|
raise ScriptError('Missing argument in delay_next_run, should set at least one')
|
||||||
|
|
||||||
|
def opsi_task_delay(self, recon_scan=False, submarine_call=False, ap_limit=False):
|
||||||
|
"""
|
||||||
|
Delay the NextRun of all OpSi tasks.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
recon_scan (bool): True to delay all tasks requiring recon scan 30 min.
|
||||||
|
submarine_call (bool): True to delay all tasks requiring submarine call 60 min.
|
||||||
|
ap_limit (bool): True to delay all tasks requiring action points 360 min.
|
||||||
|
"""
|
||||||
|
if not recon_scan and not submarine_call and not ap_limit:
|
||||||
|
return None
|
||||||
|
kv = dict_to_kv({'recon_scan': recon_scan, 'submarine_call': submarine_call, 'ap_limit': ap_limit})
|
||||||
|
|
||||||
|
def delay_tasks(task_list, minutes):
|
||||||
|
next_run = datetime.now().replace(microsecond=0) + timedelta(minutes=minutes)
|
||||||
|
for task in task_list:
|
||||||
|
keys = f'{task}.Scheduler.NextRun'
|
||||||
|
current = deep_get(self.data, keys=keys, default=datetime(2020, 1, 1, 0, 0))
|
||||||
|
if current < next_run:
|
||||||
|
logger.info(f'Delay task `{task}`` to {next_run} ({kv})')
|
||||||
|
self.modified[keys] = next_run
|
||||||
|
|
||||||
|
def is_submarine_call(task):
|
||||||
|
return deep_get(self.data, keys=f'{task}.OpsiFleet.Submarine', default=False) \
|
||||||
|
or 'submarine' in deep_get(self.data, keys=f'{task}.OpsiFleetFilter.Filter', default='').lower()
|
||||||
|
|
||||||
|
def is_not_force_run(task):
|
||||||
|
return not (deep_get(self.data, keys=f'{task}.OpsiExplore.SpecialRadar', default=False)
|
||||||
|
or deep_get(self.data, keys=f'{task}.OpsiExplore.ForceRun', default=False)
|
||||||
|
or deep_get(self.data, keys=f'{task}.OpsiObscure.ForceRun', default=False)
|
||||||
|
or deep_get(self.data, keys=f'{task}.OpsiAbyssal.ForceRun', default=False)
|
||||||
|
or deep_get(self.data, keys=f'{task}.OpsiStronghold.ForceRun', default=False))
|
||||||
|
|
||||||
|
if recon_scan:
|
||||||
|
tasks = SelectedGrids(['OpsiExplore', 'OpsiObscure', 'OpsiStronghold'])
|
||||||
|
delay_tasks(tasks.filter(is_not_force_run).grids, minutes=30)
|
||||||
|
if submarine_call:
|
||||||
|
tasks = SelectedGrids(['OpsiExplore', 'OpsiDaily', 'OpsiObscure', 'OpsiAbyssal', 'OpsiFleetFilter',
|
||||||
|
'OpsiMeowfficerFarming'])
|
||||||
|
delay_tasks(tasks.filter(is_submarine_call).filter(is_not_force_run).grids, minutes=60)
|
||||||
|
if ap_limit:
|
||||||
|
tasks = SelectedGrids(['OpsiExplore', 'OpsiDaily', 'OpsiObscure', 'OpsiAbyssal', 'OpsiFleetFilter',
|
||||||
|
'OpsiMeowfficerFarming'])
|
||||||
|
delay_tasks(tasks.filter(is_submarine_call).filter(is_not_force_run).grids, minutes=360)
|
||||||
|
|
||||||
|
self.save()
|
||||||
|
|
||||||
def task_call(self, task):
|
def task_call(self, task):
|
||||||
"""
|
"""
|
||||||
Call another task to run.
|
Call another task to run.
|
||||||
|
@ -10,7 +10,7 @@ class ManualConfig:
|
|||||||
> Gacha > SupplyPack
|
> Gacha > SupplyPack
|
||||||
> Reward > BattlePass
|
> Reward > BattlePass
|
||||||
> ShopFrequent > ShopOnce > Shipyard > DataKey
|
> ShopFrequent > ShopOnce > Shipyard > DataKey
|
||||||
> OpsiExplore > OpsiObscure
|
> OpsiExplore > OpsiAbyssal > OpsiStronghold > OpsiObscure
|
||||||
> Exercise > Daily > Hard > OpsiAshAssist
|
> Exercise > Daily > Hard > OpsiAshAssist
|
||||||
> Sos > EventSp > EventAb > EventCd > RaidDaily > WarArchives
|
> Sos > EventSp > EventAb > EventCd > RaidDaily > WarArchives
|
||||||
> OpsiDaily > OpsiMeowfficerFarming
|
> OpsiDaily > OpsiMeowfficerFarming
|
||||||
|
@ -127,7 +127,7 @@ class GlobeCamera(GlobeOperation, ZoneManager):
|
|||||||
out: IN_GLOBE, zone selected, ZONE_ENTRANCE
|
out: IN_GLOBE, zone selected, ZONE_ENTRANCE
|
||||||
"""
|
"""
|
||||||
zone = self.name_to_zone(zone)
|
zone = self.name_to_zone(zone)
|
||||||
logger.info(f'Globe focus_to: {zone}')
|
logger.info(f'Globe focus_to: {zone.zone_id}')
|
||||||
|
|
||||||
interval = Timer(2, count=2)
|
interval = Timer(2, count=2)
|
||||||
while 1:
|
while 1:
|
||||||
|
@ -18,6 +18,7 @@ class OperationSiren(Reward, OSMap):
|
|||||||
out: IN_MAP
|
out: IN_MAP
|
||||||
"""
|
"""
|
||||||
logger.hr('OS init', level=1)
|
logger.hr('OS init', level=1)
|
||||||
|
self.config.override(Submarine_Fleet=1, Submarine_Mode='every_combat')
|
||||||
|
|
||||||
# UI switching
|
# UI switching
|
||||||
if self.is_in_map():
|
if self.is_in_map():
|
||||||
@ -230,6 +231,10 @@ class OperationSiren(Reward, OSMap):
|
|||||||
self.zone_init()
|
self.zone_init()
|
||||||
if result > 1:
|
if result > 1:
|
||||||
self.globe_goto(self.zone, refresh=True)
|
self.globe_goto(self.zone, refresh=True)
|
||||||
|
self.fleet_set(self.config.OpsiFleet_Fleet)
|
||||||
|
self.os_order_execute(
|
||||||
|
recon_scan=False,
|
||||||
|
submarine_call=self.config.OpsiFleet_Submarine)
|
||||||
self.run_auto_search()
|
self.run_auto_search()
|
||||||
self.handle_fleet_repair(revert=False)
|
self.handle_fleet_repair(revert=False)
|
||||||
self.config.check_task_switch()
|
self.config.check_task_switch()
|
||||||
@ -276,6 +281,10 @@ class OperationSiren(Reward, OSMap):
|
|||||||
else:
|
else:
|
||||||
logger.hr(f'OS meowfficer farming, zone_id={zone.zone_id}', level=1)
|
logger.hr(f'OS meowfficer farming, zone_id={zone.zone_id}', level=1)
|
||||||
self.globe_goto(zone)
|
self.globe_goto(zone)
|
||||||
|
self.fleet_set(self.config.OpsiFleet_Fleet)
|
||||||
|
self.os_order_execute(
|
||||||
|
recon_scan=False,
|
||||||
|
submarine_call=self.config.OpsiFleet_Submarine)
|
||||||
self.run_auto_search()
|
self.run_auto_search()
|
||||||
self.handle_fleet_repair(revert=False)
|
self.handle_fleet_repair(revert=False)
|
||||||
self.globe_goto(self.zone_nearest_azur_port(zone=zone))
|
self.globe_goto(self.zone_nearest_azur_port(zone=zone))
|
||||||
@ -288,6 +297,10 @@ class OperationSiren(Reward, OSMap):
|
|||||||
|
|
||||||
logger.hr(f'OS meowfficer farming, zone_id={zones[0].zone_id}', level=1)
|
logger.hr(f'OS meowfficer farming, zone_id={zones[0].zone_id}', level=1)
|
||||||
self.globe_goto(zones[0])
|
self.globe_goto(zones[0])
|
||||||
|
self.fleet_set(self.config.OpsiFleet_Fleet)
|
||||||
|
self.os_order_execute(
|
||||||
|
recon_scan=False,
|
||||||
|
submarine_call=self.config.OpsiFleet_Submarine)
|
||||||
self.run_auto_search()
|
self.run_auto_search()
|
||||||
self.handle_fleet_repair(revert=False)
|
self.handle_fleet_repair(revert=False)
|
||||||
self.config.check_task_switch()
|
self.config.check_task_switch()
|
||||||
@ -325,11 +338,10 @@ class OperationSiren(Reward, OSMap):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
logger.hr(f'OS explore {zone}', level=1)
|
logger.hr(f'OS explore {zone}', level=1)
|
||||||
if self.config.OpsiExplore_SpecialRadar:
|
self.fleet_set(self.config.OpsiFleet_Fleet)
|
||||||
self.os_order_execute(recon_scan=False, submarine_call=False)
|
self.os_order_execute(
|
||||||
else:
|
recon_scan=not self.config.OpsiExplore_SpecialRadar,
|
||||||
self.os_order_execute(recon_scan=True, submarine_call=False)
|
submarine_call=self.config.OpsiFleet_Submarine)
|
||||||
self.config.task_delay(minute=30)
|
|
||||||
self.run_auto_search()
|
self.run_auto_search()
|
||||||
self.config.OpsiExplore_LastZone = zone
|
self.config.OpsiExplore_LastZone = zone
|
||||||
logger.info(f'Zone cleared: {self.name_to_zone(zone)}')
|
logger.info(f'Zone cleared: {self.name_to_zone(zone)}')
|
||||||
@ -355,20 +367,11 @@ class OperationSiren(Reward, OSMap):
|
|||||||
|
|
||||||
self.zone_init()
|
self.zone_init()
|
||||||
self.fleet_set(self.config.OpsiFleet_Fleet)
|
self.fleet_set(self.config.OpsiFleet_Fleet)
|
||||||
self.os_order_execute(recon_scan=True, submarine_call=self.config.OpsiFleet_Submarine)
|
self.os_order_execute(
|
||||||
|
recon_scan=True,
|
||||||
# Delay next run 30min or 60min.
|
submarine_call=self.config.OpsiFleet_Submarine)
|
||||||
if self.config.OpsiFleet_Submarine:
|
|
||||||
delta = 60
|
|
||||||
backup_submarine = self.config.temporary(Submarine_Fleet=1, Submarine_Mode='every_combat')
|
|
||||||
else:
|
|
||||||
delta = 30
|
|
||||||
backup_submarine = None
|
|
||||||
if not self.config.OpsiObscure_ForceRun:
|
|
||||||
self.config.task_delay(minute=delta)
|
|
||||||
|
|
||||||
self.run_auto_search()
|
self.run_auto_search()
|
||||||
backup_submarine.recover() if backup_submarine is not None else None
|
|
||||||
self.map_exit()
|
self.map_exit()
|
||||||
self.handle_fleet_repair(revert=False)
|
self.handle_fleet_repair(revert=False)
|
||||||
|
|
||||||
@ -384,7 +387,7 @@ class OperationSiren(Reward, OSMap):
|
|||||||
def clear_abyssal(self):
|
def clear_abyssal(self):
|
||||||
"""
|
"""
|
||||||
Get one abyssal logger in storage,
|
Get one abyssal logger in storage,
|
||||||
Attack abyssal boss,
|
attack abyssal boss,
|
||||||
repair fleets in port.
|
repair fleets in port.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
@ -411,6 +414,33 @@ class OperationSiren(Reward, OSMap):
|
|||||||
self.clear_abyssal()
|
self.clear_abyssal()
|
||||||
self.config.check_task_switch()
|
self.config.check_task_switch()
|
||||||
|
|
||||||
|
def clear_stronghold(self):
|
||||||
|
"""
|
||||||
|
Find a siren stronghold on globe map,
|
||||||
|
clear stronghold,
|
||||||
|
repair fleets in port.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ActionPointLimit:
|
||||||
|
TaskEnd: If no more strongholds.
|
||||||
|
RequestHumanTakeover: If unable to clear boss, fleets exhausted.
|
||||||
|
"""
|
||||||
|
logger.hr('OS clear stronghold', level=1)
|
||||||
|
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()
|
||||||
|
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
self.fleet_repair(revert=False)
|
||||||
|
|
||||||
|
def os_stronghold(self):
|
||||||
|
while 1:
|
||||||
|
self.clear_abyssal()
|
||||||
|
self.config.check_task_switch()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
self = OperationSiren('alas', task='OpsiObscure')
|
self = OperationSiren('alas', task='OpsiObscure')
|
||||||
|
@ -114,6 +114,8 @@ class MapOrderHandler(MapOperation, ActionPointHandler, EnemySearchingHandler, Z
|
|||||||
if submarine_call:
|
if submarine_call:
|
||||||
self.order_execute(ORDER_SUBMARINE)
|
self.order_execute(ORDER_SUBMARINE)
|
||||||
|
|
||||||
|
self.config.opsi_task_delay(recon_scan=recon_scan, submarine_call=submarine_call)
|
||||||
|
|
||||||
# backup.recover()
|
# backup.recover()
|
||||||
|
|
||||||
def handle_map_cat_attack(self):
|
def handle_map_cat_attack(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user