Add: 增加挂机收菜模式

This commit is contained in:
LmeSzinc 2020-05-06 23:53:25 +08:00
parent f9f0b59657
commit 65de042dd3
5 changed files with 22 additions and 5 deletions

View File

@ -50,7 +50,7 @@ class AzurLaneAutoScript:
logger.hr('Reward Settings saved') logger.hr('Reward Settings saved')
from module.reward.reward import Reward from module.reward.reward import Reward
az = Reward(self.config) az = Reward(self.config)
az.reward() az.reward_loop()
def emulator(self): def emulator(self):
for key, value in self.config.config['Emulator'].items(): for key, value in self.config.config['Emulator'].items():
@ -59,7 +59,10 @@ class AzurLaneAutoScript:
logger.hr('Emulator saved') logger.hr('Emulator saved')
from module.handler.login import LoginHandler from module.handler.login import LoginHandler
az = LoginHandler(self.config) az = LoginHandler(self.config)
az.app_ensure_start() if az.app_ensure_start():
from module.reward.reward import Reward
az = Reward(self.config)
az.reward()
def main(self): def main(self):
""" """

View File

@ -209,7 +209,7 @@ def main(ini_name=''):
# ==========收菜设置========== # ==========收菜设置==========
reward_parser = subs.add_parser('收菜设置') reward_parser = subs.add_parser('收菜设置')
reward_condition = reward_parser.add_argument_group('触发条件', '需要运行一次来保存选项, 运行时会执行一次收菜') reward_condition = reward_parser.add_argument_group('触发条件', '需要运行一次来保存选项, 运行后会进入挂机收菜模式')
reward_condition.add_argument('--启用收获', default=default('--启用收获'), choices=['', '']) 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=['20', '30', '60'], help='每隔多少分钟触发收菜')
@ -260,9 +260,9 @@ def main(ini_name=''):
# ==========设备设置========== # ==========设备设置==========
emulator_parser = subs.add_parser('设备设置') emulator_parser = subs.add_parser('设备设置')
emulator = emulator_parser.add_argument_group('模拟器', '需要运行一次来保存选项, 会检查游戏是否启动') emulator = emulator_parser.add_argument_group('模拟器', '需要运行一次来保存选项, 会检查游戏是否启动\n若启动了游戏, 触发一次收菜')
emulator.add_argument('--设备', default=default('--设备'), help='例如 127.0.0.1:62001') emulator.add_argument('--设备', default=default('--设备'), help='例如 127.0.0.1:62001')
emulator.add_argument('--包名', default=default('--包名'), help='如果不是Biliibli国服, 或者使用了非官方客户端, 需修改') emulator.add_argument('--包名', default=default('--包名'), help='')
debug = emulator_parser.add_argument_group('调试设置', '') debug = emulator_parser.add_argument_group('调试设置', '')
debug.add_argument('--出错时保存log和截图', default=default('--出错时保存log和截图'), choices=['', '']) debug.add_argument('--出错时保存log和截图', default=default('--出错时保存log和截图'), choices=['', ''])

View File

@ -48,3 +48,6 @@ class LoginHandler(Combat):
if not self.device.app_is_running(): if not self.device.app_is_running():
self.device.app_start() self.device.app_start()
self.handle_app_login() self.handle_app_login()
return True
return False

View File

@ -21,4 +21,5 @@ REWARD_1 = Button(area=(383, 285, 503, 297), color=(238, 168, 81), button=(383,
REWARD_2 = Button(area=(383, 404, 503, 444), color=(233, 165, 67), button=(383, 404, 503, 444), file='./assets/reward/REWARD_2.png') REWARD_2 = Button(area=(383, 404, 503, 444), color=(233, 165, 67), button=(383, 404, 503, 444), file='./assets/reward/REWARD_2.png')
REWARD_3 = Button(area=(383, 546, 503, 586), color=(234, 163, 69), button=(383, 546, 503, 586), file='./assets/reward/REWARD_3.png') REWARD_3 = Button(area=(383, 546, 503, 586), color=(234, 163, 69), button=(383, 546, 503, 586), file='./assets/reward/REWARD_3.png')
REWARD_SAVE_CLICK = Button(area=(415, 184, 496, 214), color=(152, 150, 168), button=(415, 184, 496, 214), file='./assets/reward/REWARD_SAVE_CLICK.png') REWARD_SAVE_CLICK = Button(area=(415, 184, 496, 214), color=(152, 150, 168), button=(415, 184, 496, 214), file='./assets/reward/REWARD_SAVE_CLICK.png')
TACTICAL_CLASS_CANCEL = Button(area=(818, 590, 990, 648), color=(153, 153, 154), button=(818, 590, 990, 648), file='./assets/reward/TACTICAL_CLASS_CANCEL.png')
TACTICAL_CLASS_START = Button(area=(1024, 590, 1197, 648), color=(96, 139, 194), button=(1024, 590, 1197, 648), file='./assets/reward/TACTICAL_CLASS_START.png') TACTICAL_CLASS_START = Button(area=(1024, 590, 1197, 648), color=(96, 139, 194), button=(1024, 590, 1197, 648), file='./assets/reward/TACTICAL_CLASS_START.png')

View File

@ -151,3 +151,13 @@ class Reward(RewardCommission, RewardTacticalClass):
self.ui_goto(page_main, skip_first_screenshot=True) self.ui_goto(page_main, skip_first_screenshot=True)
return reward return reward
def reward_loop(self):
logger.hr('Reward loop')
while 1:
if not self.reward():
break
logger.info('Reward loop wait')
logger.attr('Reward_loop_wait', f'{self.config.REWARD_INTERVAL} min')
self.device.sleep(self.config.REWARD_INTERVAL * 60)