diff --git a/module/campaign/run.py b/module/campaign/run.py index 2c00f3969..24d265df0 100644 --- a/module/campaign/run.py +++ b/module/campaign/run.py @@ -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 diff --git a/module/event/base.py b/module/event/base.py index 7e25de751..a7f999e2a 100644 --- a/module/event/base.py +++ b/module/event/base.py @@ -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 diff --git a/module/event/campaign_ab.py b/module/event/campaign_ab.py index 26459c970..6cd640cca 100644 --- a/module/event/campaign_ab.py +++ b/module/event/campaign_ab.py @@ -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)) diff --git a/module/event/campaign_cd.py b/module/event/campaign_cd.py index c71c2035a..f838fb5f8 100644 --- a/module/event/campaign_cd.py +++ b/module/event/campaign_cd.py @@ -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))