From 6acd64a1f4172f8034f6c25fc810c1e3d979b514 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Fri, 8 Dec 2023 22:00:11 +0800 Subject: [PATCH] Fix: Lang check failed due to popup --- tasks/base/main_page.py | 6 +++++- tasks/base/popup.py | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tasks/base/main_page.py b/tasks/base/main_page.py index c590d8cea..07aa90278 100644 --- a/tasks/base/main_page.py +++ b/tasks/base/main_page.py @@ -64,6 +64,7 @@ class MainPage(PopupHandler): plane: MapPlane = KEYWORDS_MAP_PLANE.Herta_ParlorCar _lang_checked = False + _lang_check_success = True def update_plane(self, lang=None) -> MapPlane | None: """ @@ -108,6 +109,8 @@ class MainPage(PopupHandler): if lang_unknown or lang != server.lang: self.config.Emulator_GameLanguage = lang server.set_lang(lang) + MainPage._lang_checked = True + MainPage._lang_check_success = True return lang if lang_unknown: @@ -115,6 +118,8 @@ class MainPage(PopupHandler): raise RequestHumanTakeover else: logger.warning(f'Cannot detect in-game text language, assume current lang={server.lang} is correct') + MainPage._lang_checked = True + MainPage._lang_check_success = False return server.lang def handle_lang_check(self, page: Page): @@ -131,7 +136,6 @@ class MainPage(PopupHandler): return False self.check_lang_from_map_plane() - MainPage._lang_checked = True return True def acquire_lang_checked(self): diff --git a/tasks/base/popup.py b/tasks/base/popup.py index 3e18c9be5..e5bc781d2 100644 --- a/tasks/base/popup.py +++ b/tasks/base/popup.py @@ -72,8 +72,16 @@ class PopupHandler(ModuleBase): If handled. """ if self.appear_then_click(MONTHLY_CARD_REWARD, interval=interval): + # Language check at the first login of the day may fail due to popups + # Retry later + from tasks.base.main_page import MainPage + if not MainPage._lang_check_success: + MainPage._lang_checked = False return True if self.appear_then_click(MONTHLY_CARD_GET_ITEM, interval=interval): + from tasks.base.main_page import MainPage + if not MainPage._lang_check_success: + MainPage._lang_checked = False return True return False