mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-13 09:07:02 +08:00
Add: Task switch
This commit is contained in:
@@ -21,6 +21,7 @@ class CampaignRun(UI):
|
||||
config: AzurLaneConfig
|
||||
campaign: CampaignBase
|
||||
run_count: int
|
||||
run_limit: int
|
||||
|
||||
def load_campaign(self, name, folder='campaign_main'):
|
||||
"""
|
||||
@@ -66,7 +67,7 @@ class CampaignRun(UI):
|
||||
bool: If triggered a stop condition.
|
||||
"""
|
||||
# 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')
|
||||
self.config.StopCondition_RunCount = 0
|
||||
return True
|
||||
@@ -137,6 +138,7 @@ class CampaignRun(UI):
|
||||
name, folder = self.handle_stage_name(name, folder)
|
||||
self.load_campaign(name, folder=folder)
|
||||
self.run_count = 0
|
||||
self.run_limit = self.config.StopCondition_RunCount
|
||||
while 1:
|
||||
# End
|
||||
if total and self.run_count == total:
|
||||
@@ -189,5 +191,7 @@ class CampaignRun(UI):
|
||||
if self.run_count >= 1:
|
||||
logger.hr('Triggered one-time stage limit')
|
||||
break
|
||||
# Scheduler
|
||||
self.config.task_switch()
|
||||
|
||||
self.campaign.ensure_auto_search_exit()
|
||||
|
||||
@@ -220,6 +220,20 @@ class AzurLaneConfig(ManualConfig, GeneratedConfig):
|
||||
else:
|
||||
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
|
||||
def campaign_name(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user