From f9f0b596576c44194cd40b51474526f4269200ea Mon Sep 17 00:00:00 2001 From: LmeSzinc Date: Tue, 5 May 2020 22:04:36 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E4=BF=AE=E5=A4=8D=E5=A4=9C=E9=97=B4?= =?UTF-8?q?=E5=A7=94=E6=89=98=E6=8D=95=E6=8D=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - module/device/device.py | 36 ++++++++++-------------------------- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 99f9c2f5d..05da8b0b5 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,6 @@ python -m uiautomator2 init - **GUI启动慢, uiautomator2启动慢** - **无法处理网络波动** 重连弹窗, 跳小黄鸡 -- **处理夜间委托的弹窗可能出错** 有捕捉, 但是可能会在一些奇怪的时间弹出来 - **会显示绿脸黄脸红脸, 红脸出击确认** 这个是瓜游心情值更新BUG的锅了, 只要填对了`RECOVER_PER_HOUR` 和 `EMOTION_LIMIT` 就不会红脸出击, 或者保证一直处于经验加成状态. - **演习可能SL失败** 演习看的是屏幕上方的血槽, 血槽可能被立绘遮挡, 因此需要一定时间(默认1s)血量低于一定值(默认40%)才会触发SL. 一个血皮后排就有30%左右的血槽, 所以别以为在1s内被打掉40%是不可能的. 另外如果后排立绘过大且CD重叠严重, 建议增大确认时间(比如3s), 或者换皮肤, 这样可以减少误判. - **极少数情况下ADB和uiautomator2会抽风** diff --git a/module/device/device.py b/module/device/device.py index 6c354371c..6667a12a6 100644 --- a/module/device/device.py +++ b/module/device/device.py @@ -1,6 +1,5 @@ from datetime import datetime, time -from module.base.timer import Timer from module.device.app import AppControl from module.device.control import Control from module.device.screenshot import Screenshot @@ -9,7 +8,7 @@ from module.logger import logger class Device(Screenshot, Control, AppControl): - def handle_night_commission(self, hour=21, threshold=5): + def handle_night_commission(self, hour=21, threshold=30): """ Args: hour (int): Hour that night commission refresh. @@ -24,35 +23,20 @@ class Device(Screenshot, Control, AppControl): if now > time(hour, 0, threshold): return False - logger.info('Handling night commission') - wait = Timer(10) - wait.start() + if GET_MISSION.match(self.image, offset=True): + logger.info('Night commission appear.') + self.click(GET_MISSION) + return True - while 1: - super().screenshot() - - if GET_MISSION.appear_on(self.image): - super().click(GET_MISSION) - - if wait.reached(): - break - - logger.info('Handle night commission finished') - return True + return False def screenshot(self): """ Returns: PIL.Image.Image: """ - self.handle_night_commission() - return super().screenshot() - - def click(self, button): - self.handle_night_commission() - return super().click(button) - - 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) + super().screenshot() + if self.handle_night_commission(): + super().screenshot() + return self.image