mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 00:28:20 +08:00
Add: Task switch
This commit is contained in:
@@ -21,6 +21,7 @@ class CampaignRun(UI):
|
|||||||
config: AzurLaneConfig
|
config: AzurLaneConfig
|
||||||
campaign: CampaignBase
|
campaign: CampaignBase
|
||||||
run_count: int
|
run_count: int
|
||||||
|
run_limit: int
|
||||||
|
|
||||||
def load_campaign(self, name, folder='campaign_main'):
|
def load_campaign(self, name, folder='campaign_main'):
|
||||||
"""
|
"""
|
||||||
@@ -66,7 +67,7 @@ class CampaignRun(UI):
|
|||||||
bool: If triggered a stop condition.
|
bool: If triggered a stop condition.
|
||||||
"""
|
"""
|
||||||
# Run count limit
|
# Run count limit
|
||||||
if self.config.StopCondition_RunCount <= 0:
|
if self.run_limit and self.config.StopCondition_RunCount <= 0:
|
||||||
logger.hr('Triggered stop condition: Run count')
|
logger.hr('Triggered stop condition: Run count')
|
||||||
self.config.StopCondition_RunCount = 0
|
self.config.StopCondition_RunCount = 0
|
||||||
return True
|
return True
|
||||||
@@ -137,6 +138,7 @@ class CampaignRun(UI):
|
|||||||
name, folder = self.handle_stage_name(name, folder)
|
name, folder = self.handle_stage_name(name, folder)
|
||||||
self.load_campaign(name, folder=folder)
|
self.load_campaign(name, folder=folder)
|
||||||
self.run_count = 0
|
self.run_count = 0
|
||||||
|
self.run_limit = self.config.StopCondition_RunCount
|
||||||
while 1:
|
while 1:
|
||||||
# End
|
# End
|
||||||
if total and self.run_count == total:
|
if total and self.run_count == total:
|
||||||
@@ -189,5 +191,7 @@ class CampaignRun(UI):
|
|||||||
if self.run_count >= 1:
|
if self.run_count >= 1:
|
||||||
logger.hr('Triggered one-time stage limit')
|
logger.hr('Triggered one-time stage limit')
|
||||||
break
|
break
|
||||||
|
# Scheduler
|
||||||
|
self.config.task_switch()
|
||||||
|
|
||||||
self.campaign.ensure_auto_search_exit()
|
self.campaign.ensure_auto_search_exit()
|
||||||
|
|||||||
@@ -220,6 +220,20 @@ class AzurLaneConfig(ManualConfig, GeneratedConfig):
|
|||||||
else:
|
else:
|
||||||
raise TaskEnd
|
raise TaskEnd
|
||||||
|
|
||||||
|
def task_switch(self):
|
||||||
|
"""
|
||||||
|
Check if needs to switch task.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
TaskEnd: If task switched
|
||||||
|
"""
|
||||||
|
prev = self.task
|
||||||
|
self.load()
|
||||||
|
new = self.get_next()
|
||||||
|
if prev != new:
|
||||||
|
logger.info(f'Switch task `{prev}` to `{new}`')
|
||||||
|
self.task_stop()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def campaign_name(self):
|
def campaign_name(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user