Add: Task Hospital to scheduler

This commit is contained in:
LmeSzinc 2025-03-28 01:17:10 +08:00
parent 985f49279f
commit 3e74a8888d
4 changed files with 64 additions and 4 deletions

View File

@ -371,6 +371,10 @@ class AzurLaneAutoScript:
from module.raid.run import RaidRun
RaidRun(config=self.config, device=self.device).run()
def hospital(self):
from module.event_hospital.hospital import Hospital
Hospital(config=self.config, device=self.device).run()
def coalition(self):
from module.coalition.coalition import Coalition
Coalition(config=self.config, device=self.device).run()

View File

@ -24,7 +24,7 @@ class ManualConfig:
> Daily > Hard > OpsiAshBeacon > OpsiAshAssist > OpsiMonthBoss
> Sos > EventSp > EventA > EventB > EventC > EventD
> RaidDaily > CoalitionSp > WarArchives > MaritimeEscort
> Event > Event2 > Raid > Coalition > Main > Main2 > Main3
> Event > Event2 > Raid > Hospital > Coalition > Main > Main2 > Main3
> OpsiMeowfficerFarming
> GemsFarming
> OpsiHazard1Leveling

View File

@ -9,6 +9,7 @@ from module.event_hospital.assets import *
from module.event_hospital.ui import HospitalUI
from module.logger import logger
from module.map.assets import FLEET_PREPARATION
from module.ui.page import page_hospital
from module.ui.scroll import Scroll
@ -138,8 +139,7 @@ class HospitalClue(HospitalUI):
in: Any sub page of hospital event
out: is_in_clue
"""
logger.info('Hospital goto clue')
self.interval_clear(HOSIPITAL_CLUE_CHECK)
logger.info('Hospital clue enter')
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
@ -150,6 +150,26 @@ class HospitalClue(HospitalUI):
if self.handle_clue_exit():
continue
def clue_exit(self, skip_first_screenshot=True):
"""
Pages:
in: Any sub page of hospital event
out: page_hospital
"""
logger.info('Hospital clue exit')
self.interval_clear(HOSIPITAL_CLUE_CHECK)
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
if self.ui_page_appear(page_hospital):
break
if self.handle_clue_exit():
continue
if self.appear_then_click(HOSIPITAL_CLUE_CHECK, offset=(20, 20), interval=2):
continue
def invest_enter(self, invest, skip_first_screenshot=True):
"""
Args:

View File

@ -1,7 +1,11 @@
from module.event_hospital.clue import HospitalClue
from module.config.config import TaskEnd
from module.event_hospital.assets import *
from module.event_hospital.clue import HospitalClue
from module.event_hospital.combat import HospitalCombat
from module.exception import ScriptEnd
from module.logger import logger
from module.raid.raid import OilExhausted
from module.ui.page import page_hospital
class Hospital(HospitalClue, HospitalCombat):
@ -9,8 +13,13 @@ class Hospital(HospitalClue, HospitalCombat):
"""
Do all invest in page
"""
self.config.override(Fleet_FleetOrder='fleet1_all_fleet2_standby')
while 1:
logger.hr('Loop hospital invest', level=2)
# Scheduler
# May raise ScriptEnd
self.emotion.check_reduce(battle=1)
invest = next(self.iter_invest(), None)
if invest is None:
logger.info('No more invest')
@ -19,6 +28,11 @@ class Hospital(HospitalClue, HospitalCombat):
self.invest_enter(invest)
self.hospital_combat()
# Scheduler
# May raise TaskEnd
if self.config.task_switched():
self.config.task_stop()
self.claim_invest_reward()
logger.info('Loop hospital invest end')
@ -68,6 +82,28 @@ class Hospital(HospitalClue, HospitalCombat):
logger.info('Loop hospital aside end')
def run(self):
self.ui_ensure(page_hospital)
self.clue_enter()
try:
self.loop_aside()
except OilExhausted:
self.clue_exit()
logger.hr('Triggered stop condition: Oil limit')
self.config.task_delay(minute=(120, 240))
except ScriptEnd as e:
logger.hr('Script end')
logger.info(str(e))
self.clue_exit()
raise
except TaskEnd:
self.clue_exit()
raise
# Scheduler
self.config.task_delay(server_update=True)
if __name__ == '__main__':
self = Hospital('alas')