Fix: 修复调用错误心情对象的问题

This commit is contained in:
LmeSzinc 2020-05-24 20:11:23 +08:00
parent f327ef0027
commit f32042fbd2
3 changed files with 26 additions and 27 deletions

View File

@ -24,6 +24,7 @@ class CampaignRun(CampaignUI, Reward, LoginHandler):
config: AzurLaneConfig config: AzurLaneConfig
campaign: CampaignBase campaign: CampaignBase
run_count: int run_count: int
start_time = datetime.now()
def load_campaign(self, name, folder='campaign_main'): def load_campaign(self, name, folder='campaign_main'):
""" """
@ -103,6 +104,30 @@ class CampaignRun(CampaignUI, Reward, LoginHandler):
return False 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.campaign.config.IGNORE_LOW_EMOTION_WARN:
if self.campaign.emotion.triggered_bug():
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
def run(self, name, folder='campaign_main', total=0): def run(self, name, folder='campaign_main', total=0):
""" """
Args: Args:

View File

@ -114,6 +114,7 @@ class Emotion:
The game does not calculate emotion correctly, which is a bug in AzurLane. 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. After a long run, we have to restart the game to update it.
""" """
logger.attr('Emotion_bug', f'{self.total_reduced}/{self.BUG_THRESHOLD}')
if self.total_reduced >= self.BUG_THRESHOLD: if self.total_reduced >= self.BUG_THRESHOLD:
self.total_reduced = 0 self.total_reduced = 0
return True return True

View File

@ -2,13 +2,10 @@ from module.base.timer import Timer
from module.combat.combat import Combat from module.combat.combat import Combat
from module.handler.assets import * from module.handler.assets import *
from module.logger import logger from module.logger import logger
from datetime import datetime
from module.ui.ui import MAIN_CHECK, EVENT_LIST_CHECK, BACK_ARROW from module.ui.ui import MAIN_CHECK, EVENT_LIST_CHECK, BACK_ARROW
class LoginHandler(Combat): class LoginHandler(Combat):
start_time = datetime.now()
def handle_app_login(self): def handle_app_login(self):
logger.hr('App login') logger.hr('App login')
@ -54,27 +51,3 @@ class LoginHandler(Combat):
return True return True
return False 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:
if self.emotion.triggered_bug():
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