Skip to content

Commit

Permalink
v7.15 事件选项分割-优化图片滤镜-修复onnx加载报错-增加周期演算模式
Browse files Browse the repository at this point in the history
  • Loading branch information
CHNZYX committed Jul 6, 2024
1 parent 0ffaf29 commit be40ae0
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 14 deletions.
4 changes: 2 additions & 2 deletions actions/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
{
Expand Down
20 changes: 13 additions & 7 deletions diver.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from collections import defaultdict

# 版本号
version = "v7.13"
version = "v7.15"


class DivergentUniverse(UniverseUtils):
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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<self.ty-20:
last_star = self.ty
if event_now is not None:
events.append(event_now)
event_now = {'raw_text': i['raw_text'][1:], 'box': i['box']}
event_now = {'raw_text': i['raw_text'].lstrip('米'), 'box': i['box']}
else:
if event_now is not None:
event_now['raw_text'] += i['raw_text']
Expand Down Expand Up @@ -772,10 +776,10 @@ def area(self):
keyops.keyUp('d')
self.portal_opening_days(static=1)
else:
self.portal_opening_days()
self.portal_opening_days(static=1)
else:
time.sleep(1)
self.portal_opening_days()
self.portal_opening_days(static=1)
elif area_now == '战斗':
if self.area_state == 0:
self.press('w', 3)
Expand Down Expand Up @@ -808,6 +812,8 @@ def area(self):
self.keys.fff = 0
self.portal_opening_days(static=1)
elif area_now == '位面':
pyautogui.click()
time.sleep(2)
self.close_and_exit()
else:
self.press('F4')
Expand Down
4 changes: 3 additions & 1 deletion info_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ config:
team: 终结技
# 速通模式
speed_mode: 0
# 周期演算
weekly_mode: 0
# 图像识别强制使用cpu
cpu_mode: 0
# 首领房间需要开秘技的角色,按顺序开
Expand All @@ -23,7 +25,7 @@ config:
- 阮梅
- 黄泉
# 自动存档数量,0-4,0代表不存档,1-4代表自动存档到前1-4个存档位
save: 4
save: 0
timezone: Default
max_run: 34
# 图像识别精度,默认1440,越高越精确,但是也越慢(最高1920)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pyuac
pillow
keyboard
requests
onnxruntime-directml
onnxruntime-directml==1.18.0
shapely
pyclipper
pyscreeze==0.1.28
Expand Down
3 changes: 3 additions & 0 deletions utils/diver/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(self):
self.long_press_sprint = 0
self.debug_mode = 0
self.speed_mode = 0
self.weekly_mode = 0
self.cpu_mode = 0
self.save_cnt = 4
self.accuracy = 1440
Expand Down Expand Up @@ -78,6 +79,7 @@ def read(self):
self.difficult = config['difficulty']
self.team = config['team']
self.speed_mode = config['speed_mode']
self.weekly_mode = config['weekly_mode']
self.cpu_mode = config['cpu_mode']
self.update_skill(config['skill'])
self.timezone = config['timezone']
Expand All @@ -104,6 +106,7 @@ def save(self):
"difficulty": self.diffi,
"team": self.team,
"speed_mode": self.speed_mode,
"weekly_mode": self.weekly_mode,
"cpu_mode": self.cpu_mode,
"skill": self.skill_char,
"save": self.save_cnt,
Expand Down
14 changes: 14 additions & 0 deletions utils/diver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,20 @@ def check(self, path, x, y, mask=None, threshold=None, large=True):
log.info("匹配到图片 %s 相似度 %f 阈值 %f" % (path, max_val, threshold))
self.last_info = path
return max_val > 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()
Expand Down
16 changes: 13 additions & 3 deletions utils/gui/config_diver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand All @@ -224,7 +234,7 @@ def getnum():
),
]
),
ft.Container(height=20),
ft.Container(height=5),
ft.Row(
[
txt,
Expand All @@ -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(
[
Expand Down

0 comments on commit be40ae0

Please sign in to comment.