Skip to content

Commit

Permalink
完善自动地鬼,自动悬赏,自动结界
Browse files Browse the repository at this point in the history
  • Loading branch information
TanyaShue committed Oct 29, 2024
1 parent 2c27817 commit 757eed0
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 49 deletions.
2 changes: 1 addition & 1 deletion assets/config/maa_option.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"logging": true,
"recording": false,
"save_draw": false,
"save_draw": true,
"show_hit_draw": false,
"stdout_level": 2
}
4 changes: 2 additions & 2 deletions assets/config/programs.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"name": "悬赏预设分组",
"default": "默认分组",
"pipeline_override": {
"自动悬赏封印": {
"装备日常清杂预设": {
"custom_action_param": {
"group_name": "{value}"
}
Expand All @@ -103,7 +103,7 @@
"name": "悬赏预设队伍",
"default": "默认队伍",
"pipeline_override": {
"自动悬赏封印": {
"装备日常清杂预设": {
"custom_action_param": {
"team_name": "{value}"
}
Expand Down
16 changes: 8 additions & 8 deletions assets/config/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"adb_address": "127.0.0.1:5555"
},
"selected_tasks": [
"自动结界",
"打开游戏",
"自动悬赏",
"自动地鬼",
"领取奖励"
"自动结界",
"自动逢魔"
],
"option": {
"选择区服": {
Expand All @@ -37,7 +37,7 @@
"input": "日常"
},
"地鬼队伍预设": {
"input": "觉醒"
"input": "日常清杂"
},
"是否启动自动轮换": {
"boole": true
Expand All @@ -52,24 +52,24 @@
"adb_address": "127.0.0.1:5555"
},
"selected_tasks": [
"打开游戏",
"启动加速器",
"测试",
"自动悬赏",
"自动结界"
"自动悬赏"
],
"option": {
"选择区服": {
"select": "官服"
},
"悬赏封印分组预设": {
"input": "99"
"input": "日常"
},
"结界突破队伍预设": {
"input": "突破"
},
"结界突破分组预设": {
"input": "日常"
},
"悬赏封印队伍预设": {
"input": "觉醒"
}
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion assets/resource/base/pipeline/地鬼.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"自动地鬼": {
"next": ["点击地域鬼王"],
"interrupt": "点击探索"
"interrupt": "点击探索",
"on_error": "返回庭院"
},
"点击地域鬼王": {
"recognition": "TemplateMatch",
Expand Down
51 changes: 35 additions & 16 deletions assets/resource/base/pipeline/悬赏封印.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"recognition": "OCR",
"expected": "悬赏封印",
"action": "Click",
"next": "识别探索目标",
"next": ["识别未发现妖怪","识别探索目标"],
"interrupt": "悬赏_向上滑动一下",
"roi": [
2,
Expand All @@ -146,6 +146,23 @@
],
"post_delay": 1000
},
"识别未发现妖怪": {
"recognition": "OCR",
"expected": "线索",
"action": "Click",
"roi": [
520,292,124,40
],
"next": "悬赏封印_关闭线索界面"
},
"悬赏封印_关闭线索界面": {
"action": "Click",
"target": [
141,564,979,56
],
"next": "返回庭院",
"post_delay": 1000
},
"悬赏_向上滑动一下": {
"roi": [
535,
Expand Down Expand Up @@ -243,32 +260,34 @@
]
},
"探索_悬赏_自动挑战": {
"recognition": "FeatureMatch",
"recognition": "ColorMatch",
"action": "Click",
"template": "探索_自动挑战.png",
"index": -1,
"next": "探索_悬赏_识别章节开始界面",
"method": 40,
"lower": [[75, 0, 50]] ,
"upper": [[125, 100, 150]],
"count": 100,
"post_delay": 30000,
"timeout": 300000,
"roi": [
84,
617,
1107,
96
]
1037,642,64,53
],
"next": "探索_悬赏_识别章节开始界面"
},
"探索_悬赏_自动轮换": {
"recognition": "FeatureMatch",
"recognition": "ColorMatch",
"action": "Click",
"template": "探索_自动挑战.png",
"enabled": true,
"next": "探索_悬赏_自动挑战",
"method": 40,
"lower": [[75, 0, 50]] ,
"upper": [[125, 100, 150]],
"count": 100,
"roi": [
84,
617,
1107,
96
]
99,643,59,63
],
"next": "探索_悬赏_自动挑战",
"post_delay": 1000
},
"探索_悬赏_识别章节开始界面": {
"recognition": "OCR",
Expand Down
7 changes: 7 additions & 0 deletions config/maa_option.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"logging": true,
"recording": false,
"save_draw": false,
"show_hit_draw": false,
"stdout_level": 2
}
1 change: 0 additions & 1 deletion main_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging

import psutil
from flask import Flask, request, jsonify
from threading import Lock, Event
from typing import Dict
Expand Down
18 changes: 9 additions & 9 deletions src/core/tasker_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

import psutil

from custom_actions.auto_battle import AutoBattle
from custom_actions.challenge_dungeon_boss import ChallengeDungeonBoss
from custom_actions.human_touch import HumanTouch
from custom_actions.loop_action import LoopAction
from custom_actions.random_swipe import RandomSwipe
from custom_actions.random_touch import RandomTouch
from custom_actions.switch_soul import SwitchSoul
from custom_actions.task_list import TaskList
from custom_recognition.my_recognizer import MyRecognizer
from src.custom_actions.auto_battle import AutoBattle
from src.custom_actions.challenge_dungeon_boss import ChallengeDungeonBoss
from src.custom_actions.human_touch import HumanTouch
from src.custom_actions.loop_action import LoopAction
from src.custom_actions.random_swipe import RandomSwipe
from src.custom_actions.random_touch import RandomTouch
from src.custom_actions.switch_soul import SwitchSoul
from src.custom_actions.task_list import TaskList
from src.custom_recognition.my_recognizer import MyRecognizer
from src.utils.config_projects import Project, ProjectRunData
from maa.controller import AdbController
from maa.resource import Resource
Expand Down
2 changes: 1 addition & 1 deletion src/custom_actions/switch_soul.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def run(self,
# 点击预设点

print("开始执行自定义动作:装备切换御魂")

print(f"开始装备切换御魂,分组名称为:{json_data['group_name']},队伍名称为:{json_data['team_name']}")
context.run_pipeline("识别预设",{"识别预设":{"timeout":2000,"recognition": "OCR","expected": "预设","roi": [336, 74, 82, 46],"action":"Click"}})

for _ in range(1):
Expand Down
1 change: 1 addition & 0 deletions src/custom_actions/task_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def run(self, context: Context, argv: CustomAction.RunArg) -> bool:
for task in task_list:
print(f"执行任务: {task}")
context.run_pipeline(task)
print(f"任务 {task} 执行完成")

return True

Expand Down
21 changes: 11 additions & 10 deletions src/ui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def init_navigation_bar(self):
self.left_nav_layout.addWidget(refresh_button)

def refresh_resources(self):
_project=self.projects.projects[0]
_project = self.projects.projects[0]
"""刷新资源"""
try:
# 创建 TaskProjectManager 实例
Expand All @@ -127,7 +127,6 @@ def refresh_resources(self):

task_manager.create_tasker_process(_project)


# 发送任务到设备
print(f"发送任务 RELOAD_RESOURCES")
task_manager.send_task(_project, "RELOAD_RESOURCES")
Expand All @@ -137,7 +136,6 @@ def refresh_resources(self):
except Exception as e:
logging.error(f"发送任务 RELOAD_RESOURCES 失败: {e}")


def init_home_page(self):
"""初始化首页页面,包含四个垂直排列的部分"""
self.clear_right_layout()
Expand Down Expand Up @@ -284,7 +282,7 @@ def load_device_table(self):

button_task_connect = QPushButton('一键启动')
button_task_connect.setObjectName('runButton')
button_task_connect.clicked.connect(lambda _, p=project,bu=button_task_connect: self.run_task(p,bu))
button_task_connect.clicked.connect(lambda _, p=project, bu=button_task_connect: self.run_task(p, bu))
layout.addWidget(button_task_connect)

button_info = QPushButton('查看详情')
Expand Down Expand Up @@ -417,7 +415,8 @@ def on_checkbox_state_changed(state, task_name=task.task_name):

# 添加设置按钮
set_button = QPushButton('设置')
set_button.clicked.connect(lambda _, selected_t=task: self.set_task_parameters(selected_t, program,project))
set_button.clicked.connect(
lambda _, selected_t=task: self.set_task_parameters(selected_t, program, project))
task_row.addWidget(set_button)

# 添加发送任务按钮
Expand Down Expand Up @@ -530,7 +529,7 @@ def create_select_option(self, layout, project, project_option, sett, option_nam

# 获取默认选中值,优先从 project.option 获取
selected_value = project_option.option_value if project_option and project_option.option_type == 'select' else \
sett.select[0].name
sett.select[0].name

# 添加下拉选项并设置默认选中项
for select_option in sett.select:
Expand Down Expand Up @@ -582,7 +581,6 @@ def update_project_option(self, project, option_name, option_type, option_value)

self.projects.save_to_file(self.projects_json_path)


def clear_layout(self, layout):
"""清空布局中的所有小部件"""
for i in reversed(range(layout.count())):
Expand All @@ -602,6 +600,7 @@ def send_single_task(self, selected_task, project):
"""
发送单个任务到设备
"""

def on_task_sent():

try:
Expand All @@ -613,7 +612,8 @@ def on_task_sent():
project_run_data = project.get_project_all_run_data(self.programs)

# 过滤掉非选中的任务,只保留当前点击的任务
filtered_tasks = [task for task in project_run_data.project_run_tasks if task.task_name == selected_task.task_name]
filtered_tasks = [task for task in project_run_data.project_run_tasks if
task.task_name == selected_task.task_name]

if not filtered_tasks:
logging.error(f"任务 {selected_task.task_name} 不在选中任务中")
Expand All @@ -630,5 +630,6 @@ def on_task_sent():

except Exception as e:
logging.error(f"发送任务 {selected_task.task_name} 失败: {e}")
ta=TaskWorker(on_task_sent)
ta.run()

ta = TaskWorker(on_task_sent)
ta.run()

0 comments on commit 757eed0

Please sign in to comment.