2020-04-01 14:40:21 +00:00
|
|
|
from datetime import datetime, timedelta
|
2020-03-30 06:00:39 +00:00
|
|
|
|
2020-04-01 14:40:21 +00:00
|
|
|
from module.base.timer import Timer
|
|
|
|
from module.combat.assets import *
|
|
|
|
from module.logger import logger
|
|
|
|
from module.reward.assets import *
|
|
|
|
from module.ui.page import *
|
2020-04-06 11:01:22 +00:00
|
|
|
from module.reward.commission import RewardCommission
|
2020-05-05 09:27:19 +00:00
|
|
|
from module.reward.tactical_class import RewardTacticalClass
|
2020-03-30 06:00:39 +00:00
|
|
|
|
2020-04-01 14:40:21 +00:00
|
|
|
|
2020-05-05 09:27:19 +00:00
|
|
|
class Reward(RewardCommission, RewardTacticalClass):
|
2020-04-01 14:40:21 +00:00
|
|
|
def reward(self):
|
2020-04-10 07:19:02 +00:00
|
|
|
if not self.config.ENABLE_REWARD:
|
|
|
|
return False
|
|
|
|
|
2020-04-01 14:40:21 +00:00
|
|
|
logger.hr('Reward start')
|
|
|
|
self.ui_goto_main()
|
|
|
|
|
|
|
|
self.ui_goto(page_reward, skip_first_screenshot=True)
|
|
|
|
|
|
|
|
self._reward_receive()
|
2020-04-06 11:01:22 +00:00
|
|
|
self.handle_info_bar()
|
|
|
|
self.handle_commission_start()
|
2020-05-05 09:27:19 +00:00
|
|
|
self.handle_tactical_class()
|
2020-04-01 14:40:21 +00:00
|
|
|
|
|
|
|
self.ui_click(
|
|
|
|
click_button=page_reward.links[page_main],
|
|
|
|
check_button=page_main.check_button,
|
|
|
|
appear_button=page_reward.check_button,
|
|
|
|
skip_first_screenshot=True)
|
2020-04-10 07:19:02 +00:00
|
|
|
|
|
|
|
self._reward_mission()
|
|
|
|
|
|
|
|
self.config.REWARD_LAST_TIME = datetime.now()
|
2020-04-01 14:40:21 +00:00
|
|
|
logger.hr('Reward end')
|
2020-04-10 07:19:02 +00:00
|
|
|
return True
|
2020-04-01 14:40:21 +00:00
|
|
|
|
|
|
|
def handle_reward(self):
|
|
|
|
if datetime.now() - self.config.REWARD_LAST_TIME < timedelta(minutes=self.config.REWARD_INTERVAL):
|
|
|
|
return False
|
|
|
|
|
2020-04-10 07:19:02 +00:00
|
|
|
flag = self.reward()
|
2020-04-01 14:40:21 +00:00
|
|
|
|
2020-04-10 07:19:02 +00:00
|
|
|
return flag
|
2020-04-01 14:40:21 +00:00
|
|
|
|
|
|
|
def _reward_receive(self):
|
|
|
|
"""
|
|
|
|
Returns:
|
|
|
|
bool: If rewarded.
|
|
|
|
"""
|
2020-05-05 09:27:19 +00:00
|
|
|
logger.hr('Reward receive')
|
2020-04-01 14:40:21 +00:00
|
|
|
|
|
|
|
reward = False
|
2020-04-28 06:37:13 +00:00
|
|
|
exit_timer = Timer(1, count=3)
|
2020-04-01 14:40:21 +00:00
|
|
|
click_timer = Timer(1)
|
|
|
|
exit_timer.start()
|
2020-04-06 11:01:22 +00:00
|
|
|
btn = []
|
|
|
|
if self.config.ENABLE_REWARD:
|
|
|
|
btn.append(REWARD_3)
|
|
|
|
if self.config.ENABLE_COMMISSION_REWARD:
|
|
|
|
btn.append(REWARD_1)
|
|
|
|
if self.config.ENABLE_OIL_REWARD:
|
|
|
|
btn.append(OIL)
|
|
|
|
if self.config.ENABLE_COIN_REWARD:
|
|
|
|
btn.append(COIN)
|
|
|
|
|
2020-04-01 14:40:21 +00:00
|
|
|
while 1:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
for button in [EXP_INFO_S_REWARD, GET_ITEMS_1, GET_ITEMS_2, GET_SHIP]:
|
|
|
|
if self.appear(button, interval=1):
|
Add: 适配第一章, 修复大量bug
- 修复处理夜间委托时, 出现递归调用的问题
- 增加红脸出击确认的功能
- 增加了透视识别错误图片保存的开关
- 修复了地图太小时, 透视识别报错的问题
- 修复了相机位于地图外时, 透视识别出错的问题
- 修复了离开退役时, 会连击的问题
- 修复了同时出现低心情和船坞已满弹窗时, 卡住的问题
- 更新了一键退役实装后的安全点击的位置
- 修复了换装滑动失败时, 卡住的问题
- 修复了关闭自动收获后, 出现委托完成的提示是, 进图卡住的问题
- 修复了, 无正在跑的委托时, 报错的问题
2020-04-11 07:23:51 +00:00
|
|
|
REWARD_SAVE_CLICK.name = button.name
|
2020-04-01 14:40:21 +00:00
|
|
|
self.device.click(REWARD_SAVE_CLICK)
|
2020-04-06 17:52:47 +00:00
|
|
|
click_timer.reset()
|
2020-04-01 14:40:21 +00:00
|
|
|
exit_timer.reset()
|
|
|
|
reward = True
|
|
|
|
continue
|
|
|
|
|
2020-05-05 09:27:19 +00:00
|
|
|
if click_timer.reached() and (
|
|
|
|
(self.config.ENABLE_OIL_REWARD and self.appear_then_click(OIL, interval=60))
|
|
|
|
or (self.config.ENABLE_COIN_REWARD and self.appear_then_click(COIN, interval=60))
|
|
|
|
or (self.config.ENABLE_COMMISSION_REWARD and self.appear_then_click(REWARD_1, interval=1))
|
|
|
|
or (self.config.ENABLE_REWARD and self.appear_then_click(REWARD_3, interval=1))
|
|
|
|
):
|
|
|
|
exit_timer.reset()
|
|
|
|
click_timer.reset()
|
|
|
|
reward = True
|
|
|
|
continue
|
2020-04-01 14:40:21 +00:00
|
|
|
|
2020-04-14 04:26:57 +00:00
|
|
|
if not self.appear(page_reward.check_button) or self.info_bar_count():
|
2020-04-13 08:07:32 +00:00
|
|
|
exit_timer.reset()
|
|
|
|
continue
|
|
|
|
|
2020-04-01 14:40:21 +00:00
|
|
|
# End
|
|
|
|
if exit_timer.reached():
|
|
|
|
break
|
|
|
|
|
|
|
|
return reward
|
|
|
|
|
|
|
|
def _reward_mission(self):
|
|
|
|
"""
|
|
|
|
Returns:
|
|
|
|
bool: If rewarded.
|
|
|
|
"""
|
|
|
|
logger.hr('Mission reward')
|
|
|
|
if not self.appear(MISSION_NOTICE):
|
|
|
|
logger.info('No mission reward')
|
|
|
|
return False
|
|
|
|
|
|
|
|
self.ui_goto(page_mission, skip_first_screenshot=True)
|
|
|
|
|
|
|
|
reward = False
|
2020-04-07 16:53:26 +00:00
|
|
|
exit_timer = Timer(2)
|
2020-04-01 14:40:21 +00:00
|
|
|
click_timer = Timer(1)
|
2020-04-06 17:52:47 +00:00
|
|
|
timeout = Timer(10)
|
2020-04-01 14:40:21 +00:00
|
|
|
exit_timer.start()
|
2020-04-06 17:52:47 +00:00
|
|
|
timeout.start()
|
2020-04-01 14:40:21 +00:00
|
|
|
while 1:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
2020-04-06 17:52:47 +00:00
|
|
|
for button in [GET_ITEMS_1, GET_ITEMS_2]:
|
|
|
|
if self.appear_then_click(button, offset=(30, 30), interval=1):
|
2020-04-01 14:40:21 +00:00
|
|
|
exit_timer.reset()
|
2020-04-24 07:26:11 +00:00
|
|
|
timeout.reset()
|
2020-04-01 14:40:21 +00:00
|
|
|
reward = True
|
|
|
|
continue
|
|
|
|
|
2020-04-06 17:52:47 +00:00
|
|
|
for button in [MISSION_MULTI, MISSION_SINGLE]:
|
2020-04-01 14:40:21 +00:00
|
|
|
if not click_timer.reached():
|
|
|
|
continue
|
|
|
|
if self.appear_then_click(button, interval=1):
|
|
|
|
exit_timer.reset()
|
|
|
|
click_timer.reset()
|
2020-04-24 07:26:11 +00:00
|
|
|
timeout.reset()
|
2020-04-06 17:52:47 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
if not self.appear(MISSION_CHECK):
|
|
|
|
if self.appear_then_click(GET_SHIP, interval=1):
|
|
|
|
click_timer.reset()
|
|
|
|
exit_timer.reset()
|
2020-04-24 07:26:11 +00:00
|
|
|
timeout.reset()
|
2020-04-01 14:40:21 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
# End
|
2020-04-06 17:52:47 +00:00
|
|
|
if reward and exit_timer.reached():
|
|
|
|
break
|
|
|
|
if timeout.reached():
|
|
|
|
logger.warning('Wait get items timeout.')
|
2020-04-01 14:40:21 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
self.ui_goto(page_main, skip_first_screenshot=True)
|
|
|
|
return reward
|
2020-05-06 15:53:25 +00:00
|
|
|
|
|
|
|
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)
|