2020-03-31 14:16:21 +00:00
|
|
|
from datetime import datetime, time
|
|
|
|
|
|
|
|
from module.base.timer import Timer
|
2020-04-10 06:18:10 +00:00
|
|
|
from module.device.app import AppControl
|
2020-03-28 17:22:46 +00:00
|
|
|
from module.device.control import Control
|
|
|
|
from module.device.screenshot import Screenshot
|
2020-03-31 14:16:21 +00:00
|
|
|
from module.handler.assets import GET_MISSION
|
|
|
|
from module.logger import logger
|
2020-03-28 17:22:46 +00:00
|
|
|
|
|
|
|
|
2020-04-10 06:18:10 +00:00
|
|
|
class Device(Screenshot, Control, AppControl):
|
2020-03-31 14:16:21 +00:00
|
|
|
def handle_night_commission(self, hour=21, threshold=5):
|
|
|
|
"""
|
|
|
|
Args:
|
|
|
|
hour (int): Hour that night commission refresh.
|
|
|
|
threshold (int): Seconds around refresh time.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
bool: If handled.
|
|
|
|
"""
|
|
|
|
now = datetime.now().time()
|
|
|
|
if now < time(hour - 1, 59, 60 - threshold):
|
|
|
|
return False
|
|
|
|
if now > time(hour, 0, threshold):
|
|
|
|
return False
|
|
|
|
|
|
|
|
logger.info('Handling night commission')
|
|
|
|
wait = Timer(10)
|
|
|
|
wait.start()
|
|
|
|
|
|
|
|
while 1:
|
|
|
|
super().screenshot()
|
|
|
|
|
|
|
|
if GET_MISSION.appear_on(self.image):
|
Add: 适配第一章, 修复大量bug
- 修复处理夜间委托时, 出现递归调用的问题
- 增加红脸出击确认的功能
- 增加了透视识别错误图片保存的开关
- 修复了地图太小时, 透视识别报错的问题
- 修复了相机位于地图外时, 透视识别出错的问题
- 修复了离开退役时, 会连击的问题
- 修复了同时出现低心情和船坞已满弹窗时, 卡住的问题
- 更新了一键退役实装后的安全点击的位置
- 修复了换装滑动失败时, 卡住的问题
- 修复了关闭自动收获后, 出现委托完成的提示是, 进图卡住的问题
- 修复了, 无正在跑的委托时, 报错的问题
2020-04-11 07:23:51 +00:00
|
|
|
super().click(GET_MISSION)
|
2020-03-31 14:16:21 +00:00
|
|
|
|
|
|
|
if wait.reached():
|
|
|
|
break
|
|
|
|
|
|
|
|
logger.info('Handle night commission finished')
|
|
|
|
return True
|
|
|
|
|
|
|
|
def screenshot(self):
|
|
|
|
"""
|
|
|
|
Returns:
|
|
|
|
PIL.Image.Image:
|
|
|
|
"""
|
|
|
|
self.handle_night_commission()
|
|
|
|
return super().screenshot()
|
2020-04-06 17:52:47 +00:00
|
|
|
|
2020-04-14 04:26:57 +00:00
|
|
|
def click(self, button):
|
2020-04-06 17:52:47 +00:00
|
|
|
self.handle_night_commission()
|
2020-04-14 04:26:57 +00:00
|
|
|
return super().click(button)
|
2020-04-06 17:52:47 +00:00
|
|
|
|
|
|
|
def swipe(self, vector, box=(123, 159, 1193, 628), random_range=(0, 0, 0, 0), padding=15, duration=(0.1, 0.2)):
|
|
|
|
self.handle_night_commission()
|
|
|
|
return super().swipe(vector=vector, box=box, random_range=random_range, padding=padding, duration=duration)
|
|
|
|
|