Skip to content

Commit 542b2cf

Browse files
committed
优化获取轮次信息
1 parent 1b46c62 commit 542b2cf

4 files changed

Lines changed: 34 additions & 25 deletions

File tree

src/tasks/AutoDefence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def do_run(self):
7070
_status = self.handle_mission_interface(stop_func=self.stop_func)
7171
if _status == Mission.START:
7272
self.wait_until(self.in_team, time_out=30)
73-
self.log_info_notify("任务完成")
73+
self.log_info_notify("任务开始")
7474
self.soundBeep()
7575
self.init_param()
7676
elif _status == Mission.STOP:

src/tasks/AutoExcavation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ def stop_func(self):
8282
if self.current_round >= self.config.get("轮次", 3):
8383
return True
8484

85-
def find_target_health_bar(self, threshold: float = 0.5):
85+
def find_target_health_bar(self, threshold: float = 0.6):
8686
health_bar_box = self.box_of_screen_scaled(2560, 1440, 131, 488, 406, 501, name="health_bar", hcenter=True)
8787
self.draw_boxes("health_bar", health_bar_box, color="blue")
8888
min_width = self.width_of_screen(200 / 2560)
8989
min_height = self.height_of_screen(8 / 1440)
90-
health_bar = find_color_rectangles(self.frame, green_health_bar_color, min_width, min_height, box=health_bar_box, threshold=0.6)
90+
health_bar = find_color_rectangles(self.frame, green_health_bar_color, min_width, min_height, box=health_bar_box, threshold=threshold)
9191
self.draw_boxes(boxes=health_bar)
9292
return health_bar
9393

src/tasks/AutoExpulsion.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,27 @@ def do_run(self):
4747
while True:
4848
if self.in_team():
4949
if _start_time == 0:
50+
_count += 1
5051
self.move_on_begin()
5152
_start_time = time.time()
5253
_skill_time = self.use_skill(_skill_time)
5354
if time.time() - _start_time >= self.config.get("任务超时时间", 120):
5455
logger.info("已经超时,重开任务...")
5556
self.give_up_mission()
57+
self.sleep(1)
5658
self.wait_until(lambda: not self.in_team(), time_out=30)
5759

5860
_status = self.handle_mission_interface()
5961
if _status == Mission.START:
60-
self.log_info("任务完成")
61-
_count += 1
62+
self.wait_until(self.in_team, time_out=30)
6263
if _count >= self.config.get("刷几次", 999):
64+
self.sleep(1)
65+
self.open_in_mission_menu()
66+
self.log_info("任务终止")
6367
return
64-
self.wait_until(self.in_team, time_out=30)
68+
self.log_info("任务开始")
6569
self.sleep(2.5)
66-
_start_time = time.time()
67-
self.move_on_begin()
70+
_start_time = 0
6871
self.sleep(0.2)
6972

7073
def move_on_begin(self):

src/tasks/CommissionsTask.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def setup_commission_config(self):
2727
self.default_config.update({
2828
"委托手册": "不使用",
2929
"使用技能": "不使用",
30-
"技能释放频率": 5,
30+
"技能释放频率": 5.0,
3131
"启用自动穿引共鸣": True,
3232
"发出声音提醒": True,
3333
"自动选择首个密函和密函奖励": True,
@@ -75,7 +75,7 @@ def find_drop_rate_btn(self, threshold=0):
7575
def find_esc_menu(self, threshold=0):
7676
return self.find_one("quit_big_icon", threshold=threshold)
7777

78-
def open_in_mission_menu(self, time_out=10, raise_if_not_found=True):
78+
def open_in_mission_menu(self, time_out=20, raise_if_not_found=True):
7979
if self.find_esc_menu():
8080
return True
8181
found = False
@@ -114,7 +114,7 @@ def quit_mission(self, timeout=10):
114114
)
115115
self.sleep(0.5)
116116
self.click_until(
117-
click_func=lambda: self.click_box(quit_btn),
117+
click_func=lambda: self.click_box(quit_btn, after_sleep=0.25),
118118
check_func=lambda: not self.find_quit_btn(),
119119
time_out=action_timeout,
120120
)
@@ -150,7 +150,7 @@ def continue_mission(self, timeout=10):
150150
self.find_continue_btn, time_out=action_timeout, raise_if_not_found=True
151151
)
152152
self.click_until(
153-
click_func=lambda: self.click_box(continue_btn),
153+
click_func=lambda: self.click_box(continue_btn, after_sleep=0.25),
154154
check_func=lambda: not self.find_continue_btn(),
155155
time_out=action_timeout,
156156
)
@@ -159,13 +159,12 @@ def continue_mission(self, timeout=10):
159159

160160
def choose_drop_rate(self, timeout=10):
161161
action_timeout = self.safe_get("action_timeout", timeout)
162+
self.sleep(0.5)
162163
self.choose_drop_rate_item()
163164
box = self.box_of_screen_scaled(2560, 1440, 1067, 940, 1415, 992, name="drop_rate_btn", hcenter=True)
164165
self.click_until(
165-
click_func=lambda: self.wait_click_box(
166-
lambda: self.find_start_btn(box=box), time_out=0.25
167-
),
168-
check_func=lambda: not self.find_start_btn(box=box),
166+
click_func=lambda: self.wait_click_box(lambda: self.find_start_btn(box=box), time_out=0.25),
167+
check_func=lambda: not self.find_drop_item(),
169168
time_out=action_timeout,
170169
)
171170

@@ -244,19 +243,26 @@ def use_skill(self, skill_time):
244243
return skill_time
245244

246245
def get_round_info(self):
246+
"""获取并更新当前轮次信息。"""
247247
if self.in_team():
248248
return
249-
self.sleep(0.5)
249+
250+
self.sleep(1)
250251
round_info_box = self.box_of_screen_scaled(2560, 1440, 531, 517, 618, 602, name="round_info", hcenter=True)
251252
texts = self.ocr(box=round_info_box)
252-
if texts:
253-
prev_round = self.current_round
254-
try:
255-
self.current_round = int(texts[0].name)
256-
except:
257-
return
258-
if prev_round != self.current_round:
259-
self.info_set("当前轮次", self.current_round)
253+
254+
prev_round = self.current_round
255+
new_round_from_ocr = None
256+
if texts and texts[0].name.isdigit():
257+
new_round_from_ocr = int(texts[0].name)
258+
259+
if new_round_from_ocr is not None:
260+
self.current_round = new_round_from_ocr
261+
elif self.current_round != -1: # OCR失败,但之前已有轮次记录,则递增
262+
self.current_round += 1
263+
264+
if prev_round != self.current_round:
265+
self.info_set("当前轮次", self.current_round)
260266

261267
def get_wave_info(self):
262268
if not self.in_team():

0 commit comments

Comments
 (0)