diff --git a/module/combat/emotion.py b/module/combat/emotion.py index df84bc0d8..c4b453350 100644 --- a/module/combat/emotion.py +++ b/module/combat/emotion.py @@ -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 diff --git a/module/handler/login.py b/module/handler/login.py index d01f22d06..5d3c23105 100644 --- a/module/handler/login.py +++ b/module/handler/login.py @@ -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