From 4c0786b38f34dbd610934f4b47869be55d4e2a9d Mon Sep 17 00:00:00 2001 From: Small_Ku Date: Sat, 17 Aug 2024 23:13:51 +0800 Subject: [PATCH 1/4] feat: allow fast echo pickup while searching --- src/task/BaseWWTask.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/task/BaseWWTask.py b/src/task/BaseWWTask.py index 6a4f071..7a04344 100644 --- a/src/task/BaseWWTask.py +++ b/src/task/BaseWWTask.py @@ -192,6 +192,12 @@ class BaseWWTask(BaseTask, FindFeature, OCR): highest_index = 0 threshold = 0.02 for i in range(4): + if self.find_f_with_text(target_text=self.absorb_echo_text): + self.send_key('f') + if not self.handle_claim_button(): + logger.debug(f'farm echo found echo before turn and find') + self.sleep(0.5) + return True self.middle_click_relative(0.5, 0.5, down_time=0.2) self.sleep(1) color_percent = self.calculate_color_percentage(echo_color, box) From 3eb423fb35c39b68945aa6934c3a28969017d1cb Mon Sep 17 00:00:00 2001 From: Small_Ku Date: Sun, 18 Aug 2024 01:52:47 +0800 Subject: [PATCH 2/4] refactor: use walk_until_f --- src/task/BaseWWTask.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/task/BaseWWTask.py b/src/task/BaseWWTask.py index 7a04344..5df042d 100644 --- a/src/task/BaseWWTask.py +++ b/src/task/BaseWWTask.py @@ -192,12 +192,8 @@ class BaseWWTask(BaseTask, FindFeature, OCR): highest_index = 0 threshold = 0.02 for i in range(4): - if self.find_f_with_text(target_text=self.absorb_echo_text): - self.send_key('f') - if not self.handle_claim_button(): - logger.debug(f'farm echo found echo before turn and find') - self.sleep(0.5) - return True + if self.walk_until_f(target_text=self.absorb_echo_text(), raise_if_not_found=False): + return True self.middle_click_relative(0.5, 0.5, down_time=0.2) self.sleep(1) color_percent = self.calculate_color_percentage(echo_color, box) From 802978e569d12d3adc676dcd8518d55acb817863 Mon Sep 17 00:00:00 2001 From: ok-oldking <154002444+ok-oldking@users.noreply.github.com> Date: Sun, 18 Aug 2024 10:02:06 +0800 Subject: [PATCH 3/4] Update BaseWWTask.py --- src/task/BaseWWTask.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/task/BaseWWTask.py b/src/task/BaseWWTask.py index 5df042d..e52f71a 100644 --- a/src/task/BaseWWTask.py +++ b/src/task/BaseWWTask.py @@ -187,13 +187,13 @@ class BaseWWTask(BaseTask, FindFeature, OCR): return True def turn_and_find_echo(self): + if self.walk_until_f(target_text=self.absorb_echo_text(), raise_if_not_found=False): + return True box = self.box_of_screen(0.25, 0.20, 0.75, 0.53, hcenter=True) highest_percent = 0 highest_index = 0 - threshold = 0.02 - for i in range(4): - if self.walk_until_f(target_text=self.absorb_echo_text(), raise_if_not_found=False): - return True + threshold = 0.02 + for i in range(4): self.middle_click_relative(0.5, 0.5, down_time=0.2) self.sleep(1) color_percent = self.calculate_color_percentage(echo_color, box) From a22c2c8ef6a0dea03ba16b8640e6c4c5a0ffb959 Mon Sep 17 00:00:00 2001 From: ok-oldking <154002444+ok-oldking@users.noreply.github.com> Date: Sun, 18 Aug 2024 10:02:45 +0800 Subject: [PATCH 4/4] Update BaseWWTask.py --- src/task/BaseWWTask.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/task/BaseWWTask.py b/src/task/BaseWWTask.py index e52f71a..bbb94eb 100644 --- a/src/task/BaseWWTask.py +++ b/src/task/BaseWWTask.py @@ -192,8 +192,8 @@ class BaseWWTask(BaseTask, FindFeature, OCR): box = self.box_of_screen(0.25, 0.20, 0.75, 0.53, hcenter=True) highest_percent = 0 highest_index = 0 - threshold = 0.02 - for i in range(4): + threshold = 0.02 + for i in range(4): self.middle_click_relative(0.5, 0.5, down_time=0.2) self.sleep(1) color_percent = self.calculate_color_percentage(echo_color, box)