Skip to content

Commit

Permalink
fix auto fight
Browse files Browse the repository at this point in the history
  • Loading branch information
pur1fying committed Jan 17, 2024
1 parent f5484cf commit 9ca816d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
47 changes: 36 additions & 11 deletions module/main_story.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import time

import cv2

from core import color, picture


Expand All @@ -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")
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions module/normal_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down

0 comments on commit 9ca816d

Please sign in to comment.