mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-08 12:07:36 +08:00
優化了campaign_abcd的執行邏輯並改為通用的判定(但目前沒有活動無法測試有效性)
This commit is contained in:
parent
3d28b9785c
commit
b51ea492fb
16
alas.py
16
alas.py
@ -226,20 +226,20 @@ class AzurLaneAutoScript:
|
||||
RaidDaily(config=self.config, device=self.device).run()
|
||||
|
||||
def event_a(self):
|
||||
from module.event.campaign_abcd import CampaignA
|
||||
CampaignA(config=self.config, device=self.device).run()
|
||||
from module.event.campaign_abcd import CampaignABCD
|
||||
CampaignABCD(config=self.config, device=self.device).run(DailyEventABCD=self.config.EventA_StageFilter, LastStageABCD=self.config.EventA_LastStage)
|
||||
|
||||
def event_b(self):
|
||||
from module.event.campaign_abcd import CampaignB
|
||||
CampaignB(config=self.config, device=self.device).run()
|
||||
from module.event.campaign_abcd import CampaignABCD
|
||||
CampaignABCD(config=self.config, device=self.device).run(DailyEventABCD=self.config.EventB_StageFilter, LastStageABCD=self.config.EventB_LastStage)
|
||||
|
||||
def event_c(self):
|
||||
from module.event.campaign_abcd import CampaignC
|
||||
CampaignC(config=self.config, device=self.device).run()
|
||||
from module.event.campaign_abcd import CampaignABCD
|
||||
CampaignABCD(config=self.config, device=self.device).run(DailyEventABCD=self.config.EventC_StageFilter, LastStageABCD=self.config.EventC_LastStage)
|
||||
|
||||
def event_d(self):
|
||||
from module.event.campaign_abcd import CampaignD
|
||||
CampaignD(config=self.config, device=self.device).run()
|
||||
from module.event.campaign_abcd import CampaignABCD
|
||||
CampaignABCD(config=self.config, device=self.device).run(DailyEventABCD=self.config.EventD_StageFilter, LastStageABCD=self.config.EventD_LastStage)
|
||||
|
||||
def event_sp(self):
|
||||
from module.event.campaign_sp import CampaignSP
|
||||
|
@ -6,14 +6,14 @@ from module.event.base import STAGE_FILTER, EventBase, EventStage
|
||||
from module.logger import logger
|
||||
|
||||
|
||||
class CampaignA(EventBase):
|
||||
class CampaignABCD(EventBase):
|
||||
def run(self, *args, **kwargs):
|
||||
# Filter map files
|
||||
stages = [EventStage(file) for file in os.listdir(f'./campaign/{self.config.Campaign_Event}')]
|
||||
stages = self.convert_stages(stages)
|
||||
logger.attr('Stage', [str(stage) for stage in stages])
|
||||
logger.attr('StageFilter', self.config.EventA_StageFilter)
|
||||
STAGE_FILTER.load(self.config.EventA_StageFilter)
|
||||
logger.attr('StageFilter', kwargs.get("DailyEventABCD"))
|
||||
STAGE_FILTER.load(kwargs.get("DailyEventABCD"))
|
||||
self.convert_stages(STAGE_FILTER)
|
||||
stages = [str(stage) for stage in STAGE_FILTER.apply(stages)]
|
||||
logger.attr('Filter sort', ' > '.join(stages))
|
||||
@ -24,12 +24,12 @@ class CampaignA(EventBase):
|
||||
self.config.task_stop()
|
||||
|
||||
# Start from last stage
|
||||
logger.info(f'LastStage {self.config.EventA_LastStage}, recorded at {self.config.Scheduler_NextRun}')
|
||||
logger.info(f'LastStage {kwargs["last_stage"]}, recorded at {self.config.Scheduler_NextRun}')
|
||||
if get_server_last_update(self.config.Scheduler_ServerUpdate) >= self.config.Scheduler_NextRun:
|
||||
logger.info('LastStage outdated, reset')
|
||||
self.config.EventA_LastStage = 0
|
||||
kwargs["last_stage"] = 0
|
||||
else:
|
||||
last = str(self.config.EventA_LastStage).lower()
|
||||
last = str(kwargs["last_stage"]).lower()
|
||||
last = self.convert_stages(last)
|
||||
if last in stages:
|
||||
stages = stages[stages.index(last) + 1:]
|
||||
@ -47,163 +47,7 @@ class CampaignA(EventBase):
|
||||
pass
|
||||
if self.run_count > 0:
|
||||
with self.config.multi_set():
|
||||
self.config.EventA_LastStage = stage
|
||||
self.config.task_delay(minute=0)
|
||||
else:
|
||||
self.config.task_stop()
|
||||
if self.config.task_switched():
|
||||
self.config.task_stop()
|
||||
|
||||
# Scheduler
|
||||
self.config.task_delay(server_update=True)
|
||||
|
||||
|
||||
class CampaignB(EventBase):
|
||||
def run(self, *args, **kwargs):
|
||||
# Filter map files
|
||||
stages = [EventStage(file) for file in os.listdir(f'./campaign/{self.config.Campaign_Event}')]
|
||||
stages = self.convert_stages(stages)
|
||||
logger.attr('Stage', [str(stage) for stage in stages])
|
||||
logger.attr('StageFilter', self.config.EventB_StageFilter)
|
||||
STAGE_FILTER.load(self.config.EventB_StageFilter)
|
||||
self.convert_stages(STAGE_FILTER)
|
||||
stages = [str(stage) for stage in STAGE_FILTER.apply(stages)]
|
||||
logger.attr('Filter sort', ' > '.join(stages))
|
||||
|
||||
if not stages:
|
||||
logger.warning('No stage satisfy current filter')
|
||||
self.config.Scheduler_Enable = False
|
||||
self.config.task_stop()
|
||||
|
||||
# Start from last stage
|
||||
logger.info(f'LastStage {self.config.EventB_LastStage}, recorded at {self.config.Scheduler_NextRun}')
|
||||
if get_server_last_update(self.config.Scheduler_ServerUpdate) >= self.config.Scheduler_NextRun:
|
||||
logger.info('LastStage outdated, reset')
|
||||
self.config.EventB_LastStage = 0
|
||||
else:
|
||||
last = str(self.config.EventB_LastStage).lower()
|
||||
last = self.convert_stages(last)
|
||||
if last in stages:
|
||||
stages = stages[stages.index(last) + 1:]
|
||||
logger.attr('Filter sort', ' > '.join(stages))
|
||||
else:
|
||||
logger.info('Start from the beginning')
|
||||
|
||||
# Run
|
||||
for stage in stages:
|
||||
stage = str(stage)
|
||||
try:
|
||||
super().run(name=stage, folder=self.config.Campaign_Event, total=1)
|
||||
except TaskEnd:
|
||||
# Catch task switch
|
||||
pass
|
||||
if self.run_count > 0:
|
||||
with self.config.multi_set():
|
||||
self.config.EventB_LastStage = stage
|
||||
self.config.task_delay(minute=0)
|
||||
else:
|
||||
self.config.task_stop()
|
||||
if self.config.task_switched():
|
||||
self.config.task_stop()
|
||||
|
||||
# Scheduler
|
||||
self.config.task_delay(server_update=True)
|
||||
|
||||
|
||||
class CampaignC(EventBase):
|
||||
def run(self, *args, **kwargs):
|
||||
# Filter map files
|
||||
stages = [EventStage(file) for file in os.listdir(f'./campaign/{self.config.Campaign_Event}')]
|
||||
stages = self.convert_stages(stages)
|
||||
logger.attr('Stage', [str(stage) for stage in stages])
|
||||
logger.attr('StageFilter', self.config.EventC_StageFilter)
|
||||
STAGE_FILTER.load(self.config.EventC_StageFilter)
|
||||
self.convert_stages(STAGE_FILTER)
|
||||
stages = [str(stage) for stage in STAGE_FILTER.apply(stages)]
|
||||
logger.attr('Filter sort', ' > '.join(stages))
|
||||
|
||||
if not stages:
|
||||
logger.warning('No stage satisfy current filter')
|
||||
self.config.Scheduler_Enable = False
|
||||
self.config.task_stop()
|
||||
|
||||
# Start from last stage
|
||||
logger.info(f'LastStage {self.config.EventC_LastStage}, recorded at {self.config.Scheduler_NextRun}')
|
||||
if get_server_last_update(self.config.Scheduler_ServerUpdate) >= self.config.Scheduler_NextRun:
|
||||
logger.info('LastStage outdated, reset')
|
||||
self.config.EventC_LastStage = 0
|
||||
else:
|
||||
last = str(self.config.EventC_LastStage).lower()
|
||||
last = self.convert_stages(last)
|
||||
if last in stages:
|
||||
stages = stages[stages.index(last) + 1:]
|
||||
logger.attr('Filter sort', ' > '.join(stages))
|
||||
else:
|
||||
logger.info('Start from the beginning')
|
||||
|
||||
# Run
|
||||
for stage in stages:
|
||||
stage = str(stage)
|
||||
try:
|
||||
super().run(name=stage, folder=self.config.Campaign_Event, total=1)
|
||||
except TaskEnd:
|
||||
# Catch task switch
|
||||
pass
|
||||
if self.run_count > 0:
|
||||
with self.config.multi_set():
|
||||
self.config.EventC_LastStage = stage
|
||||
self.config.task_delay(minute=0)
|
||||
else:
|
||||
self.config.task_stop()
|
||||
if self.config.task_switched():
|
||||
self.config.task_stop()
|
||||
|
||||
# Scheduler
|
||||
self.config.task_delay(server_update=True)
|
||||
|
||||
|
||||
class CampaignD(EventBase):
|
||||
def run(self, *args, **kwargs):
|
||||
# Filter map files
|
||||
stages = [EventStage(file) for file in os.listdir(f'./campaign/{self.config.Campaign_Event}')]
|
||||
stages = self.convert_stages(stages)
|
||||
logger.attr('Stage', [str(stage) for stage in stages])
|
||||
logger.attr('StageFilter', self.config.EventD_StageFilter)
|
||||
STAGE_FILTER.load(self.config.EventD_StageFilter)
|
||||
self.convert_stages(STAGE_FILTER)
|
||||
stages = [str(stage) for stage in STAGE_FILTER.apply(stages)]
|
||||
logger.attr('Filter sort', ' > '.join(stages))
|
||||
|
||||
if not stages:
|
||||
logger.warning('No stage satisfy current filter')
|
||||
self.config.Scheduler_Enable = False
|
||||
self.config.task_stop()
|
||||
|
||||
# Start from last stage
|
||||
logger.info(f'LastStage {self.config.EventD_LastStage}, recorded at {self.config.Scheduler_NextRun}')
|
||||
if get_server_last_update(self.config.Scheduler_ServerUpdate) >= self.config.Scheduler_NextRun:
|
||||
logger.info('LastStage outdated, reset')
|
||||
self.config.EventD_LastStage = 0
|
||||
else:
|
||||
last = str(self.config.EventD_LastStage).lower()
|
||||
last = self.convert_stages(last)
|
||||
if last in stages:
|
||||
stages = stages[stages.index(last) + 1:]
|
||||
logger.attr('Filter sort', ' > '.join(stages))
|
||||
else:
|
||||
logger.info('Start from the beginning')
|
||||
|
||||
# Run
|
||||
for stage in stages:
|
||||
stage = str(stage)
|
||||
try:
|
||||
super().run(name=stage, folder=self.config.Campaign_Event, total=1)
|
||||
except TaskEnd:
|
||||
# Catch task switch
|
||||
pass
|
||||
if self.run_count > 0:
|
||||
with self.config.multi_set():
|
||||
self.config.EventD_LastStage = stage
|
||||
kwargs["last_stage"] = stage
|
||||
self.config.task_delay(minute=0)
|
||||
else:
|
||||
self.config.task_stop()
|
||||
|
Loading…
Reference in New Issue
Block a user