mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 06:18:21 +08:00
Refactor: Opsi task managing
This commit is contained in:
85
module/os/tasks/daily.py
Normal file
85
module/os/tasks/daily.py
Normal file
@@ -0,0 +1,85 @@
|
||||
import numpy as np
|
||||
|
||||
from module.logger import logger
|
||||
from module.os.map import OSMap
|
||||
|
||||
|
||||
class OpsiDaily(OSMap):
|
||||
def os_port_mission(self):
|
||||
"""
|
||||
Visit all ports and do the daily mission in it.
|
||||
"""
|
||||
logger.hr('OS port mission', level=1)
|
||||
ports = ['NY City', 'Dakar', 'Taranto', 'Gibraltar', 'Brest', 'Liverpool', 'Kiel', 'St. Petersburg']
|
||||
if np.random.uniform() > 0.5:
|
||||
ports.reverse()
|
||||
|
||||
for port in ports:
|
||||
port = self.name_to_zone(port)
|
||||
logger.hr(f'OS port daily in {port}', level=2)
|
||||
self.globe_goto(port)
|
||||
|
||||
self.run_auto_search()
|
||||
self.handle_after_auto_search()
|
||||
|
||||
def os_finish_daily_mission(self, question=True, rescan=None):
|
||||
"""
|
||||
Finish all daily mission in Operation Siren.
|
||||
Suggest to run os_port_daily to accept missions first.
|
||||
|
||||
Args:
|
||||
question (bool): refer to run_auto_search
|
||||
rescan (None, bool): refer to run_auto_search
|
||||
|
||||
Returns:
|
||||
int: Number of missions finished
|
||||
"""
|
||||
logger.hr('OS finish daily mission', level=1)
|
||||
count = 0
|
||||
while True:
|
||||
result = self.os_get_next_mission()
|
||||
if not result:
|
||||
break
|
||||
|
||||
if result != 'pinned_at_archive_zone':
|
||||
# The name of archive zone is "archive zone", which is not an existing zone.
|
||||
# After archive zone, it go back to previous zone automatically.
|
||||
self.zone_init()
|
||||
if result == 'already_at_mission_zone':
|
||||
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 and result != 'pinned_at_archive_zone')
|
||||
self.run_auto_search(question, rescan)
|
||||
self.handle_after_auto_search()
|
||||
count += 1
|
||||
self.config.check_task_switch()
|
||||
|
||||
return count
|
||||
|
||||
def os_daily(self):
|
||||
# Finish existing missions first
|
||||
# No need anymore, os_mission_overview_accept() is able to handle
|
||||
# self.os_finish_daily_mission()
|
||||
|
||||
# Clear tuning samples daily
|
||||
if self.config.OpsiDaily_UseTuningSample:
|
||||
self.tuning_sample_use()
|
||||
|
||||
while True:
|
||||
# If unable to receive more dailies, finish them and try again.
|
||||
success = self.os_mission_overview_accept()
|
||||
# Re-init zone name
|
||||
# MISSION_ENTER appear from the right,
|
||||
# need to confirm that the animation has ended,
|
||||
# or it will click on MAP_GOTO_GLOBE
|
||||
self.zone_init()
|
||||
self.os_finish_daily_mission()
|
||||
if self.is_in_opsi_explore():
|
||||
self.os_port_mission()
|
||||
break
|
||||
if success:
|
||||
break
|
||||
|
||||
self.config.task_delay(server_update=True)
|
||||
Reference in New Issue
Block a user