From be40ae0ea79553a8b7d2128bb582feb95b56dbca Mon Sep 17 00:00:00 2001 From: ZYX_QZ Date: Sun, 7 Jul 2024 00:13:02 +0800 Subject: [PATCH] =?UTF-8?q?v7.15=20=E4=BA=8B=E4=BB=B6=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E5=88=86=E5=89=B2-=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=BB=A4=E9=95=9C-=E4=BF=AE=E5=A4=8Donnx=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E6=8A=A5=E9=94=99-=E5=A2=9E=E5=8A=A0=E5=91=A8=E6=9C=9F?= =?UTF-8?q?=E6=BC=94=E7=AE=97=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- actions/default.json | 4 ++-- diver.py | 20 +++++++++++++------- info_example.yml | 4 +++- requirements.txt | 2 +- utils/diver/config.py | 3 +++ utils/diver/utils.py | 14 ++++++++++++++ utils/gui/config_diver.py | 16 +++++++++++++--- 7 files changed, 49 insertions(+), 14 deletions(-) diff --git a/actions/default.json b/actions/default.json index c39fbeb..33e3a20 100644 --- a/actions/default.json +++ b/actions/default.json @@ -307,14 +307,14 @@ "name": "确认界面", "trigger":{ "text": "确认", - "box": [1152, 1205, 648, 678], + "box": [1111, 1225, 648, 678], "redundancy": 30 }, "actions": [ { "text": "确认", - "box": [1152, 1205, 648, 678], + "box": [1111, 1225, 648, 678], "redundancy": 30 }, { diff --git a/diver.py b/diver.py index ead4ffa..201697e 100644 --- a/diver.py +++ b/diver.py @@ -28,7 +28,7 @@ from collections import defaultdict # 版本号 -version = "v7.13" +version = "v7.15" class DivergentUniverse(UniverseUtils): @@ -59,6 +59,8 @@ def __init__(self, debug=0, nums=-1, speed=0): self.saved_num = 0 self.default_json_path = "actions/default.json" self.default_json = self.load_actions(self.default_json_path) + if config.weekly_mode: + self.default_json['模式选择'][0]['actions'][1]['text'] = '周期演算' if debug != 2: pyautogui.FAILSAFE = False self.update_count() @@ -353,7 +355,7 @@ def forward_until(self, text_list=[], timeout=5, moving=0): print(text_list) if self.check_f(is_in=text_list): self.press('f') - for _ in range(2): + for _ in range(1): self.press('s',0.2) self.press('f') return 1 @@ -439,7 +441,7 @@ def event_score(self, text, event): event_weight = [2*self.speed, 1, -10] for i in range(3): for e in event[i].split('-'): - if e in text: + if e in text and len(e): score += event_weight[i] return score @@ -479,11 +481,13 @@ def event(self): text = self.ts.find_with_box([1300, 1920, 100, 1080], redundancy=30) events = [] event_now = None + last_star = 0 for i in text: - if i['raw_text'].startswith('米'): + if self.check_box("star", [1250, 1460, i['box'][2]-30, i['box'][3]+30]) and last_star threshold + + def check_box(self, path, box=[0,1920,0,1080], threshold=0.96): + path = self.format_path(path) + target = cv.imread(path) + local_screen = self.screen[box[2]:box[3],box[0]:box[1]] + result = cv.matchTemplate(local_screen, target, cv.TM_CCORR_NORMED) + min_val, max_val, min_loc, max_loc = cv.minMaxLoc(result) + self.tx, self.ty = (max_loc[0]+box[0], max_loc[1]+box[2]) + self.tm = max_val + if max_val > threshold: + if self.last_info != path: + log.info("匹配到图片 %s 相似度 %f 阈值 %f" % (path, max_val, threshold)) + self.last_info = path + return max_val > threshold def get_end_point(self, mask=0): self.get_screen() diff --git a/utils/gui/config_diver.py b/utils/gui/config_diver.py index 74f0955..dd9e24d 100644 --- a/utils/gui/config_diver.py +++ b/utils/gui/config_diver.py @@ -23,6 +23,9 @@ def debug_checkbox_changed(_e): def speed_checkbox_changed(_e): config.speed_mode = not config.speed_mode + def weekly_checkbox_changed(_e): + config.weekly_mode = not config.weekly_mode + def cpu_checkbox_changed(_e): config.cpu_mode = not config.cpu_mode @@ -140,6 +143,13 @@ def getnum(): label_position='left', scale=1.2 ), + ft.Switch( + label="周期演算", + value=get_info_mode(config.weekly_mode), + on_change=weekly_checkbox_changed, + label_position='left', + scale=1.2 + ), ft.Switch( label="禁用GPU加速", value=get_info_mode(config.cpu_mode), @@ -214,7 +224,7 @@ def getnum(): ), ] ), - ft.Container(height=20), + ft.Container(height=15), ft.Row( [ ft.Text("秘技角色:",weight=ft.FontWeight.W_600,size=18), @@ -224,7 +234,7 @@ def getnum(): ), ] ), - ft.Container(height=20), + ft.Container(height=5), ft.Row( [ txt, @@ -246,7 +256,7 @@ def getnum(): ft.Text("次",weight=ft.FontWeight.W_400,size=18), ] ), - ft.Container(height=40), + ft.Container(height=20), ft.ElevatedButton( content=ft.Row( [