Fix: 修复长时间运行时, 游戏内心情值计算bug导致的出错

- 未开启红脸出击时, 累计消耗100心情后重启游戏
This commit is contained in:
LmeSzinc 2020-05-21 12:26:28 +08:00
parent 75dab4db70
commit bd8090dff5
2 changed files with 17 additions and 4 deletions

View File

@ -8,6 +8,9 @@ config_name = 'EmotionRecord'
class Emotion:
total_reduced = 0
BUG_THRESHOLD = 100
def __init__(self, config):
"""
Args:
@ -59,6 +62,7 @@ class Emotion:
self.update()
self.emotion[config_name][f'fleet_{index}_emotion'] = str(int(
self.emotion[config_name][f'fleet_{index}_emotion']) - 2)
self.total_reduced += 2
self.record()
def recovered_time(self, fleet=(1, 2)):
@ -104,3 +108,14 @@ class Emotion:
logger.attr('Emotion recovered', recovered_time)
self.config.EMOTION_LIMIT_TRIGGERED = True
sleep(60)
def triggered_bug(self):
"""
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 self.total_reduced >= self.BUG_THRESHOLD:
self.total_reduced = 0
return True
return False

View File

@ -2,7 +2,7 @@ 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 datetime import datetime
from module.ui.ui import MAIN_CHECK, EVENT_LIST_CHECK, BACK_ARROW
@ -65,9 +65,7 @@ class LoginHandler(Combat):
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):
if self.emotion.triggered_bug():
logger.hr('Triggered restart avoid emotion bug')
return True