From 9ca816d2a0c396f074d7e559b4af51b0d40ffcca Mon Sep 17 00:00:00 2001 From: pur1fy <2274916027@qq.com> Date: Wed, 17 Jan 2024 23:14:17 +0800 Subject: [PATCH] fix auto fight --- module/main_story.py | 47 +++++++++++++++++++++++++++++++++---------- module/normal_task.py | 3 +-- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/module/main_story.py b/module/main_story.py index da4bdddde..18953ea74 100644 --- a/module/main_story.py +++ b/module/main_story.py @@ -1,4 +1,7 @@ import time + +import cv2 + from core import color, picture @@ -19,29 +22,51 @@ def implement(self): self.logger.info("START pushing main story") self.quick_method_to_main_page() to_main_story(self) - return True + +def judge_acc(self): + if color.judge_rgb_range(self.latest_img_array, 1170, 621, 200, 255, 200, 255, 200, 255) and \ + color.judge_rgb_range(self.latest_img_array, 1250, 621, 200, 255, 200, 255, 200, 255): + return 1 + elif color.judge_rgb_range(self.latest_img_array, 1250, 621, 100, 150, 200, 255, 200, 255) and \ + color.judge_rgb_range(self.latest_img_array, 1170, 621, 100, 155, 200, 255, 200, 255): + return 2 + elif color.judge_rgb_range(self.latest_img_array, 1250, 621, 210, 255, 180, 240, 0, 80) and \ + color.judge_rgb_range(self.latest_img_array, 1170, 621, 200, 255, 180, 240, 0, 80): + return 3 + return 'UNKNOWN' + + +def judge_auto(self): + if color.judge_rgb_range(self.latest_img_array, 1250, 677, 200, 255, 200, 255, 200, 255) and \ + color.judge_rgb_range(self.latest_img_array, 1170, 677, 200, 255, 200, 255, 200, 255): + return 'off' + elif color.judge_rgb_range(self.latest_img_array, 1250, 677, 200, 255, 180, 240, 0, 80) and \ + color.judge_rgb_range(self.latest_img_array, 1170, 677, 200, 255, 180, 240, 0, 80): + return 'on' + + def change_acc_auto(self): y = 625 - acc_r_ave = int(self.latest_img_array[y][1196][0]) // 3 + int(self.latest_img_array[y][1215][0]) // 3 + int( - self.latest_img_array[y][1230][0]) // 3 - if 250 <= acc_r_ave <= 260: + acc_phase = judge_acc(self) + if acc_phase == 1: self.logger.info("CHANGE acceleration phase from 2 to 3") self.click(1215, y) - elif 0 <= acc_r_ave <= 60: - self.logger.info("ACCELERATION phase 3") - elif 140 <= acc_r_ave <= 180: + elif acc_phase == 2: self.logger.info("CHANGE acceleration phase from 1 to 3") self.click(1215, y, wait=False, count=2) + elif acc_phase == 3: + self.logger.info("ACCELERATION phase 3") else: self.logger.warning("CAN'T DETECT acceleration BUTTON") y = 677 - auto_r_ave = int(self.latest_img_array[y][1171][0]) // 2 + int(self.latest_img_array[y][1246][0]) // 2 - if 190 <= auto_r_ave <= 230: + + auto_phase = judge_auto(self) + if auto_phase == 'off': self.logger.info("CHANGE MANUAL to auto") self.click(1215, y, wait=False) - elif 0 <= auto_r_ave <= 60: + elif auto_phase == 'on': self.logger.info("AUTO") else: self.logger.warning("can't identify auto button") @@ -51,7 +76,7 @@ def enter_fight(self): t_start = time.time() while time.time() <= t_start + 20: self.latest_img_array = self.get_screenshot_array() - if not color.judge_rgb_range(self.latest_img_array, 831, 692, 0, 64, 161, 217, 240, 255): + if not color.judge_rgb_range(self.latest_img_array, 897, 692, 0, 64, 161, 217, 240, 255): time.sleep(self.screenshot_interval) else: break diff --git a/module/normal_task.py b/module/normal_task.py index 6f19b01e5..c1561e21d 100644 --- a/module/normal_task.py +++ b/module/normal_task.py @@ -117,7 +117,6 @@ def to_normal_event(self, skip_first_screenshot=False): "event_hard": (805, 165), "main_page": (1198, 580), "campaign": (823, 261), - "reward_acquired": (640, 116), "mission_info": (task_info_x[self.server], 142), "purchase_ap_notice": (919, 168), "start_sweep_notice": (887, 164), @@ -137,7 +136,7 @@ def to_normal_event(self, skip_first_screenshot=False): 'normal_task_auto-over': (1082, 599), 'normal_task_task-finish': (1038, 662), 'normal_task_prize-confirm': (776, 655), - 'main_story_fight-confirm': (1168, 659), + 'normal_task_fight-confirm': (1168, 659), 'normal_task_fight-complete-confirm': (1160, 666), 'normal_task_reward-acquired-confirm': (800, 660), 'normal_task_mission-conclude-confirm': (1042, 671),