Refactor: Event daily SP and AB

- Add Raid and WarArchives configs
This commit is contained in:
LmeSzinc 2021-10-03 22:14:30 +08:00
parent abbf735fa3
commit 4046dd25f5
15 changed files with 1924 additions and 120 deletions

View File

@ -153,6 +153,14 @@ class AzurLaneAutoScript:
from module.sos.sos import CampaignSos
CampaignSos(config=self.config, device=self.device).run()
def event_ab(self):
from module.event.campaign_ab import CampaignAB
CampaignAB(config=self.config, device=self.device).run()
def event_sp(self):
from module.event.campaign_sp import CampaignSP
CampaignSP(config=self.config, device=self.device).run()
def opsi_ash_assist(self):
from module.os_ash.ash import AshBeaconAssist
AshBeaconAssist(config=self.config, device=self.device).run()

View File

@ -193,10 +193,19 @@
"ServerUpdate": "00:00"
},
"Raid": {
"Event": "raid_20200624",
"Mode": "hard",
"UseTicket": false
},
"Campaign": {
"Name": "dynamic",
"Event": "campaign_main",
"Mode": "normal",
"UseClearMode": true,
"UseFleetLock": true,
"UseAutoSearch": false,
"Use2xBook": false,
"AmbushEvade": true
},
"StopCondition": {
"RunCount": 0,
"OilLimit": 1000,
@ -879,6 +888,255 @@
"LowHpRetreatThreshold": 0.3
}
},
"EventAb": {
"Scheduler": {
"Enable": false,
"NextRun": "2020-01-01 00:00:00",
"Command": "EventAb",
"SuccessInterval": 30,
"FailureInterval": 30,
"ServerUpdate": "00:00"
},
"EventAb": {
"StageFilter": "A1 > A2 > A3 > B1 > B2 > B3",
"LastStage": 0
},
"Campaign": {
"Name": "dynamic",
"Event": "campaign_main",
"Mode": "normal",
"UseClearMode": true,
"UseFleetLock": true,
"UseAutoSearch": false,
"Use2xBook": false,
"AmbushEvade": true
},
"StopCondition": {
"RunCount": 0,
"OilLimit": 1000,
"MapAchievement": "non_stop",
"GetNewShip": false,
"ReachLevel120": false
},
"Fleet": {
"Fleet1": 1,
"Fleet1Formation": "double_line",
"Fleet1Mode": "combat_auto",
"Fleet1Step": 3,
"Fleet2": 2,
"Fleet2Formation": "double_line",
"Fleet2Mode": "combat_auto",
"Fleet2Step": 2,
"FleetOrder": "fleet1_mob_fleet2_boss",
"AutoSearchFleetOrder": "fleet1_mob_fleet2_boss"
},
"Submarine": {
"Fleet": 0,
"Mode": "do_not_use"
},
"Emotion": {
"CalculateEmotion": true,
"IgnoreLowEmotionWarn": false,
"Fleet1Value": 119,
"Fleet1Record": "2020-01-01 00:00:00",
"Fleet1Control": "prevent_yellow_face",
"Fleet1Recover": "not_in_dormitory",
"Fleet1Oath": false,
"Fleet2Value": 119,
"Fleet2Record": "2020-01-01 00:00:00",
"Fleet2Control": "prevent_yellow_face",
"Fleet2Recover": "not_in_dormitory",
"Fleet2Oath": false
},
"HpControl": {
"UseHpBalance": false,
"UseEmergencyRepair": false,
"UseLowHpRetreat": false,
"HpBalanceThreshold": 0.2,
"HpBalanceWeight": "1000, 1000, 1000",
"RepairUseSingleThreshold": 0.3,
"RepairUseMultiThreshold": 0.6,
"LowHpRetreatThreshold": 0.3
}
},
"EventSp": {
"Scheduler": {
"Enable": false,
"NextRun": "2020-01-01 00:00:00",
"Command": "EventSp",
"SuccessInterval": 30,
"FailureInterval": 30,
"ServerUpdate": "00:00"
},
"Campaign": {
"Name": "sp",
"Event": "campaign_main",
"Mode": "normal",
"UseClearMode": true,
"UseFleetLock": true,
"UseAutoSearch": false,
"Use2xBook": false,
"AmbushEvade": true
},
"StopCondition": {
"RunCount": 0,
"OilLimit": 1000,
"MapAchievement": "non_stop",
"GetNewShip": false,
"ReachLevel120": false
},
"Fleet": {
"Fleet1": 1,
"Fleet1Formation": "double_line",
"Fleet1Mode": "combat_auto",
"Fleet1Step": 3,
"Fleet2": 2,
"Fleet2Formation": "double_line",
"Fleet2Mode": "combat_auto",
"Fleet2Step": 2,
"FleetOrder": "fleet1_mob_fleet2_boss",
"AutoSearchFleetOrder": "fleet1_mob_fleet2_boss"
},
"Submarine": {
"Fleet": 0,
"Mode": "do_not_use"
},
"Emotion": {
"CalculateEmotion": true,
"IgnoreLowEmotionWarn": false,
"Fleet1Value": 119,
"Fleet1Record": "2020-01-01 00:00:00",
"Fleet1Control": "prevent_yellow_face",
"Fleet1Recover": "not_in_dormitory",
"Fleet1Oath": false,
"Fleet2Value": 119,
"Fleet2Record": "2020-01-01 00:00:00",
"Fleet2Control": "prevent_yellow_face",
"Fleet2Recover": "not_in_dormitory",
"Fleet2Oath": false
},
"HpControl": {
"UseHpBalance": false,
"UseEmergencyRepair": false,
"UseLowHpRetreat": false,
"HpBalanceThreshold": 0.2,
"HpBalanceWeight": "1000, 1000, 1000",
"RepairUseSingleThreshold": 0.3,
"RepairUseMultiThreshold": 0.6,
"LowHpRetreatThreshold": 0.3
}
},
"RaidDaily": {
"Scheduler": {
"Enable": false,
"NextRun": "2020-01-01 00:00:00",
"Command": "RaidDaily",
"SuccessInterval": 30,
"FailureInterval": 30,
"ServerUpdate": "00:00"
},
"RaidDaily": {
"StageFilter": "hard > normal > easy"
},
"Campaign": {
"Name": "dynamic",
"Event": "campaign_main",
"Mode": "normal",
"UseClearMode": true,
"UseFleetLock": true,
"UseAutoSearch": false,
"Use2xBook": false,
"AmbushEvade": true
},
"StopCondition": {
"RunCount": 0,
"OilLimit": 1000,
"MapAchievement": "non_stop",
"GetNewShip": false,
"ReachLevel120": false
},
"Emotion": {
"CalculateEmotion": true,
"IgnoreLowEmotionWarn": false,
"Fleet1Value": 119,
"Fleet1Record": "2020-01-01 00:00:00",
"Fleet1Control": "prevent_yellow_face",
"Fleet1Recover": "not_in_dormitory",
"Fleet1Oath": false,
"Fleet2Value": 119,
"Fleet2Record": "2020-01-01 00:00:00",
"Fleet2Control": "prevent_yellow_face",
"Fleet2Recover": "not_in_dormitory",
"Fleet2Oath": false
}
},
"WarArchives": {
"Scheduler": {
"Enable": false,
"NextRun": "2020-01-01 00:00:00",
"Command": "WarArchives",
"SuccessInterval": 30,
"FailureInterval": 30,
"ServerUpdate": "00:00"
},
"Campaign": {
"Name": "7-2",
"Event": "campaign_main",
"Mode": "normal",
"UseClearMode": true,
"UseFleetLock": true,
"UseAutoSearch": false,
"Use2xBook": false,
"AmbushEvade": true
},
"StopCondition": {
"RunCount": 0,
"OilLimit": 1000,
"MapAchievement": "non_stop",
"GetNewShip": false,
"ReachLevel120": false
},
"Fleet": {
"Fleet1": 1,
"Fleet1Formation": "double_line",
"Fleet1Mode": "combat_auto",
"Fleet1Step": 3,
"Fleet2": 2,
"Fleet2Formation": "double_line",
"Fleet2Mode": "combat_auto",
"Fleet2Step": 2,
"FleetOrder": "fleet1_mob_fleet2_boss",
"AutoSearchFleetOrder": "fleet1_mob_fleet2_boss"
},
"Submarine": {
"Fleet": 0,
"Mode": "do_not_use"
},
"Emotion": {
"CalculateEmotion": true,
"IgnoreLowEmotionWarn": false,
"Fleet1Value": 119,
"Fleet1Record": "2020-01-01 00:00:00",
"Fleet1Control": "prevent_yellow_face",
"Fleet1Recover": "not_in_dormitory",
"Fleet1Oath": false,
"Fleet2Value": 119,
"Fleet2Record": "2020-01-01 00:00:00",
"Fleet2Control": "prevent_yellow_face",
"Fleet2Recover": "not_in_dormitory",
"Fleet2Oath": false
},
"HpControl": {
"UseHpBalance": false,
"UseEmergencyRepair": false,
"UseLowHpRetreat": false,
"HpBalanceThreshold": 0.2,
"HpBalanceWeight": "1000, 1000, 1000",
"RepairUseSingleThreshold": 0.3,
"RepairUseMultiThreshold": 0.6,
"LowHpRetreatThreshold": 0.3
}
},
"OpsiGeneral": {
"OpsiGeneral": {
"AshAttack": true,

File diff suppressed because it is too large Load Diff

View File

@ -113,7 +113,7 @@ Submarine:
option: [0, 1, 2]
Mode:
value: do_not_use
option: [do_not_use,hunt_only, every_combat]
option: [do_not_use, hunt_only, every_combat]
Emotion:
CalculateEmotion: true
IgnoreLowEmotionWarn: false
@ -145,7 +145,6 @@ HpControl:
RepairUseMultiThreshold: 0.6
LowHpRetreatThreshold: 0.3
Raid:
Event: raid_20200624
Mode:
value: hard
option: [easy, normal, hard]
@ -359,6 +358,13 @@ Sos:
Chapter:
value: 3
option: [3, 4, 5, 6, 7, 8, 9, 10]
EventAb:
StageFilter: |-
A1 > A2 > A3 > B1 > B2 > B3
LastStage: 0
RaidDaily:
StageFilter: |-
hard > normal > easy
# ==================== Opsi ====================

View File

@ -31,7 +31,11 @@
"Daily",
"Hard",
"Exercise",
"Sos"
"Sos",
"EventAb",
"EventSp",
"RaidDaily",
"WarArchives"
],
"Opsi": [
"OpsiGeneral",

View File

@ -19,6 +19,20 @@ Event:
Campaign:
Mode: normal
AmbushEvade: true
Raid:
Campaign:
Name: dynamic
Mode: normal
UseClearMode: true
UseFleetLock: true
UseAutoSearch: false
Use2xBook: false
AmbushEvade: true
StopCondition:
RunCount: 0
MapAchievement: non_stop
GetNewShip: false
ReachLevel120: false
C11AffinityFarming:
Campaign:
Name: campaign_1_1_affinity_farming
@ -185,6 +199,57 @@ Sos:
GetNewShip: false
Fleet:
AutoSearchFleetOrder: fleet1_all_fleet2_standby
EventAb:
Scheduler:
SuccessInterval: 30
FailureInterval: 30
ServerUpdate: 00:00
Campaign:
Name: dynamic
Mode: normal
AmbushEvade: true
StopCondition:
RunCount: 0
MapAchievement: non_stop
GetNewShip: false
ReachLevel120: false
EventSp:
Scheduler:
SuccessInterval: 30
FailureInterval: 30
ServerUpdate: 00:00
Campaign:
Name: sp
Mode: normal
AmbushEvade: true
StopCondition:
RunCount: 0
MapAchievement: non_stop
GetNewShip: false
ReachLevel120: false
RaidDaily:
Scheduler:
SuccessInterval: 30
FailureInterval: 30
ServerUpdate: 00:00
Campaign:
Name: dynamic
Mode: normal
UseClearMode: true
UseFleetLock: true
UseAutoSearch: false
Use2xBook: false
AmbushEvade: true
StopCondition:
RunCount: 0
MapAchievement: non_stop
GetNewShip: false
ReachLevel120: false
WarArchives:
Scheduler:
SuccessInterval: 30
FailureInterval: 30
ServerUpdate: 00:00
# ==================== Opsi ====================

View File

@ -35,6 +35,7 @@ Event:
Raid:
- Scheduler
- Raid
- Campaign
- StopCondition
- Emotion
C11AffinityFarming:
@ -140,6 +141,37 @@ Sos:
- Submarine
- Emotion
- HpControl
EventAb:
- Scheduler
- EventAb
- Campaign
- StopCondition
- Fleet
- Submarine
- Emotion
- HpControl
EventSp:
- Scheduler
- Campaign
- StopCondition
- Fleet
- Submarine
- Emotion
- HpControl
RaidDaily:
- Scheduler
- RaidDaily
- Campaign
- StopCondition
- Emotion
WarArchives:
- Scheduler
- Campaign
- StopCondition
- Fleet
- Submarine
- Emotion
- HpControl
# ==================== Opsi ====================

View File

@ -111,7 +111,6 @@ class GeneratedConfig:
HpControl_LowHpRetreatThreshold = 0.3
# Group `Raid`
Raid_Event = 'raid_20200624'
Raid_Mode = 'hard' # easy, normal, hard
Raid_UseTicket = False
@ -243,6 +242,13 @@ class GeneratedConfig:
# Group `Sos`
Sos_Chapter = 3 # 3, 4, 5, 6, 7, 8, 9, 10
# Group `EventAb`
EventAb_StageFilter = 'A1 > A2 > A3 > B1 > B2 > B3'
EventAb_LastStage = 0
# Group `RaidDaily`
RaidDaily_StageFilter = 'hard > normal > easy'
# Group `OpsiAshAssist`
OpsiAshAssist_Tier = 15

View File

@ -297,13 +297,14 @@ class ConfigGenerator:
if name:
if event.is_raid:
# insert('Raid')
pass
insert('Raid')
insert('RaidDaily')
elif event.is_war_archives:
# insert('WarArchives')
pass
insert('WarArchives')
else:
insert('Event')
insert('EventAb')
insert('EventSp')
@timer
def generate(self):
@ -356,7 +357,10 @@ class ConfigUpdater:
# Update to latest event
if not is_template:
server_ = deep_get(new, 'Alas.Emulator.Server', 'cn')
deep_set(new, keys='Event.Campaign.Event', value=deep_get(self.args, f'Event.Campaign.Event.{server_}'))
for task in ['Event', 'EventAb', 'EventSp', 'Raid', 'RaidDaily', 'WarArchives']:
deep_set(new,
keys=f'{task}.Campaign.Event',
value=deep_get(self.args, f'{task}.Campaign.Event.{server_}'))
return new

View File

@ -126,6 +126,22 @@
"name": "Sos",
"help": ""
},
"EventAb": {
"name": "Task.EventAb.name",
"help": "Task.EventAb.help"
},
"EventSp": {
"name": "Task.EventSp.name",
"help": "Task.EventSp.help"
},
"RaidDaily": {
"name": "Task.RaidDaily.name",
"help": "Task.RaidDaily.help"
},
"WarArchives": {
"name": "Task.WarArchives.name",
"help": "Task.WarArchives.help"
},
"OpsiGeneral": {
"name": "Opsi General",
"help": ""
@ -667,10 +683,6 @@
"name": "Raid._info.name",
"help": "Raid._info.help"
},
"Event": {
"name": "Raid.Event.name",
"help": "Raid.Event.help"
},
"Mode": {
"name": "Raid.Mode.name",
"help": "Raid.Mode.help",
@ -1296,6 +1308,30 @@
"10": "10"
}
},
"EventAb": {
"_info": {
"name": "EventAb._info.name",
"help": "EventAb._info.help"
},
"StageFilter": {
"name": "EventAb.StageFilter.name",
"help": "EventAb.StageFilter.help"
},
"LastStage": {
"name": "EventAb.LastStage.name",
"help": "EventAb.LastStage.help"
}
},
"RaidDaily": {
"_info": {
"name": "RaidDaily._info.name",
"help": "RaidDaily._info.help"
},
"StageFilter": {
"name": "RaidDaily.StageFilter.name",
"help": "RaidDaily.StageFilter.help"
}
},
"OpsiAshAssist": {
"_info": {
"name": "OpsiAshAssist._info.name",

View File

@ -126,6 +126,22 @@
"name": "Task.Sos.name",
"help": "Task.Sos.help"
},
"EventAb": {
"name": "Task.EventAb.name",
"help": "Task.EventAb.help"
},
"EventSp": {
"name": "Task.EventSp.name",
"help": "Task.EventSp.help"
},
"RaidDaily": {
"name": "Task.RaidDaily.name",
"help": "Task.RaidDaily.help"
},
"WarArchives": {
"name": "Task.WarArchives.name",
"help": "Task.WarArchives.help"
},
"OpsiGeneral": {
"name": "Task.OpsiGeneral.name",
"help": "Task.OpsiGeneral.help"
@ -667,10 +683,6 @@
"name": "Raid._info.name",
"help": "Raid._info.help"
},
"Event": {
"name": "Raid.Event.name",
"help": "Raid.Event.help"
},
"Mode": {
"name": "Raid.Mode.name",
"help": "Raid.Mode.help",
@ -1296,6 +1308,30 @@
"10": "10"
}
},
"EventAb": {
"_info": {
"name": "EventAb._info.name",
"help": "EventAb._info.help"
},
"StageFilter": {
"name": "EventAb.StageFilter.name",
"help": "EventAb.StageFilter.help"
},
"LastStage": {
"name": "EventAb.LastStage.name",
"help": "EventAb.LastStage.help"
}
},
"RaidDaily": {
"_info": {
"name": "RaidDaily._info.name",
"help": "RaidDaily._info.help"
},
"StageFilter": {
"name": "RaidDaily.StageFilter.name",
"help": "RaidDaily.StageFilter.help"
}
},
"OpsiAshAssist": {
"_info": {
"name": "OpsiAshAssist._info.name",

View File

@ -126,6 +126,22 @@
"name": "潜艇图",
"help": ""
},
"EventAb": {
"name": "Task.EventAb.name",
"help": "Task.EventAb.help"
},
"EventSp": {
"name": "Task.EventSp.name",
"help": "Task.EventSp.help"
},
"RaidDaily": {
"name": "Task.RaidDaily.name",
"help": "Task.RaidDaily.help"
},
"WarArchives": {
"name": "Task.WarArchives.name",
"help": "Task.WarArchives.help"
},
"OpsiGeneral": {
"name": "大世界",
"help": ""
@ -667,10 +683,6 @@
"name": "共斗",
"help": ""
},
"Event": {
"name": "共斗活动名",
"help": ""
},
"Mode": {
"name": "难度",
"help": "",
@ -1296,6 +1308,30 @@
"10": "10"
}
},
"EventAb": {
"_info": {
"name": "EventAb._info.name",
"help": "EventAb._info.help"
},
"StageFilter": {
"name": "EventAb.StageFilter.name",
"help": "EventAb.StageFilter.help"
},
"LastStage": {
"name": "EventAb.LastStage.name",
"help": "EventAb.LastStage.help"
}
},
"RaidDaily": {
"_info": {
"name": "RaidDaily._info.name",
"help": "RaidDaily._info.help"
},
"StageFilter": {
"name": "RaidDaily.StageFilter.name",
"help": "RaidDaily.StageFilter.help"
}
},
"OpsiAshAssist": {
"_info": {
"name": "OpsiAshAssist._info.name",

View File

@ -126,6 +126,22 @@
"name": "Task.Sos.name",
"help": "Task.Sos.help"
},
"EventAb": {
"name": "Task.EventAb.name",
"help": "Task.EventAb.help"
},
"EventSp": {
"name": "Task.EventSp.name",
"help": "Task.EventSp.help"
},
"RaidDaily": {
"name": "Task.RaidDaily.name",
"help": "Task.RaidDaily.help"
},
"WarArchives": {
"name": "Task.WarArchives.name",
"help": "Task.WarArchives.help"
},
"OpsiGeneral": {
"name": "Task.OpsiGeneral.name",
"help": "Task.OpsiGeneral.help"
@ -667,10 +683,6 @@
"name": "Raid._info.name",
"help": "Raid._info.help"
},
"Event": {
"name": "Raid.Event.name",
"help": "Raid.Event.help"
},
"Mode": {
"name": "Raid.Mode.name",
"help": "Raid.Mode.help",
@ -1296,6 +1308,30 @@
"10": "10"
}
},
"EventAb": {
"_info": {
"name": "EventAb._info.name",
"help": "EventAb._info.help"
},
"StageFilter": {
"name": "EventAb.StageFilter.name",
"help": "EventAb.StageFilter.help"
},
"LastStage": {
"name": "EventAb.LastStage.name",
"help": "EventAb.LastStage.help"
}
},
"RaidDaily": {
"_info": {
"name": "RaidDaily._info.name",
"help": "RaidDaily._info.help"
},
"StageFilter": {
"name": "RaidDaily.StageFilter.name",
"help": "RaidDaily.StageFilter.help"
}
},
"OpsiAshAssist": {
"_info": {
"name": "OpsiAshAssist._info.name",

View File

@ -3,71 +3,55 @@ import re
from module.campaign.run import CampaignRun
from module.logger import logger
from module.config.utils import get_server_last_update
from module.base.filter import Filter
RECORD_SINCE = (0,)
CAMPAIGN_NAME = [
'a1', 'a2', 'a3', 'a4',
'b1', 'b2', 'b3', 'b4',
'c1', 'c2', 'c3', 'c4',
'd1', 'd2', 'd3', 'd4',
't1', 't2', 't3', 't4', 't5', 't6',
'ht1', 'ht2', 'ht3', 'ht4', 'ht5', 'ht6',
]
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, name, folder='campaign_main', total=0):
"""
Args:
name:
folder:
total:
def run(self):
stages = [EventStage(file) for file in os.listdir(f'./campaign/{self.config.Campaign_Event}')]
logger.attr('Stage', stages)
logger.attr('StageFilter', self.config.EventAb_StageFilter)
STAGE_FILTER.load(self.config.EventAb_StageFilter)
stages = STAGE_FILTER.apply(stages)
logger.attr('Filter sort', ' > '.join([str(stage) for stage in stages]))
Returns:
bool: If executed.
"""
name = name.lower()
option = ('EventABRecord', name)
if not self.config.record_executed_since(option=option, since=RECORD_SINCE):
super().run(name=name, folder=folder, total=1)
self.config.record_save(option=option)
return True
else:
return False
if not stages:
logger.warning('No stage satisfy current filter')
self.config.Scheduler_Enable = False
self.config.task_stop()
def run_event_daily(self):
"""
Returns:
bool: If executed.
"""
count = 0
satisfied_count = 0
existing = [file[:-3] for file in os.listdir(f'./campaign/{self.config.EVENT_NAME_AB}') if file[-3:] == '.py']
chapter = self.config.EVENT_AB_CHAPTER.split('_')[1]
logger.attr('LastStage', self.config.Scheduler_ServerUpdate)
if get_server_last_update(self.config.Scheduler_ServerUpdate) >= self.config.Scheduler_NextRun:
logger.info('Reset LastStage')
self.config.EventAb_LastStage = 0
if self.config.EventAb_LastStage in stages:
stages = stages[stages.index(self.config.EventAb_LastStage) + 1:]
name = ''.join(existing).lower()
if 'sp1' in name or 'sp2' in name or 'sp3' in name:
logger.warning(f'{self.config.EVENT_NAME_AB} seems to be a SP event, skip daily_ab')
logger.warning(f'Existing map files: {existing}')
return False
# Run
for stage in stages:
stage = str(stage)
super().run(name=stage, folder=self.config.Campaign_Event, total=1)
if self.run_count > 0:
self.config.EventAb_LastStage = stage
else:
self.config.task_stop()
self.reward_backup_daily_reward_settings()
for name in CAMPAIGN_NAME:
if name not in existing:
continue
strip = re.sub(r'\d+', '', name)
if strip not in chapter:
continue
satisfied_count += 1
result = self.run(name=name, folder=self.config.EVENT_NAME_AB)
if result:
count += 1
self.reward_recover_daily_reward_settings()
logger.info(f'Event daily ab executed: {count}')
if satisfied_count == 0:
logger.warning(f'No map files satisfy current settings, EVENT_AB_CHAPTER={self.config.EVENT_AB_CHAPTER}')
logger.warning(f'Existing map files: {existing}')
return count > 0
# Scheduler
self.config.task_delay(server_update=True)

View File

@ -3,34 +3,18 @@ import os
from module.campaign.run import CampaignRun
from module.logger import logger
RECORD_SINCE = (0,)
RECORD_OPTION = ('EventABRecord', 'sp')
class CampaignSP(CampaignRun):
_fleet_backup: tuple
def run(self):
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()
def run_event_daily_sp(self):
"""
Returns:
bool: If executed.
"""
if not os.path.exists(f'./campaign/{self.config.EVENT_NAME_AB}/sp.py'):
logger.info('This event do not have SP, skip')
return False
super().run(name=self.config.Campaign_Name, folder=self.config.Campaign_Event, total=1)
self.reward_backup_daily_reward_settings()
fleet_1, fleet_2 = (2, 1) if self.config.EVENT_SP_MOB_FLEET == 2 else (1, 2)
backup = self.config.cover(FLEET_1=fleet_1, FLEET_2=fleet_2, ENABLE_FLEET_REVERSE_IN_HARD=False)
if not self.config.record_executed_since(option=RECORD_OPTION, since=RECORD_SINCE):
self.run(name='sp', folder=self.config.EVENT_NAME_AB, total=1)
self.config.record_save(option=RECORD_OPTION)
executed = True
if self.run_count > 0:
self.config.task_delay(server_update=True)
else:
executed = False
backup.recover()
self.reward_recover_daily_reward_settings()
return executed
self.config.task_stop()