Skip to content

Commit bb6f6ae

Browse files
committed
优化五合一识别
1 parent 860ac91 commit bb6f6ae

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/task/FiveToOneTask.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class FiveToOneTask(BaseCombatTask):
1313

1414
def __init__(self, *args, **kwargs):
1515
super().__init__(*args, **kwargs)
16-
self.description = "游戏语言必须为简体中文,必须16:9分辨率,勾选需要的, 没勾的都会自动合成"
16+
self.description = "游戏语言必须为简体中文,必须16:9分辨率,使用1600x900以上分辨率, 勾选需要的, 没勾的都会自动合成"
1717
self.name = "数据坞五合一"
1818
self.default_config = {
1919
}
@@ -31,8 +31,9 @@ def __init__(self, *args, **kwargs):
3131
self.all_stats = []
3232
self.black_list = ["主属性生命值", "主属性攻击力", "主属性防御力"]
3333
for main_stat in self.main_stats:
34-
self.all_stats.append("主属性" + main_stat)
35-
self.all_stats += self.black_list
34+
self.all_stats.append(re.compile("主属性" + main_stat))
35+
for black in self.black_list:
36+
self.all_stats.append(re.compile(black))
3637

3738
self.add_text_fix(
3839
{'凝夜自霜': '凝夜白霜', '主属性灭伤害加成': '主属性湮灭伤害加成', "灭伤害加成": "主属性湮灭伤害加成",
@@ -82,15 +83,20 @@ def merge_set(self, name_box, set_name, step):
8283
self.wait_click_ocr(box=name_box, match=re.compile(set_name), raise_if_not_found=True,
8384
after_sleep=0.2)
8485
self.wait_feature("merge_echo_check", box=name_box, raise_if_not_found=True)
85-
8686
self.click_relative(0.895, 0.74, after_sleep=0.5) # 滚动
87-
choices = self.ocr(box=name_box, match=chinese_regex)
87+
choices = self.ocr(box=name_box, match=self.all_stats)
8888
if step == 1:
89+
if len(choices) != 16:
90+
raise Exception(f"属性列表识别失败! {choices}")
8991
for choice in choices:
90-
if choice.name not in self.all_stats:
91-
raise Exception(f"无法识别的属性: {choice.name}")
9292
in_keep = False
93-
if choice.name in self.black_list:
93+
in_black_list = False
94+
for black in self.black_list:
95+
if black in choice.name and "百分比" not in choice.name:
96+
in_black_list = True
97+
break
98+
if in_black_list:
99+
self.log_debug(f'跳过黑名单 {choice.name}')
94100
continue
95101
for keep in keeps:
96102
if keep in choice.name:

0 commit comments

Comments
 (0)