diff --git a/route/daily/ForgottenHallStage1.py b/route/daily/ForgottenHallStage1.py index 05e6cd5bb..26fc3196e 100644 --- a/route/daily/ForgottenHallStage1.py +++ b/route/daily/ForgottenHallStage1.py @@ -25,7 +25,8 @@ class Route(RouteBase, ForgottenHallUI): logger.hr('Forgotten hall stage 1') self.stage_goto(KEYWORDS_DUNGEON_LIST.The_Last_Vestiges_of_Towering_Citadel, KEYWORDS_FORGOTTEN_HALL_STAGE.Stage_1) - self.team_choose_first_4() + if not self.team_is_prepared(): + self.team_choose_first_4() self.enter_forgotten_hall_dungeon() self.map_init(plane=Jarilo_BackwaterPass, position=(369.4, 643.4)) diff --git a/tasks/daily/use_technique.py b/tasks/daily/use_technique.py index eff114cdc..f7f15a3c7 100644 --- a/tasks/daily/use_technique.py +++ b/tasks/daily/use_technique.py @@ -56,7 +56,8 @@ class UseTechniqueUI(MapControlJoystick, ForgottenHallUI): logger.hr('Use techniques', level=2) self.stage_goto(KEYWORDS_DUNGEON_LIST.The_Last_Vestiges_of_Towering_Citadel, KEYWORDS_FORGOTTEN_HALL_STAGE.Stage_1) - self.team_choose_first() + if not self.team_is_prepared(): + self.team_choose_first_4() self.enter_forgotten_hall_dungeon() self._use_technique(count, skip_first_screenshot=skip_first_screenshot) self.exit_dungeon() diff --git a/tasks/forgotten_hall/team.py b/tasks/forgotten_hall/team.py index 9e4eadbab..0d4cfe34d 100644 --- a/tasks/forgotten_hall/team.py +++ b/tasks/forgotten_hall/team.py @@ -1,6 +1,7 @@ import cv2 import numpy as np +from module.base.timer import Timer from module.base.utils import color_similarity_2d, get_color from module.logger import logger from tasks.base.ui import UI @@ -72,3 +73,24 @@ class ForgottenHallTeam(UI): self.device.click(character) # Casual sleep, game may not respond that fast self.device.sleep((0.1, 0.2)) + + def team_is_prepared(self, skip_first_screenshot=True) -> bool: + """ + Pages: + in: ENTRANCE_CHECKED, ENTER_FORGOTTEN_HALL_DUNGEON + """ + characters = [CHARACTER_1, CHARACTER_2, CHARACTER_3, CHARACTER_4] + timeout = Timer(1, count=5).start() + while 1: + if skip_first_screenshot: + skip_first_screenshot = False + else: + self.device.screenshot() + + if timeout.reached(): + logger.info('Team not prepared') + return False + chosen_list = [self.is_character_chosen(c) for c in characters] + if all(chosen_list): + logger.info("Team already prepared") + return True