diff --git a/module/base/timer.py b/module/base/timer.py index d0a8a4da9..f9fc6f31d 100644 --- a/module/base/timer.py +++ b/module/base/timer.py @@ -96,6 +96,9 @@ class Timer: def start(self): if not self.started(): self._current = time.time() + self._reach_count = 0 + + return self def started(self): return bool(self._current) diff --git a/module/equipment/equipment.py b/module/equipment/equipment.py index 9d2c6b1cb..d23e55158 100644 --- a/module/equipment/equipment.py +++ b/module/equipment/equipment.py @@ -27,11 +27,6 @@ class Equipment(InfoHandler): self.device.screenshot() if SWIPE_CHECK.match(self.device.image): - if swipe_timer.reached(): - import time - from PIL import Image - self.device.image.save(f'{int(time.time() * 1000)}.png') - Image.fromarray(SWIPE_CHECK.image).save(f'{int(time.time() * 1000)}.png') continue if self.appear(check_button, offset=(30, 30)) and not SWIPE_CHECK.match(self.device.image): diff --git a/module/exercise/combat.py b/module/exercise/combat.py index 2c711a137..cf9a38454 100644 --- a/module/exercise/combat.py +++ b/module/exercise/combat.py @@ -32,8 +32,7 @@ class ExerciseCombat(HpDaemon, OpponentChoose, ExerciseEquipment): bool: True if wins. False if quit. """ logger.info('Combat execute') - self.low_hp_confirm_timer = Timer(self.config.LOW_HP_CONFIRM_WAIT, count=2) - self.low_hp_confirm_timer.start() + self.low_hp_confirm_timer = Timer(self.config.LOW_HP_CONFIRM_WAIT, count=2).start() show_hp_timer = Timer(5) success = True end = False diff --git a/module/handler/info_handler.py b/module/handler/info_handler.py index e05a24e22..ba84a3e91 100644 --- a/module/handler/info_handler.py +++ b/module/handler/info_handler.py @@ -110,8 +110,7 @@ class InfoHandler(ModuleBase): def ensure_no_story(self, skip_first_screenshot=True): logger.info('Ensure no story') - story_timer = Timer(5, count=4) - story_timer.start() + story_timer = Timer(5, count=10).start() while 1: if skip_first_screenshot: skip_first_screenshot = False diff --git a/module/handler/login.py b/module/handler/login.py index 077bc3746..3877ce269 100644 --- a/module/handler/login.py +++ b/module/handler/login.py @@ -9,7 +9,7 @@ class LoginHandler(Combat): def handle_app_login(self): logger.hr('App login') - confirm_timer = Timer(1.5, count=4) + confirm_timer = Timer(1.5, count=4).start() while 1: self.device.screenshot() diff --git a/module/reward/reward.py b/module/reward/reward.py index 05b44e4b2..112a3edb6 100644 --- a/module/reward/reward.py +++ b/module/reward/reward.py @@ -52,9 +52,8 @@ class Reward(RewardCommission, RewardTacticalClass): logger.hr('Reward receive') reward = False - exit_timer = Timer(1, count=3) + exit_timer = Timer(1, count=3).start() click_timer = Timer(1) - exit_timer.start() btn = [] if self.config.ENABLE_REWARD: btn.append(REWARD_3) diff --git a/module/reward/tactical_class.py b/module/reward/tactical_class.py index 4f19024ab..17164b74e 100644 --- a/module/reward/tactical_class.py +++ b/module/reward/tactical_class.py @@ -148,8 +148,6 @@ class BookGroup: class RewardTacticalClass(UI, InfoHandler): - tactical_animation_timer = Timer(2, count=3) - def _tactical_animation_running(self): """ Returns: @@ -208,6 +206,8 @@ class RewardTacticalClass(UI, InfoHandler): return False logger.hr('Tactical class receive') + tactical_class_timout = Timer(10, count=10).start() + tactical_animation_timer = Timer(2, count=3).start() while 1: if skip_first_screenshot: skip_first_screenshot = False @@ -215,11 +215,14 @@ class RewardTacticalClass(UI, InfoHandler): self.device.screenshot() if self.appear_then_click(REWARD_2, interval=1): + tactical_class_timout.reset() continue if self.handle_popup_confirm(): + tactical_class_timout.reset() continue if self.handle_urgent_commission(save_get_items=False): # Only one button in the middle, when skill reach max level. + tactical_class_timout.reset() continue if self.appear(TACTICAL_CLASS_CANCEL, offset=(30, 30), interval=2) \ and self.appear(TACTICAL_CLASS_START, offset=(30, 30)): @@ -228,17 +231,21 @@ class RewardTacticalClass(UI, InfoHandler): self._tactical_books_choose() self.device.click(TACTICAL_CLASS_START) self.interval_reset(TACTICAL_CLASS_CANCEL) + tactical_class_timout.reset() continue # End if self.appear(TACTICAL_CHECK, offset=(20, 20)): self.ui_current = page_tactical if not self._tactical_animation_running(): - if self.tactical_animation_timer.reached(): + if tactical_animation_timer.reached(): logger.info('Tactical reward end.') break else: - self.tactical_animation_timer.reset() + tactical_animation_timer.reset() + if tactical_class_timout.reached(): + logger.info('Tactical reward timeout.') + break self.ui_goto(page_reward, skip_first_screenshot=True) return True