From 34af75245e5610871abda51c750fe3200e820fd4 Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Sat, 10 Aug 2024 17:49:26 +0800 Subject: [PATCH] fix(tc): improve stability of reward --- tasks/tactical_challenge/tactical_challenge.py | 2 -- tasks/tactical_challenge/ui.py | 11 ++++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tasks/tactical_challenge/tactical_challenge.py b/tasks/tactical_challenge/tactical_challenge.py index 726f7a6..8540c14 100644 --- a/tasks/tactical_challenge/tactical_challenge.py +++ b/tasks/tactical_challenge/tactical_challenge.py @@ -41,8 +41,6 @@ class TacticalChallenge(TacticalChallengeUI): def _handle_challenge(self, status): match status: case TCStatus.REWARD: - if self.ui_additional(): - return status if self.get_reward(): return TCStatus.OCR case TCStatus.OCR: diff --git a/tasks/tactical_challenge/ui.py b/tasks/tactical_challenge/ui.py index a0c6a73..db94765 100644 --- a/tasks/tactical_challenge/ui.py +++ b/tasks/tactical_challenge/ui.py @@ -26,17 +26,26 @@ class TacticalChallengeUI(UI): def get_reward(self): timer = Timer(10, 10).start() + action_timer = Timer(0.5, 1) while 1: self.device.screenshot() - self.ui_additional() + if not action_timer.reached_and_reset(): + continue + if self.handle_insufficient_inventory(): + logger.warning('Insufficient inventory, skip reward') + return True + if self.ui_additional(): + continue if self.match_color(GOT_REWARD_DAILY) and self.match_color(GOT_REWARD_CREDIT): return True if self.match_color(GET_REWARD_DAILY): self.click_with_interval(GET_REWARD_DAILY, 0.3) logger.info('Get daily reward') + continue if self.match_color(GET_REWARD_CREDIT): self.click_with_interval(GET_REWARD_CREDIT, 0.3) logger.info('Get credit reward') + continue if timer.reached(): return False