From 9c77cdd058fcea9411bd1ea6f627e5daadc88fe7 Mon Sep 17 00:00:00 2001 From: LmeSzinc Date: Tue, 19 May 2020 22:58:25 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E4=BF=AE=E5=A4=8D=E9=95=BF=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=BF=90=E8=A1=8C=E6=97=B6,=20=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E5=86=85=E5=BF=83=E6=83=85=E5=80=BC=E8=AE=A1=E7=AE=97bug?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 未开启红脸出击时, 会每隔两个半小时重启游戏 --- README.md | 2 +- module/campaign/run.py | 5 +---- module/handler/login.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1bcc87435..1410b6d3e 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ python -m uiautomator2 init - **GUI启动慢, uiautomator2启动慢** - **无法处理网络波动** 重连弹窗, 跳小黄鸡 -- **会显示绿脸黄脸红脸, 红脸出击确认** 这个是瓜游心情值更新BUG的锅了, 只要填对了`RECOVER_PER_HOUR` 和 `EMOTION_LIMIT` 就不会红脸出击, 或者保证一直处于经验加成状态. +- **会显示绿脸黄脸红脸** 这个是瓜游心情值更新BUG, Alas会每隔2.5小时重启游戏来更新心情. - **演习可能SL失败** 演习看的是屏幕上方的血槽, 血槽可能被立绘遮挡, 因此需要一定时间(默认1s)血量低于一定值(默认40%)才会触发SL. 一个血皮后排就有30%左右的血槽, 所以别以为在1s内被打掉40%是不可能的. 另外如果后排立绘过大且CD重叠严重, 建议增大确认时间(比如3s), 或者换皮肤, 这样可以减少误判. - **极少数情况下ADB和uiautomator2会抽风** - **拖动操作在极少数情况下无效** diff --git a/module/campaign/run.py b/module/campaign/run.py index 38df8f946..423696c11 100644 --- a/module/campaign/run.py +++ b/module/campaign/run.py @@ -112,11 +112,8 @@ class CampaignRun(CampaignUI, Reward, LoginHandler): """ self.load_campaign(name, folder=folder) self.run_count = 0 - start_date = datetime.now().date() while 1: - if datetime.now().date() != start_date: - start_date = datetime.now().date() - self.app_restart() + if self.handle_app_restart(): self.campaign.fleet_checked_reset() if self.handle_reward(): self.campaign.fleet_checked_reset() diff --git a/module/handler/login.py b/module/handler/login.py index 077bc3746..49f3da658 100644 --- a/module/handler/login.py +++ b/module/handler/login.py @@ -2,10 +2,13 @@ from module.base.timer import Timer from module.combat.combat import Combat from module.handler.assets import * from module.logger import logger +from datetime import datetime, timedelta from module.ui.ui import MAIN_CHECK, EVENT_LIST_CHECK, BACK_ARROW class LoginHandler(Combat): + start_time = datetime.now() + def handle_app_login(self): logger.hr('App login') @@ -51,3 +54,29 @@ class LoginHandler(Combat): return True return False + + def _triggered_app_restart(self): + """ + Returns: + bool: If triggered a restart condition. + """ + now = datetime.now() + if now.date() != self.start_time.date(): + logger.hr('Triggered restart new day') + return True + if not self.config.IGNORE_LOW_EMOTION_WARN: + # The game does not calculate emotion correctly, which is a bug in AzurLane. + # After a long run, we have to restart the game to update it. + if now - self.start_time > timedelta(hours=2, minutes=30): + logger.hr('Triggered restart avoid emotion bug') + return True + + return False + + def handle_app_restart(self): + if self._triggered_app_restart(): + self.app_restart() + self.start_time = datetime.now() + return True + + return False