Fix: Disable MAP_IS_ONE_TIME_STAGE in event dailies, last fix not working

This commit is contained in:
LmeSzinc 2022-01-10 00:13:00 +08:00
parent 9a8f219dd0
commit 0765be5366
4 changed files with 37 additions and 46 deletions

28
module/event/base.py Normal file
View File

@ -0,0 +1,28 @@
import re
from module.base.filter import Filter
from module.campaign.run import CampaignRun
STAGE_FILTER = Filter(regex=re.compile('^(.*?)$'), attr=('stage',))
class EventStage:
def __init__(self, filename):
self.filename = filename
self.stage = 'unknown'
if filename[-3:] == '.py':
self.stage = filename[:-3]
def __str__(self):
return self.stage
def __eq__(self, other):
return str(self) == str(other)
class EventBase(CampaignRun):
def load_campaign(self, *args, **kwargs):
super().load_campaign(*args, **kwargs)
self.campaign.config.temporary(
MAP_IS_ONE_TIME_STAGE=False
)

View File

@ -1,31 +1,13 @@
import os
import re
from module.base.filter import Filter
from module.campaign.run import CampaignRun
from module.config.config import TaskEnd
from module.config.utils import get_server_last_update
from module.event.base import EventBase, EventStage, STAGE_FILTER
from module.logger import logger
STAGE_FILTER = Filter(regex=re.compile('^(.*?)$'), attr=('stage',))
class EventStage:
def __init__(self, filename):
self.filename = filename
self.stage = 'unknown'
if filename[-3:] == '.py':
self.stage = filename[:-3]
def __str__(self):
return self.stage
def __eq__(self, other):
return str(self) == str(other)
class CampaignAB(CampaignRun):
def run(self):
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}')]
logger.attr('Stage', [str(stage) for stage in stages])

View File

@ -1,31 +1,13 @@
import os
import re
from module.base.filter import Filter
from module.campaign.run import CampaignRun
from module.config.config import TaskEnd
from module.config.utils import get_server_last_update
from module.event.base import EventBase, EventStage, STAGE_FILTER
from module.logger import logger
STAGE_FILTER = Filter(regex=re.compile('^(.*?)$'), attr=('stage',))
class EventStage:
def __init__(self, filename):
self.filename = filename
self.stage = 'unknown'
if filename[-3:] == '.py':
self.stage = filename[:-3]
def __str__(self):
return self.stage
def __eq__(self, other):
return str(self) == str(other)
class CampaignCD(CampaignRun):
def run(self):
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}')]
logger.attr('Stage', [str(stage) for stage in stages])

View File

@ -1,19 +1,18 @@
import os
from module.campaign.run import CampaignRun
from module.config.config import TaskEnd
from module.event.base import EventBase
from module.logger import logger
class CampaignSP(CampaignRun):
def run(self):
class CampaignSP(EventBase):
def run(self, *args, **kwargs):
if not os.path.exists(f'./campaign/{self.config.Campaign_Event}/sp.py'):
logger.info(f'./campaign/{self.config.Campaign_Event}/sp.py not exists')
logger.info(f'This event do not have SP, skip')
self.config.Scheduler_Enable = False
self.config.task_stop()
self.config.temporary(MAP_IS_ONE_TIME_STAGE=False)
try:
super().run(name=self.config.Campaign_Name, folder=self.config.Campaign_Event, total=1)
except TaskEnd: