Add: Run daily as a part of reward, disabled by default

This commit is contained in:
LmeSzinc 2020-06-29 00:07:06 +08:00
parent faab67a3e4
commit 22203ccb7b
8 changed files with 63 additions and 33 deletions

35
alas.py
View File

@ -96,38 +96,9 @@ class AzurLaneAutoScript:
"""
Method to run daily missions.
"""
if self.config.ENABLE_DAILY_MISSION:
from module.daily.daily import Daily
az = Daily(self.config, device=self.device)
if not az.record_executed_since():
az.run()
az.record_save()
if self.config.ENABLE_HARD_CAMPAIGN:
from module.hard.hard import CampaignHard
az = CampaignHard(self.config, device=self.device)
if not az.record_executed_since():
az.run()
az.record_save()
if self.config.ENABLE_EXERCISE:
from module.exercise.exercise import Exercise
az = Exercise(self.config, device=self.device)
if not az.record_executed_since():
az.run()
az.record_save()
if self.config.ENABLE_EVENT_NAME_AB:
from module.event.campaign_ab import CampaignAB
az = CampaignAB(self.config, device=self.device)
az.run_event_daily()
if self.config.ENABLE_RAID_DAILY:
from module.raid.daily import RaidDaily
az = RaidDaily(self.config, device=self.device)
if not az.record_executed_since():
az.run()
az.record_save()
from module.reward.reward import Reward
az = Reward(self.config, device=self.device)
az.daily_wrapper_run()
self.reward_when_finished()

View File

@ -61,6 +61,7 @@ command = setting
command = reward
enable_reward = yes
reward_interval = 20
enable_daily_reward = no
enable_oil_reward = yes
enable_coin_reward = yes
enable_mission_reward = yes

View File

@ -185,6 +185,7 @@ def main(ini_name=''):
reward_condition = reward_parser.add_argument_group('触发条件', '需要运行一次来保存选项, 运行后会进入挂机收菜模式')
reward_condition.add_argument('--启用收获', default=default('--启用收获'), choices=['', ''])
reward_condition.add_argument('--收菜间隔', default=default('--收菜间隔'), choices=['20', '30', '60'], help='每隔多少分钟触发收菜')
reward_condition.add_argument('--启用每日收获', default=default('--启用每日收获'), choices=['', ''], help='将每日任务困难演习作为收获的一部分来运行')
reward_oil = reward_parser.add_argument_group('石油物资', '')
reward_oil.add_argument('--启用石油收获', default=default('--启用石油收获'), choices=['', ''])

View File

@ -186,6 +186,7 @@ def main(ini_name=''):
reward_condition = reward_parser.add_argument_group('Triggering conditions', 'Need to Press start to save your settings, after running it will enter the on-hook vegetable collection mode')
reward_condition.add_argument('--enable_reward', default=default('--enable_reward'), choices=['yes', 'no'])
reward_condition.add_argument('--reward_interval', default=default('--reward_interval'), choices=['20', '30', '60'], help='How many minutes to trigger collection')
reward_condition.add_argument('--enable_daily_reward', default=default('--enable_daily_reward'), choices=['yes', 'no'], help='Run daily as a part of reward')
reward_oil = reward_parser.add_argument_group('Oil supplies', '')
reward_oil.add_argument('--enable_oil_reward', default=default('--enable_oil_reward'), choices=['yes', 'no'])

View File

@ -185,6 +185,7 @@ def main(ini_name=''):
reward_condition = reward_parser.add_argument_group('Triggering conditions', 'Need to Press start to save your settings, after running it will enter the on-hook vegetable collection mode')
reward_condition.add_argument('--enable_reward', default=default('--enable_reward'), choices=['yes', 'no'])
reward_condition.add_argument('--reward_interval', default=default('--reward_interval'), choices=['20', '30', '60'], help='How many minutes to trigger collection')
reward_condition.add_argument('--enable_daily_reward', default=default('--enable_daily_reward'), choices=['yes', 'no'], help='Run daily as a part of reward')
reward_oil = reward_parser.add_argument_group('Oil supplies', '')
reward_oil.add_argument('--enable_oil_reward', default=default('--enable_oil_reward'), choices=['yes', 'no'])

View File

@ -316,6 +316,7 @@ class AzurLaneConfig:
ENABLE_REWARD = True
REWARD_INTERVAL = 20
REWARD_LAST_TIME = datetime.now()
ENABLE_DAILY_REWARD = False
ENABLE_OIL_REWARD = True
ENABLE_COIN_REWARD = True
ENABLE_MISSION_REWARD = True
@ -496,7 +497,8 @@ class AzurLaneConfig:
# Reward
option = config['Reward']
self.REWARD_INTERVAL = int(option['reward_interval'])
for attr in ['enable_reward', 'enable_oil_reward', 'enable_coin_reward', 'enable_mission_reward', 'enable_commission_reward', 'enable_tactical_reward']:
for attr in ['enable_reward', 'enable_oil_reward', 'enable_coin_reward', 'enable_mission_reward',
'enable_commission_reward', 'enable_tactical_reward', 'enable_daily_reward']:
self.__setattr__(attr.upper(), to_bool(option[attr]))
if not option['commission_time_limit'].isdigit():
self.COMMISSION_TIME_LIMIT = future_time(option['commission_time_limit'])

View File

@ -93,6 +93,7 @@ dic_true_eng_to_eng = {
'map_star_clear_all': 'map_star_clear_all',
'enable_reward': 'enable_reward',
'reward_interval': 'reward_interval',
'enable_daily_reward': 'enable_daily_reward',
'enable_oil_reward': 'enable_oil_reward',
'enable_coin_reward': 'enable_coin_reward',
'enable_mission_reward': 'enable_mission_reward',
@ -300,6 +301,7 @@ dic_chi_to_eng = {
'地图全清星星': 'map_star_clear_all',
'启用收获': 'enable_reward',
'收菜间隔': 'reward_interval',
'启用每日收获': 'enable_daily_reward',
'启用石油收获': 'enable_oil_reward',
'启用物资收获': 'enable_coin_reward',
'启用任务收获': 'enable_mission_reward',

View File

@ -36,6 +36,13 @@ class Reward(RewardCommission, RewardTacticalClass, LoginHandler, Update):
self.config.REWARD_LAST_TIME = datetime.now()
logger.hr('Reward end')
if self.config.ENABLE_DAILY_REWARD:
logger.hr('Daily reward')
count = self.daily_wrapper_run()
if count > 0:
return self.reward()
return True
def handle_reward(self):
@ -164,3 +171,47 @@ class Reward(RewardCommission, RewardTacticalClass, LoginHandler, Update):
logger.info('Reward loop wait')
logger.attr('Reward_loop_wait', f'{self.config.REWARD_INTERVAL} min')
self.device.sleep(self.config.REWARD_INTERVAL * 60)
def daily_wrapper_run(self):
count = 0
total = 5
if self.config.ENABLE_DAILY_MISSION:
from module.daily.daily import Daily
az = Daily(self.config, device=self.device)
if not az.record_executed_since():
az.run()
az.record_save()
count += 1
if self.config.ENABLE_HARD_CAMPAIGN:
from module.hard.hard import CampaignHard
az = CampaignHard(self.config, device=self.device)
if not az.record_executed_since():
az.run()
az.record_save()
count += 1
if self.config.ENABLE_EXERCISE:
from module.exercise.exercise import Exercise
az = Exercise(self.config, device=self.device)
if not az.record_executed_since():
az.run()
az.record_save()
count += 1
if self.config.ENABLE_EVENT_NAME_AB:
from module.event.campaign_ab import CampaignAB
az = CampaignAB(self.config, device=self.device)
az.run_event_daily()
count += 1
if self.config.ENABLE_RAID_DAILY:
from module.raid.daily import RaidDaily
az = RaidDaily(self.config, device=self.device)
if not az.record_executed_since():
az.run()
az.record_save()
count += 1
logger.attr('Daily_executed', f'{count}/{total}')
return count