Opt: Auto convert chapter A/B/C/D to T/HT

This commit is contained in:
LmeSzinc 2022-07-15 01:51:04 +08:00
parent 37220a7104
commit 206b546eb1
4 changed files with 51 additions and 0 deletions

View File

@ -147,6 +147,25 @@ class CampaignRun(UI):
name = 'sp'
if folder == 'event_20220324_cn' and name == 'esp':
name = 'sp'
convert = {
'a1': 't1',
'a2': 't2',
'a3': 't3',
'b1': 't4',
'b2': 't5',
'b3': 't6',
'c1': 'ht1',
'c2': 'ht2',
'c3': 'ht3',
'd1': 'ht4',
'd2': 'ht5',
'd3': 'ht6',
}
if folder == 'event_20200917_cn':
name = convert.get(name, name)
else:
reverse = {v: k for k, v in convert.items()}
name = reverse.get(name, name)
return name, folder

View File

@ -26,3 +26,29 @@ class EventBase(CampaignRun):
self.campaign.config.temporary(
MAP_IS_ONE_TIME_STAGE=False
)
def convert_stages(self, stages):
"""
Convert whatever input to the correct stage name
"""
def convert(n):
return self.handle_stage_name(n, folder=self.config.Campaign_Event)[0]
if isinstance(stages, str):
return convert(stages)
if isinstance(stages, list):
out = []
for name in stages:
if isinstance(name, EventStage):
name.stage = convert(name.stage)
out.append(name)
elif isinstance(name, str):
out.append(convert(name))
else:
out.append(name)
return out
if isinstance(stages, Filter):
stages.filter = [[convert(selection[0])] for selection in stages.filter]
return stages
return stages

View File

@ -10,9 +10,11 @@ class CampaignAB(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.EventAb_StageFilter)
STAGE_FILTER.load(self.config.EventAb_StageFilter)
self.convert_stages(STAGE_FILTER)
stages = [str(stage) for stage in STAGE_FILTER.apply(stages)]
logger.attr('Filter sort', ' > '.join(stages))
@ -28,6 +30,7 @@ class CampaignAB(EventBase):
self.config.EventAb_LastStage = 0
else:
last = str(self.config.EventAb_LastStage).lower()
last = self.convert_stages(last)
if last in stages:
stages = stages[stages.index(last) + 1:]
logger.attr('Filter sort', ' > '.join(stages))

View File

@ -10,9 +10,11 @@ class CampaignCD(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.EventCd_StageFilter)
STAGE_FILTER.load(self.config.EventCd_StageFilter)
self.convert_stages(STAGE_FILTER)
stages = [str(stage) for stage in STAGE_FILTER.apply(stages)]
logger.attr('Filter sort', ' > '.join(stages))
@ -28,6 +30,7 @@ class CampaignCD(EventBase):
self.config.EventCd_LastStage = 0
else:
last = str(self.config.EventCd_LastStage).lower()
last = self.convert_stages(last)
if last in stages:
stages = stages[stages.index(last) + 1:]
logger.attr('Filter sort', ' > '.join(stages))