Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c8210c3b5 | ||
|
|
ad4125510b | ||
|
|
ffd87f2b11 | ||
|
|
dca422de8e | ||
|
|
2ea663b0ff | ||
|
|
bbf1be3de9 | ||
|
|
3586e37c69 | ||
|
|
4896d0344a | ||
|
|
c1d0a53110 | ||
|
|
0eedfb6969 | ||
|
|
d0c02717e8 | ||
|
|
2a53fb9742 | ||
|
|
bd8451a190 | ||
|
|
ee500b2971 | ||
|
|
b0a1715ba3 | ||
|
|
33760242ea | ||
|
|
7d91fba327 | ||
|
|
8956c306c2 | ||
|
|
a7dac95468 | ||
|
|
dea40ce177 | ||
|
|
410c3f2a92 | ||
|
|
30d11bed4c | ||
|
|
cfebcd0b8d | ||
|
|
43f2263cfa | ||
|
|
f9dd661c05 | ||
|
|
24128ee64b | ||
|
|
c8d10614c5 | ||
|
|
5c7e8e8f11 | ||
|
|
907fe5b3c2 | ||
|
|
4c81109f0d | ||
|
|
11102a4be2 | ||
|
|
c1c578d256 | ||
|
|
1690a727fc | ||
|
|
ee928a6847 | ||
|
|
4ad7db06ae | ||
|
|
8a6194f374 | ||
|
|
b1f1fe913a | ||
|
|
c8be442943 | ||
|
|
3d394475e1 | ||
|
|
da068549fe | ||
|
|
ca249206ae | ||
|
|
f80814952b | ||
|
|
38f41ac573 | ||
|
|
399b9d4adb | ||
|
|
091bbb2865 | ||
|
|
ec7b00e35e | ||
|
|
c5f7a68e79 | ||
|
|
e0c56a74ea | ||
|
|
3f1dc374eb | ||
|
|
eaa412d8c9 | ||
|
|
03a4102fe7 | ||
|
|
70c5a84bed | ||
|
|
147f466fb9 | ||
|
|
4cbdaa6ff8 | ||
|
|
8300d9dd7c | ||
|
|
5b2701a68f | ||
|
|
3d84638c55 | ||
|
|
7f6c3c408b | ||
|
|
fc7993afda | ||
|
|
040a5e8417 | ||
|
|
1c33bb9282 | ||
|
|
f923a8a4d2 | ||
|
|
f658bf85ee | ||
|
|
0d8de96e17 | ||
|
|
e9413f4214 | ||
|
|
aef3fa913b | ||
|
|
d55b1d867b | ||
|
|
311c8b2f37 | ||
|
|
1a478affb2 | ||
|
|
da6d956ef1 | ||
|
|
955d7d51d9 | ||
|
|
b4053e9357 | ||
|
|
a0d8133558 | ||
|
|
99f4f54ff7 | ||
|
|
c8a8d6217a | ||
|
|
cd978327fc | ||
|
|
b0b13cb36d | ||
|
|
beb36ff41a | ||
|
|
713589734b | ||
|
|
eedce17a9c | ||
|
|
4572b94122 | ||
|
|
5831e3671c | ||
|
|
e46076eaaa | ||
|
|
c553a49f18 | ||
|
|
53810d34b8 | ||
|
|
875434b492 | ||
|
|
565510ebe6 | ||
|
|
eec4518605 | ||
|
|
201cbf1629 | ||
|
|
33013fd7a5 | ||
|
|
f9b707b1ac | ||
|
|
68ebf2eb4b | ||
|
|
2c28cc2335 | ||
|
|
47a4983c16 | ||
|
|
c5a9427ca7 | ||
|
|
12e6296059 | ||
|
|
cf344b2d39 | ||
|
|
e958e24d4e | ||
|
|
26416b00b5 | ||
|
|
54301e1e02 | ||
|
|
1e9b72e547 | ||
|
|
d660f79b4c | ||
|
|
48bbad9853 | ||
|
|
5dcbd9b577 | ||
|
|
bb1f6d7281 | ||
|
|
d4ef75344e | ||
|
|
f614695a3a | ||
|
|
77306168f9 | ||
|
|
dee418cbe5 | ||
|
|
226785e8a4 | ||
|
|
5a5b77266e | ||
|
|
864efb42a3 | ||
|
|
32582e39a9 | ||
|
|
6bcb63e996 | ||
|
|
65b5032e6e | ||
|
|
b9e1c37b67 | ||
|
|
a5829ed6bb | ||
|
|
8b7d2353e5 | ||
|
|
c3b8c9e78f | ||
|
|
b49910873e | ||
|
|
ea6a9a4af2 | ||
|
|
a51213dceb | ||
|
|
e3c451cd92 | ||
|
|
e69283c3f2 | ||
|
|
23de87d1a6 | ||
|
|
dad2e8ef7d | ||
|
|
7e944e18fb | ||
|
|
f1154e6ef7 | ||
|
|
b2d5988d24 | ||
|
|
c2b68cfee9 | ||
|
|
6668a89fa7 | ||
|
|
01f1beba0b | ||
|
|
9e3c8920ba | ||
|
|
ce31169f66 | ||
|
|
53854e6d28 | ||
|
|
01c506fa13 | ||
|
|
95e0f01753 | ||
|
|
4aaca366f0 | ||
|
|
cac0dfc754 | ||
|
|
847bc8970e | ||
|
|
d4d99d34bc | ||
|
|
f86abe3ceb | ||
|
|
b1c6e9e4e3 | ||
|
|
d632bdd9fc | ||
|
|
fe61549c95 | ||
|
|
6832d0f8d8 | ||
|
|
a872dde7c8 | ||
|
|
12423edd6e | ||
|
|
9fe0209122 | ||
|
|
6e49368f0a | ||
|
|
f80939dad4 | ||
|
|
f7976b0bbd | ||
|
|
e9d11f7267 | ||
|
|
20fe152630 | ||
|
|
3c883fcf05 | ||
|
|
a4684ee6f7 | ||
|
|
edf0c695c6 | ||
|
|
12db6280b2 | ||
|
|
ffec4aadbe | ||
|
|
368ca18d9f | ||
|
|
891c695383 | ||
|
|
53051eff11 | ||
|
|
0797f20f26 | ||
|
|
77f8013bb0 | ||
|
|
df8e7288c1 | ||
|
|
e565f4b438 | ||
|
|
a8de2fb41a | ||
|
|
a0584f6fdc | ||
|
|
44459cbca7 | ||
|
|
c37ebae3bc | ||
|
|
2f7e64ac57 | ||
|
|
87c21f85bf | ||
|
|
7b7efdce80 | ||
|
|
536ed10dbf | ||
|
|
67ced40b6b | ||
|
|
b242d98208 | ||
|
|
28c50211a7 | ||
|
|
9f67726781 | ||
|
|
a2bd48a56f | ||
|
|
b9b251aa13 | ||
|
|
8ab64a70b5 | ||
|
|
c24329eca6 | ||
|
|
57421b9a45 | ||
|
|
efc66e6062 | ||
|
|
e8c067f7c0 | ||
|
|
292dc8fb4f | ||
|
|
0d466e5022 | ||
|
|
908294e2fe | ||
|
|
b3e2a08a6d | ||
|
|
c28aba2bab | ||
|
|
08583c776f | ||
|
|
e15a1d7276 | ||
|
|
f80afc0244 | ||
|
|
2caa6ee9f3 | ||
|
|
2f2311aa68 | ||
|
|
4f7afb6a34 | ||
|
|
2f3ca34704 | ||
|
|
ea1a30a685 | ||
|
|
b61ceae5ea | ||
|
|
bf3957d4e8 | ||
|
|
7c026fcf5f | ||
|
|
50055c3f26 | ||
|
|
6b2f2543c4 | ||
|
|
a24dd1c778 | ||
|
|
2ced2862b3 | ||
|
|
73422860af |
No files matched your search
@@ -1,22 +0,0 @@
|
||||
---
|
||||
name: Bug report / 错误报告
|
||||
about: Create a report to help us improve / 创建报告以帮助我们改进
|
||||
title: "[bug]请补充标题内容"
|
||||
labels: bug
|
||||
---
|
||||
|
||||
<!--
|
||||
请提供下述完整信息以便快速定位问题 / Please provide the following information to quickly locate the problem
|
||||
-->
|
||||
|
||||
- 系统环境 / System Environment:
|
||||
|
||||
|
||||
- BetterGI版本号 / BetterGI Version:
|
||||
|
||||
|
||||
- 问题描述 / Description of the issue:
|
||||
|
||||
|
||||
- 复现步骤 / Reproduction steps:
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
name: Bug report / 错误报告
|
||||
description: 提交可复现的问题,帮助我们定位错误 / Report a reproducible problem
|
||||
title: "[bug] "
|
||||
labels:
|
||||
- BUG
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 提交确认 / Checklist
|
||||
description: Checklist before submitting
|
||||
options:
|
||||
- label: 我已经搜索过现有 issue,确认这不是重复问题 / I have searched existing issues and confirmed this is not a duplicate
|
||||
required: true
|
||||
- label: "我已阅读过[文档](https://www.bettergi.com/doc.html),确认文档的内容无法解决我的问题 / I have read the [documentation](https://www.bettergi.com/doc.html) and confirmed it does not solve my problem"
|
||||
required: true
|
||||
- label: 我愿意为了解决这个问题尽自己所能 / I am willing to do my part to help resolve this issue
|
||||
- type: textarea
|
||||
id: environment
|
||||
attributes:
|
||||
label: 系统环境
|
||||
description: System environment,例如操作系统版本、运行时版本、显卡驱动版本
|
||||
placeholder: Windows 11 24H2 (26100.3775) / .NET Desktop Runtime 8.0.15 / NVIDIA 572.83
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: BetterGI 版本号
|
||||
description: BetterGI Version
|
||||
placeholder: e.g. 0.58.0
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 问题描述
|
||||
description: Describe the actual behavior and impact
|
||||
placeholder: 请描述实际出现的问题,以及这个问题对使用造成了什么影响 / Describe the actual behavior and impact
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: 期望结果
|
||||
description: Expected behavior
|
||||
placeholder: 请描述你期望出现的正确行为或结果 / Describe the expected behavior or result
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: steps
|
||||
attributes:
|
||||
label: 复现步骤
|
||||
description: Reproduction steps
|
||||
placeholder: |-
|
||||
1. 打开…… / Open ...
|
||||
2. 点击…… / Click ...
|
||||
3. 出现…… / Observe ...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: 日志与附件
|
||||
description: Logs and attachments,可直接拖拽上传日志文件、压缩包、截图或视频
|
||||
placeholder: |-
|
||||
可在这里补充日志和附件说明 / Add logs and attachment notes here:
|
||||
- 可直接粘贴关键日志片段 / Paste key log snippets directly
|
||||
- 可拖拽上传日志文件或压缩包 / Drag and drop log files or archives
|
||||
- 可拖拽上传截图、录屏或演示视频 / Drag and drop screenshots or videos
|
||||
- 若附件较多,请说明对应的时间点、任务名称或异常现象 / If there are many files, explain the relevant timestamps or symptoms
|
||||
- 提交前请注意移除账号、路径等隐私信息 / Remove private information before submitting
|
||||
validations:
|
||||
required: false
|
||||
@@ -1,9 +1,9 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 官方文档 / Document
|
||||
url: https://bgi.huiyadan.com/doc.html
|
||||
url: https://www.bettergi.com/doc.html
|
||||
about: 请在提出问题前阅读文档 / Read the document before submit the issue
|
||||
|
||||
- name: 常见问题 / FAQ
|
||||
url: https://bgi.huiyadan.com/faq.html
|
||||
url: https://www.bettergi.com/faq.html
|
||||
about: 常见的用户提出的问题 / Common questions asked by users
|
||||
@@ -1,9 +0,0 @@
|
||||
---
|
||||
name: I have feature requesting / 我有新功能请求
|
||||
about: Your request may come as a surprise. / 你的请求也许成为惊喜
|
||||
title: "[feature] "
|
||||
labels: feature 功能请求
|
||||
---
|
||||
|
||||
- Your feature requesting / 你的新功能请求
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
name: I have feature requesting / 我有功能需求
|
||||
description: 提出新的功能想法 / Share a feature request
|
||||
title: "[feature] "
|
||||
labels:
|
||||
- 功能建议
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 提交确认 / Checklist
|
||||
description: Please confirm the following before submitting
|
||||
options:
|
||||
- label: 我已经搜索过现有 issue,确认这不是重复建议 / I have searched existing issues and confirmed this is not a duplicate request
|
||||
required: true
|
||||
- label: 我已确认当前版本中尚未提供该功能,或至少没有等价实现 / I have confirmed this feature, or an equivalent one, is not already available in the current version
|
||||
required: true
|
||||
- label: 我认为这个需求能为更多用户带来明确收益,而不仅仅是个人偏好 / I believe this request provides clear value to a broader group of users, not just my personal preference
|
||||
required: true
|
||||
- label: 我理解这个需求可能因实现成本、维护成本或项目方向而暂不采纳 / I understand this request may not be accepted due to implementation cost, maintenance cost, or project direction
|
||||
required: true
|
||||
- type: textarea
|
||||
id: request
|
||||
attributes:
|
||||
label: 功能请求
|
||||
description: Feature Request
|
||||
placeholder: 请简要说明你希望新增什么能力 / Briefly describe the capability you want to add
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: scenario
|
||||
attributes:
|
||||
label: 使用场景
|
||||
description: Use Case
|
||||
placeholder: 这个功能要解决什么问题?在哪些场景下使用? / What problem does this feature solve, and when would it be used?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: impact
|
||||
attributes:
|
||||
label: 潜在影响
|
||||
description: Potential Impact
|
||||
placeholder: 请说明这个功能是否可能带来新的问题、维护成本、使用门槛或兼容性影响;如果没有,请填写“无” / Describe any potential downsides such as new issues, maintenance cost, usability barriers, or compatibility impact. Write "None" if there are no obvious downsides.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: extra
|
||||
attributes:
|
||||
label: 补充信息
|
||||
description: Optional
|
||||
placeholder: "可选,补充示意图、交互草图、参考链接或相关背景信息 / Optional: add mockups, interaction sketches, reference links, or other background information"
|
||||
validations:
|
||||
required: false
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
name: Feel free to express / 随便写写
|
||||
about: Record something / 简单写写记录记录
|
||||
---
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Feel free to express / 自由描述
|
||||
description: 记录你想反馈的内容 / Share general feedback
|
||||
title: "[feedback] "
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 提交确认 / Checklist
|
||||
description: Please confirm the following before submitting
|
||||
options:
|
||||
- label: 我已经搜索过现有 issue,确认这不是重复反馈 / I have searched existing issues and confirmed this is not duplicate feedback
|
||||
required: true
|
||||
- label: "我已阅读过[文档](https://www.bettergi.com/doc.html),确认文档的内容无法解决我的问题或覆盖我的反馈 / I have read the [documentation](https://www.bettergi.com/doc.html) and confirmed it does not solve my problem or cover my feedback"
|
||||
required: true
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 描述
|
||||
description: Description
|
||||
placeholder: 请描述你想反馈的内容 / Describe what you want to share
|
||||
validations:
|
||||
required: true
|
||||
@@ -1,9 +0,0 @@
|
||||
---
|
||||
name: I have a question / 我有疑问
|
||||
about: Solve your problem / 解决你的疑问
|
||||
title: "[question] "
|
||||
labels: question
|
||||
---
|
||||
|
||||
- Problem Description / 问题描述
|
||||
- 请尽量提供问题相关的截图/日志等内容
|
||||
@@ -0,0 +1,32 @@
|
||||
name: I have a question / 我有疑问
|
||||
description: 提交你的问题,我们会尽量帮助你解决 / Ask a question
|
||||
title: "[question] "
|
||||
labels:
|
||||
- 问题咨询
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 提交确认 / Checklist
|
||||
description: Please confirm the following before submitting
|
||||
options:
|
||||
- label: 我已经搜索过现有 issue,确认这不是重复问题 / I have searched existing issues and confirmed this is not a duplicate question
|
||||
required: true
|
||||
- label: "我已阅读过[文档](https://www.bettergi.com/doc.html),确认文档的内容无法解决我的问题 / I have read the [documentation](https://www.bettergi.com/doc.html) and confirmed it does not solve my problem"
|
||||
required: true
|
||||
- type: textarea
|
||||
id: question
|
||||
attributes:
|
||||
label: 问题描述
|
||||
description: Problem Description
|
||||
placeholder: 请清楚描述你的问题 / Clearly describe your question
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: tried
|
||||
attributes:
|
||||
label: 已尝试内容
|
||||
description: Screenshots / logs / what you already tried
|
||||
placeholder: 可附上截图、日志,以及你已经尝试过的排查过程 / Add screenshots, logs, and what you have already tried
|
||||
validations:
|
||||
required: true
|
||||
@@ -1,9 +0,0 @@
|
||||
---
|
||||
name: I have suggestions / 我有建议
|
||||
about: Your suggestions may benefit everyone / 你的建议可能让所有人受益
|
||||
title: "[suggestion] "
|
||||
labels: suggestion
|
||||
---
|
||||
|
||||
- Your suggestions / 你的建议
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
name: I have suggestions / 我有建议
|
||||
description: 分享对项目的改进建议 / Share an improvement suggestion
|
||||
title: "[suggestion] "
|
||||
labels:
|
||||
- 功能建议
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 提交确认 / Checklist
|
||||
description: Please confirm the following before submitting
|
||||
options:
|
||||
- label: 我已经搜索过现有 issue,确认这不是重复建议 / I have searched existing issues and confirmed this is not a duplicate suggestion
|
||||
required: true
|
||||
- label: "我已阅读过[文档](https://www.bettergi.com/doc.html),确认文档的内容无法解决我的问题或覆盖我的建议 / I have read the [documentation](https://www.bettergi.com/doc.html) and confirmed it does not solve my problem or cover my suggestion"
|
||||
required: true
|
||||
- type: textarea
|
||||
id: suggestion
|
||||
attributes:
|
||||
label: 建议内容
|
||||
description: Suggestion
|
||||
placeholder: 请描述你的建议内容 / Describe your suggestion
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: benefit
|
||||
attributes:
|
||||
label: 预期收益
|
||||
description: Expected Benefit
|
||||
placeholder: 这个建议会给用户或项目带来什么帮助? / What benefits would this suggestion bring to users or the project?
|
||||
validations:
|
||||
required: true
|
||||
@@ -0,0 +1,229 @@
|
||||
runtime:
|
||||
languageMode: auto
|
||||
dryRun: false
|
||||
|
||||
providers:
|
||||
openAiCompatible:
|
||||
enabled: true
|
||||
baseUrl: https://api.openai.com/v1
|
||||
model: gpt-5.4
|
||||
apiStyle: responses
|
||||
timeoutMs: 30000
|
||||
|
||||
issues:
|
||||
autoProcessing:
|
||||
skipCreatedBefore: auto
|
||||
validation:
|
||||
enabled: true
|
||||
fallbackTemplateKey: normal
|
||||
commentAnchor: issue-bot:validation
|
||||
templates:
|
||||
- key: bug
|
||||
detect:
|
||||
markers:
|
||||
- bug
|
||||
titlePrefixes:
|
||||
- "[bug]"
|
||||
requiredSections:
|
||||
- id: environment
|
||||
aliases:
|
||||
- 系统环境
|
||||
- System Environment
|
||||
- id: version
|
||||
aliases:
|
||||
- BetterGI 版本号
|
||||
- BetterGI Version
|
||||
- id: description
|
||||
aliases:
|
||||
- 问题描述
|
||||
- Description of the issue
|
||||
- id: steps
|
||||
aliases:
|
||||
- 复现步骤
|
||||
- Reproduction steps
|
||||
labels:
|
||||
whenValid:
|
||||
- BUG
|
||||
whenInvalid:
|
||||
- 需要更多信息
|
||||
- key: feature
|
||||
detect:
|
||||
markers:
|
||||
- feature
|
||||
titlePrefixes:
|
||||
- "[feature]"
|
||||
requiredSections:
|
||||
- id: request
|
||||
aliases:
|
||||
- 功能请求
|
||||
- Feature Request
|
||||
- id: scenario
|
||||
aliases:
|
||||
- 使用场景
|
||||
- Use Case
|
||||
labels:
|
||||
whenValid:
|
||||
- 功能建议
|
||||
whenInvalid:
|
||||
- 需要更多信息
|
||||
- key: suggestion
|
||||
detect:
|
||||
markers:
|
||||
- suggestion
|
||||
titlePrefixes:
|
||||
- "[suggestion]"
|
||||
requiredSections:
|
||||
- id: suggestion
|
||||
aliases:
|
||||
- 建议内容
|
||||
- Suggestion
|
||||
- id: benefit
|
||||
aliases:
|
||||
- 预期收益
|
||||
- Expected Benefit
|
||||
labels:
|
||||
whenValid:
|
||||
- 功能建议
|
||||
whenInvalid:
|
||||
- 需要更多信息
|
||||
- key: question
|
||||
detect:
|
||||
markers:
|
||||
- question
|
||||
titlePrefixes:
|
||||
- "[question]"
|
||||
requiredSections:
|
||||
- id: question
|
||||
aliases:
|
||||
- 问题描述
|
||||
- Problem Description
|
||||
- id: tried
|
||||
aliases:
|
||||
- 已尝试内容
|
||||
- What I Tried
|
||||
labels:
|
||||
whenValid:
|
||||
- 问题咨询
|
||||
whenInvalid:
|
||||
- 需要更多信息
|
||||
- key: normal
|
||||
detect:
|
||||
markers:
|
||||
- normal
|
||||
titlePrefixes:
|
||||
- "[feedback]"
|
||||
- "[normal]"
|
||||
requiredSections:
|
||||
- id: description
|
||||
aliases:
|
||||
- 描述
|
||||
- Description
|
||||
labels:
|
||||
whenValid: []
|
||||
whenInvalid:
|
||||
- 需要更多信息
|
||||
duplicateDetection:
|
||||
enabled: true
|
||||
bypassLabels:
|
||||
- 跳过重复检测
|
||||
duplicateLabel: 重复
|
||||
searchResultLimit: 50
|
||||
candidateLimit: 20
|
||||
aiReviewMaxCandidates: 3
|
||||
thresholds:
|
||||
exact: 0.995
|
||||
highConfidence: 0.93
|
||||
reviewMin: 0.82
|
||||
similarityComment:
|
||||
enabled: true
|
||||
commentAnchor: issue-bot:similar-issues
|
||||
minScore: 0.3
|
||||
maxCandidates: 3
|
||||
labeling:
|
||||
enabled: true
|
||||
autoCreateMissing: true
|
||||
managed:
|
||||
- BUG
|
||||
- 功能建议
|
||||
- 问题咨询
|
||||
- 需要更多信息
|
||||
- 重复
|
||||
definitions:
|
||||
BUG:
|
||||
color: d73a4a
|
||||
description: 程序存在缺陷或异常行为。
|
||||
功能建议:
|
||||
color: a2eeef
|
||||
description: 新功能建议或现有功能改进。
|
||||
问题咨询:
|
||||
color: d876e3
|
||||
description: 使用问题、求助或咨询。
|
||||
# 需要更多信息:
|
||||
# color: fbca04
|
||||
# description: 当前 Issue 缺少必要信息。
|
||||
重复:
|
||||
color: cfd3d7
|
||||
description: 已存在相同或高度相似的问题。
|
||||
keywordRules: []
|
||||
aiClassification:
|
||||
enabled: false
|
||||
maxLabels: 3
|
||||
minConfidence: 0.65
|
||||
include: []
|
||||
exclude:
|
||||
- BUG
|
||||
- 功能请求
|
||||
- 重复
|
||||
- 不会修复
|
||||
- 使用问题
|
||||
- 需要帮助
|
||||
- 已完成
|
||||
- 未解决
|
||||
- 待确认
|
||||
- P0
|
||||
- P1
|
||||
- 需要文档
|
||||
- 优化点
|
||||
- 急急急
|
||||
prompt: 优先给 BetterGI Issue 选择能反映具体功能模块、子系统或使用场景的标签,例如一条龙、调度器、脚本、设置项、地图追踪;避免只选择宽泛的流程或状态标签。
|
||||
sourceRepository:
|
||||
owner: babalae
|
||||
repo: better-genshin-impact
|
||||
aiHelp:
|
||||
enabled: true
|
||||
triggerLabels: []
|
||||
commentAnchor: issue-bot:ai
|
||||
projectContext:
|
||||
enabled: true
|
||||
includeRepositoryMetadata: true
|
||||
includeReadme: true
|
||||
readmeMaxChars: 3000
|
||||
profile:
|
||||
name: BetterGI
|
||||
aliases:
|
||||
- BGI
|
||||
- Better Genshin Impact
|
||||
summary: BetterGI is a desktop automation assistant for Genshin Impact.
|
||||
techStack:
|
||||
- C#
|
||||
- WPF
|
||||
- .NET
|
||||
commands:
|
||||
enabled: true
|
||||
mentions:
|
||||
- "@bot"
|
||||
- "@bettergi-repo-bot"
|
||||
access: collaborators
|
||||
fix:
|
||||
enabled: true
|
||||
commentAnchor: issue-bot:fix
|
||||
refresh:
|
||||
enabled: true
|
||||
|
||||
pullRequests:
|
||||
review:
|
||||
enabled: false
|
||||
labeling:
|
||||
enabled: false
|
||||
summary:
|
||||
enabled: false
|
||||
@@ -7,6 +7,7 @@ on:
|
||||
|
||||
jobs:
|
||||
mirrorchyan_release_note:
|
||||
if: github.repository_owner == 'babalae'
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
|
||||
@@ -7,6 +7,7 @@ on:
|
||||
|
||||
jobs:
|
||||
mirrorchyan:
|
||||
if: github.repository_owner == 'babalae'
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: 📥 Download release
|
||||
|
||||
@@ -74,7 +74,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: A-Little-AnQi/bettergi-script-web
|
||||
repository: zaodonganqi/bettergi-script-web
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
name: Repo Bot
|
||||
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- opened
|
||||
- edited
|
||||
- reopened
|
||||
- labeled
|
||||
issue_comment:
|
||||
types:
|
||||
- created
|
||||
- edited
|
||||
|
||||
jobs:
|
||||
repo-bot:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Detect GitHub App configuration
|
||||
id: auth-mode
|
||||
shell: bash
|
||||
env:
|
||||
REPO_BOT_GITHUB_APP_ID: ${{ vars.REPO_BOT_GITHUB_APP_ID }}
|
||||
REPO_BOT_GITHUB_APP_PRIVATE_KEY: ${{ secrets.REPO_BOT_GITHUB_APP_PRIVATE_KEY }}
|
||||
run: |
|
||||
if [ -n "$REPO_BOT_GITHUB_APP_ID" ] && [ -n "$REPO_BOT_GITHUB_APP_PRIVATE_KEY" ]; then
|
||||
echo "use_app=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "use_app=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Create GitHub App token
|
||||
if: ${{ steps.auth-mode.outputs.use_app == 'true' }}
|
||||
id: app-token
|
||||
uses: actions/create-github-app-token@v3
|
||||
with:
|
||||
app-id: ${{ vars.REPO_BOT_GITHUB_APP_ID }}
|
||||
private-key: ${{ secrets.REPO_BOT_GITHUB_APP_PRIVATE_KEY }}
|
||||
|
||||
- name: Run Repo Bot
|
||||
uses: ddaodan/bettergi-github-bot@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
REPO_BOT_GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
REPO_BOT_AI_API_KEY: ${{ secrets.REPO_BOT_AI_API_KEY }}
|
||||
REPO_BOT_AI_BASE_URL: ${{ vars.REPO_BOT_AI_BASE_URL }}
|
||||
with:
|
||||
config-path: .github/repo-bot.yml
|
||||
config-overrides-json: ${{ vars.REPO_BOT_CONFIG_OVERRIDES_JSON }}
|
||||
@@ -33,5 +33,6 @@ github_actions_cache/
|
||||
.trae
|
||||
.claude
|
||||
CLAUDE.md
|
||||
AGENTS.md
|
||||
|
||||
__pycache__/
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
<FontFamily x:Key="TextThemeFontFamily">/Resources/Fonts/MiSans-Regular.ttf#MiSans</FontFamily>
|
||||
<FontFamily x:Key="DigitalThemeFontFamily">/Resources/Fonts/deluge-led.ttf#Deluge LED</FontFamily>
|
||||
<bgivc:DomainNameToCascadingItemConverter x:Key="DomainNameConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
<bgivc:BooleanToVisibilityRevertConverter x:Key="BooleanToVisibilityRevertConverter" />
|
||||
<bgivc:BooleanToEnableTextConverter x:Key="BooleanToEnableTextConverter" />
|
||||
@@ -24,6 +25,9 @@
|
||||
<bgivc:NotNullConverter x:Key="NotNullConverter" />
|
||||
<bgivc:EnumToKVPConverter x:Key="EnumToKVPConverter" />
|
||||
<bgivc:CultureInfoNameToKVPConverter x:Key="CultureInfoNameToKVPConverter" />
|
||||
<bgivc:StringToColorConverter x:Key="StringToColorConverter" />
|
||||
<bgivc:TrConverter x:Key="TrConverter" />
|
||||
<bgivc:AdaptiveUniformGridColumnsConverter x:Key="AdaptiveUniformGridColumnsConverter" />
|
||||
<Style BasedOn="{StaticResource DefaultTextBoxStyle}" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="behavior:ClipboardInterceptor.EnableSafeClipboard" Value="True" />
|
||||
</Style>
|
||||
|
||||
@@ -52,8 +52,7 @@ public partial class App : Application
|
||||
.UseElevated()
|
||||
.UseSingleInstance("BetterGI")
|
||||
.ConfigureLogging(builder => { builder.ClearProviders(); })
|
||||
.ConfigureServices(
|
||||
(context, services) =>
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
// 提前初始化配置
|
||||
var configService = new ConfigService();
|
||||
@@ -74,7 +73,7 @@ public partial class App : Application
|
||||
rollingInterval: RollingInterval.Day,
|
||||
retainedFileCountLimit: 31,
|
||||
retainedFileTimeLimit: TimeSpan.FromDays(21))
|
||||
.WriteTo.Console(outputTemplate:
|
||||
.WriteTo.Console(outputTemplate:
|
||||
"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")
|
||||
.MinimumLevel.Debug()
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
|
||||
@@ -86,7 +85,25 @@ public partial class App : Application
|
||||
}
|
||||
|
||||
Log.Logger = loggerConfiguration.CreateLogger();
|
||||
services.AddSingleton<IMissingTranslationReporter, SupabaseMissingTranslationReporter>();
|
||||
services.AddSingleton<ITranslationService, JsonTranslationService>();
|
||||
|
||||
services.AddLogging(c => c.AddSerilog());
|
||||
// if ("zh-Hans".Equals(all.OtherConfig.UiCultureInfoName, StringComparison.OrdinalIgnoreCase))
|
||||
// {
|
||||
// services.AddLogging(c => c.AddSerilog());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// services.AddLogging(logging =>
|
||||
// {
|
||||
// logging.ClearProviders();
|
||||
// logging.SetMinimumLevel(LogLevel.Debug);
|
||||
// logging.AddFilter("Microsoft", LogLevel.Warning);
|
||||
// logging.AddFilter("Microsoft.Hosting.Lifetime", LogLevel.Warning);
|
||||
// logging.Services.AddSingleton<ILoggerProvider, TranslatingSerilogLoggerProvider>();
|
||||
// });
|
||||
// }
|
||||
|
||||
services.AddLocalization();
|
||||
|
||||
@@ -147,14 +164,15 @@ public partial class App : Application
|
||||
services.AddSingleton<MemoryFileCache>();
|
||||
services.AddSingleton<IMihoyoMapApiService, MihoyoMapApiService>();
|
||||
services.AddSingleton<IKongyingTavernApiService, KongyingTavernApiService>();
|
||||
services.AddSingleton<IHoYoLabMapApiService, HoYoLabMapApiService>();
|
||||
services.AddSingleton<IMaskMapPointService, MaskMapPointService>();
|
||||
|
||||
|
||||
services.AddSingleton(TimeProvider.System);
|
||||
services.AddSingleton<IServerTimeProvider, ServerTimeProvider>();
|
||||
|
||||
// Configuration
|
||||
//services.Configure<AppConfig>(context.Configuration.GetSection(nameof(AppConfig)));
|
||||
|
||||
|
||||
I18N.Culture = new CultureInfo("zh-Hans"); // #1846
|
||||
}
|
||||
)
|
||||
@@ -207,10 +225,19 @@ public partial class App : Application
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// DEBUG only, no overhead
|
||||
Debug.WriteLine(ex);
|
||||
ConsoleHelper.WriteError($"应用程序启动失败: {ex.Message}");
|
||||
|
||||
try
|
||||
{
|
||||
HandleException(ex);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
Debug.WriteLine(ex2);
|
||||
ConsoleHelper.WriteError($"应用程序启动失败打印日志时又失败了: {ex2.Message}");
|
||||
}
|
||||
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
Debugger.Break();
|
||||
@@ -226,12 +253,12 @@ public partial class App : Application
|
||||
base.OnExit(e);
|
||||
|
||||
ConsoleHelper.WriteLine("BetterGI 应用程序正在关闭...");
|
||||
|
||||
|
||||
TempManager.CleanUp();
|
||||
|
||||
await _host.StopAsync();
|
||||
_host.Dispose();
|
||||
|
||||
|
||||
// 释放控制台窗口
|
||||
ConsoleHelper.FreeConsoleWindow();
|
||||
}
|
||||
@@ -333,4 +360,4 @@ public partial class App : Application
|
||||
// log
|
||||
GetLogger<App>().LogDebug(e, "UnHandle Exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyName>BetterGI</AssemblyName>
|
||||
<Version>0.56.2</Version>
|
||||
<Version>0.60.2-alpha.1</Version>
|
||||
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
||||
@@ -43,9 +43,9 @@
|
||||
|
||||
|
||||
<PackageReference Include="BetterGI.VCRuntime" Version="14.44.35208" />
|
||||
<PackageReference Include="BetterGI.Assets.Map" Version="1.0.17" />
|
||||
<PackageReference Include="BetterGI.Assets.Model" Version="1.0.18" />
|
||||
<PackageReference Include="BetterGI.Assets.Other" Version="1.0.12" />
|
||||
<PackageReference Include="BetterGI.Assets.Map" Version="1.0.18" />
|
||||
<PackageReference Include="BetterGI.Assets.Model" Version="1.0.20" />
|
||||
<PackageReference Include="BetterGI.Assets.Other" Version="1.0.15" />
|
||||
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="DeviceId" Version="6.9.0" />
|
||||
@@ -67,7 +67,7 @@
|
||||
<PackageReference Include="Microsoft.ML.OnnxRuntime.Managed" Version="1.21.0" />
|
||||
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
|
||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2592.51" />
|
||||
<PackageReference Include="MimeKit" Version="4.14.0" />
|
||||
<PackageReference Include="MimeKit" Version="4.15.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
|
||||
<PackageReference Include="OpenCvSharp4.WpfExtensions" Version="4.11.0.20250507" />
|
||||
@@ -84,6 +84,7 @@
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.RichTextBoxEx.Wpf" Version="1.1.0.1" />
|
||||
<!-- <PackageReference Include="supabase-csharp" Version="0.16.2" />-->
|
||||
<PackageReference Include="System.Drawing.Common" Version="10.0.0" />
|
||||
<PackageReference Include="System.IO.Hashing" Version="9.0.4" />
|
||||
<PackageReference Include="TorchSharp" Version="0.105.0" />
|
||||
@@ -94,7 +95,7 @@
|
||||
<PackageReference Include="WPF-UI" Version="4.2.0" />
|
||||
<PackageReference Include="WPF-UI.DependencyInjection" Version="4.2.0" />
|
||||
<PackageReference Include="WPF-UI.Tray" Version="4.2.0" />
|
||||
<PackageReference Include="WPF-UI.Violeta" Version="4.2.0.1" />
|
||||
<PackageReference Include="WPF-UI.Violeta" Version="4.2.0.10" />
|
||||
<PackageReference Include="gong-wpf-dragdrop" Version="3.2.1" />
|
||||
<PackageReference Include="YamlDotNet" Version="16.3.0" />
|
||||
<PackageReference Include="YoloSharp" Version="6.0.3" />
|
||||
@@ -128,6 +129,9 @@
|
||||
<None Update="GameTask\AutoFishing\Assets\1920x1080\**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\AutoLeyLineOutcrop\Assets\**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\LogParse\Assets\**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
@@ -194,6 +198,12 @@
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\in_domain.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\AutoDomain\Assets\1920x1080\**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="User\I18n\en.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.AutoCook;
|
||||
using BetterGenshinImpact.GameTask.AutoDomain;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.GameTask.AutoFishing;
|
||||
@@ -22,7 +21,10 @@ using BetterGenshinImpact.GameTask.AutoArtifactSalvage;
|
||||
using BetterGenshinImpact.GameTask.AutoStygianOnslaught;
|
||||
using BetterGenshinImpact.GameTask.GetGridIcons;
|
||||
using BetterGenshinImpact.GameTask.AutoEat;
|
||||
using BetterGenshinImpact.GameTask.AutoLeyLineOutcrop;
|
||||
using BetterGenshinImpact.GameTask.AutoCook;
|
||||
using BetterGenshinImpact.GameTask.MapMask;
|
||||
using BetterGenshinImpact.GameTask.SkillCd;
|
||||
using BetterGenshinImpact.GameTask.UseRedeemCode;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Config;
|
||||
@@ -127,11 +129,6 @@ public partial class AllConfig : ObservableObject
|
||||
/// </summary>
|
||||
public QuickTeleportConfig QuickTeleportConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 自动烹饪配置
|
||||
/// </summary>
|
||||
public AutoCookConfig AutoCookConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 自动打牌配置
|
||||
/// </summary>
|
||||
@@ -172,12 +169,24 @@ public partial class AllConfig : ObservableObject
|
||||
/// 自动吃药配置
|
||||
/// </summary>
|
||||
public AutoEatConfig AutoEatConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 自动地脉花配置
|
||||
/// </summary>
|
||||
public AutoLeyLineOutcropConfig AutoLeyLineOutcropConfig { get; set; } = new();
|
||||
|
||||
public AutoCookConfig AutoCookConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 地图遮罩
|
||||
/// </summary>
|
||||
public MapMaskConfig MapMaskConfig { get; set; } = new();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 技能 CD 提示
|
||||
/// </summary>
|
||||
public SkillCdConfig SkillCdConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 自动使用
|
||||
/// </summary>
|
||||
@@ -257,7 +266,6 @@ public partial class AllConfig : ObservableObject
|
||||
AutoSkipConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoFishingConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
QuickTeleportConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoCookConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
MacroConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
HotKeyConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoWoodConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
@@ -267,6 +275,8 @@ public partial class AllConfig : ObservableObject
|
||||
AutoArtifactSalvageConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoRedeemCodeConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoEatConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoLeyLineOutcropConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoCookConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
MapMaskConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoMusicGameConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
TpConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
@@ -274,6 +284,7 @@ public partial class AllConfig : ObservableObject
|
||||
PathingConditionConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
DevConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
HardwareAccelerationConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
SkillCdConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
}
|
||||
|
||||
public void OnAnyPropertyChanged(object? sender, EventArgs args)
|
||||
@@ -286,4 +297,4 @@ public partial class AllConfig : ObservableObject
|
||||
{
|
||||
NotificationService.Instance().RefreshNotifiers();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,10 @@ public partial class HardwareAccelerationConfig : ObservableObject
|
||||
private InferenceDeviceType _inferenceDevice = InferenceDeviceType.Cpu;
|
||||
|
||||
/// <summary>
|
||||
/// 是否强制OCR使用CPU推理。在某些环境上使用GPU进行OCR推理会导致性能下降(比如很多使用DirectML推理的情况下)。默认关闭。
|
||||
/// 是否强制OCR使用CPU推理。在某些环境上使用GPU进行OCR推理会导致性能下降(比如很多使用DirectML推理的情况下)。默认开启。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _cpuOcr = false;
|
||||
private bool _cpuOcr = true;
|
||||
|
||||
#region 一般GPU加速设置
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using BetterGenshinImpact.Model;
|
||||
using BetterGenshinImpact.Model;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
|
||||
@@ -100,6 +100,13 @@ public partial class HotKeyConfig : ObservableObject
|
||||
|
||||
[ObservableProperty]
|
||||
private string _quickTeleportTickHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 技能CD提示开关
|
||||
[ObservableProperty]
|
||||
private string _skillCdEnabledHotkey = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _skillCdEnabledHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 截图
|
||||
[ObservableProperty]
|
||||
@@ -156,6 +163,13 @@ public partial class HotKeyConfig : ObservableObject
|
||||
[ObservableProperty]
|
||||
private string _autoFishingGameHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 自动烹饪开始/停止
|
||||
[ObservableProperty]
|
||||
private string _autoCookGameHotkey = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _autoCookGameHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 自动寻路
|
||||
[ObservableProperty]
|
||||
private string _autoTrackPathHotkey = "";
|
||||
@@ -237,4 +251,11 @@ public partial class HotKeyConfig : ObservableObject
|
||||
|
||||
[ObservableProperty]
|
||||
private string _onedragonHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 地图遮罩开关
|
||||
[ObservableProperty]
|
||||
private string _mapMaskEnabledHotkey = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _mapMaskEnabledHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
}
|
||||
@@ -63,13 +63,6 @@ public partial class MaskWindowConfig : ObservableObject
|
||||
[ObservableProperty]
|
||||
private bool _showFps = false;
|
||||
|
||||
/// <summary>
|
||||
/// 作为原神子窗体
|
||||
/// 有些bug没解决
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _useSubform = false;
|
||||
|
||||
/// <summary>
|
||||
/// 遮罩文本透明度 (0.0-1.0)
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.AutoLeyLineOutcrop;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
@@ -61,6 +62,87 @@ public partial class OneDragonFlowConfig : ObservableObject
|
||||
[ObservableProperty]
|
||||
private List<string> _secretTreasureObjects = new();
|
||||
|
||||
// 地脉花一条龙模式(跳过部分准备流程)
|
||||
[ObservableProperty]
|
||||
private bool _leyLineOneDragonMode = false;
|
||||
|
||||
// 地脉花运行日期设置
|
||||
[ObservableProperty]
|
||||
private bool _leyLineRunMonday = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _leyLineRunTuesday = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _leyLineRunWednesday = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _leyLineRunThursday = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _leyLineRunFriday = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _leyLineRunSaturday = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _leyLineRunSunday = true;
|
||||
|
||||
// 地脉花每日类型与国家配置(为空则使用独立任务配置)
|
||||
[ObservableProperty]
|
||||
private string _leyLineMondayType = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineMondayCountry = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineTuesdayType = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineTuesdayCountry = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineWednesdayType = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineWednesdayCountry = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineThursdayType = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineThursdayCountry = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineFridayType = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineFridayCountry = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineSaturdayType = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineSaturdayCountry = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineSundayType = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _leyLineSundayCountry = string.Empty;
|
||||
|
||||
// 地脉花刷取次数(0 表示使用独立任务配置)
|
||||
[ObservableProperty]
|
||||
private int _leyLineRunCount = 0;
|
||||
|
||||
// 地脉花树脂耗尽模式
|
||||
[ObservableProperty]
|
||||
private bool _leyLineResinExhaustionMode = false;
|
||||
|
||||
// 地脉花刷取次数取小值(仅耗尽模式生效)
|
||||
[ObservableProperty]
|
||||
private bool _leyLineOpenModeCountMin = false;
|
||||
|
||||
#region 每周秘境配置
|
||||
|
||||
//周一
|
||||
@@ -142,5 +224,62 @@ public partial class OneDragonFlowConfig : ObservableObject
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShouldRunLeyLineToday()
|
||||
{
|
||||
if (!LeyLineRunMonday
|
||||
&& !LeyLineRunTuesday
|
||||
&& !LeyLineRunWednesday
|
||||
&& !LeyLineRunThursday
|
||||
&& !LeyLineRunFriday
|
||||
&& !LeyLineRunSaturday
|
||||
&& !LeyLineRunSunday)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var serverTime = ServerTimeHelper.GetServerTimeNow();
|
||||
var dayOfWeek = (serverTime.Hour >= 4 ? serverTime : serverTime.AddDays(-1)).DayOfWeek;
|
||||
return dayOfWeek switch
|
||||
{
|
||||
DayOfWeek.Monday => LeyLineRunMonday,
|
||||
DayOfWeek.Tuesday => LeyLineRunTuesday,
|
||||
DayOfWeek.Wednesday => LeyLineRunWednesday,
|
||||
DayOfWeek.Thursday => LeyLineRunThursday,
|
||||
DayOfWeek.Friday => LeyLineRunFriday,
|
||||
DayOfWeek.Saturday => LeyLineRunSaturday,
|
||||
DayOfWeek.Sunday => LeyLineRunSunday,
|
||||
_ => true
|
||||
};
|
||||
}
|
||||
|
||||
public (string type, string country) GetLeyLineConfigForToday(AutoLeyLineOutcropConfig fallback)
|
||||
{
|
||||
var serverTime = ServerTimeHelper.GetServerTimeNow();
|
||||
var dayOfWeek = (serverTime.Hour >= 4 ? serverTime : serverTime.AddDays(-1)).DayOfWeek;
|
||||
var (type, country) = dayOfWeek switch
|
||||
{
|
||||
DayOfWeek.Monday => (LeyLineMondayType, LeyLineMondayCountry),
|
||||
DayOfWeek.Tuesday => (LeyLineTuesdayType, LeyLineTuesdayCountry),
|
||||
DayOfWeek.Wednesday => (LeyLineWednesdayType, LeyLineWednesdayCountry),
|
||||
DayOfWeek.Thursday => (LeyLineThursdayType, LeyLineThursdayCountry),
|
||||
DayOfWeek.Friday => (LeyLineFridayType, LeyLineFridayCountry),
|
||||
DayOfWeek.Saturday => (LeyLineSaturdayType, LeyLineSaturdayCountry),
|
||||
DayOfWeek.Sunday => (LeyLineSundayType, LeyLineSundayCountry),
|
||||
_ => (string.Empty, string.Empty)
|
||||
};
|
||||
|
||||
if (string.IsNullOrWhiteSpace(type))
|
||||
{
|
||||
type = fallback.LeyLineOutcropType;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(country))
|
||||
{
|
||||
country = fallback.Country;
|
||||
}
|
||||
|
||||
return (type, country);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.Model;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
@@ -121,4 +121,4 @@ public partial class OtherConfig : ObservableObject
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _uiCultureInfoName = "zh-Hans";
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,9 @@ public partial class PathingPartyConfig : ObservableObject
|
||||
// 切换到队伍的名称
|
||||
[ObservableProperty]
|
||||
private string _partyName = string.Empty;
|
||||
|
||||
[JsonIgnore]
|
||||
public bool SkipPartySwitch { get; set; }
|
||||
|
||||
// 切换队伍前是否前往须弥七天神像
|
||||
[ObservableProperty]
|
||||
|
||||
@@ -50,4 +50,10 @@ public partial class ScriptConfig : ObservableObject
|
||||
|
||||
// 仓库新手教程是否已阅读
|
||||
[ObservableProperty] private bool _guideStatus = false;
|
||||
|
||||
// 是否在启动时自动更新已订阅的脚本
|
||||
[ObservableProperty] private bool _autoUpdateSubscribedScripts = false;
|
||||
|
||||
// 命令行启动时是否先自动更新已订阅脚本再执行命令
|
||||
[ObservableProperty] private bool _autoUpdateBeforeCommandLineRun = false;
|
||||
}
|
||||
@@ -102,6 +102,11 @@ public partial class MouseKeyMonitor
|
||||
// Debug.WriteLine("KeyDown: \t{0}", e.KeyCode);
|
||||
GlobalKeyMouseRecord.Instance.GlobalHookKeyDown(e, Kernel32.GetTickCount());
|
||||
|
||||
if (SystemControl.IsGenshinImpactActive())
|
||||
{
|
||||
ChatUiHotkeyGuard.PrimeFromChatKey(e.KeyCode);
|
||||
}
|
||||
|
||||
// 热键按下事件
|
||||
HotKeyDown(sender, e);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Linq;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR.Engine;
|
||||
using BetterGenshinImpact.Core.Recognition.ONNX;
|
||||
using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using OpenCvSharp;
|
||||
using OpenCvSharp.Extensions;
|
||||
using YamlDotNet.Core;
|
||||
@@ -246,7 +247,7 @@ public class PaddleOcrService : IOcrService, IDisposable
|
||||
_localRecModel = modelsRec;
|
||||
|
||||
// 预热模型
|
||||
using var preHeatImageMat = Cv2.ImRead(modelType.PreHeatImagePath) ??
|
||||
using var preHeatImageMat = Bv.ImRead(modelType.PreHeatImagePath) ??
|
||||
throw new FileNotFoundException($"预热图片未找到: {modelType.PreHeatImagePath}");
|
||||
// Debug输出结果
|
||||
var preHeatResult = RunAll(preHeatImageMat, 1);
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR.Engine;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR.Engine.data;
|
||||
@@ -95,21 +94,33 @@ public class Rec(
|
||||
// .AsParallel()
|
||||
.Select(src =>
|
||||
{
|
||||
using var channel3 = src.Channels() switch
|
||||
Mat? channel3 = default;
|
||||
try
|
||||
{
|
||||
4 => src.CvtColor(ColorConversionCodes.BGRA2BGR),
|
||||
1 => src.CvtColor(ColorConversionCodes.GRAY2BGR),
|
||||
3 => src,
|
||||
var x => throw new Exception($"Unexpect src channel: {x}, allow: (1/3/4)")
|
||||
};
|
||||
var result = OcrUtils.ResizeNormImg(channel3, new OcrShape(3, maxWidth, modelHeight),
|
||||
out var owner);
|
||||
lock (owners)
|
||||
{
|
||||
owners.Add(owner);
|
||||
}
|
||||
channel3 = src.Channels() switch
|
||||
{
|
||||
4 => src.CvtColor(ColorConversionCodes.BGRA2BGR),
|
||||
1 => src.CvtColor(ColorConversionCodes.GRAY2BGR),
|
||||
3 => src,
|
||||
var x => throw new Exception($"Unexpect src channel: {x}, allow: (1/3/4)")
|
||||
};
|
||||
var result = OcrUtils.ResizeNormImg(channel3, new OcrShape(3, maxWidth, modelHeight),
|
||||
out var owner);
|
||||
lock (owners)
|
||||
{
|
||||
owners.Add(owner);
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Only dispose Mats created in this scope
|
||||
if (channel3 != null && !ReferenceEquals(channel3, src))
|
||||
{
|
||||
channel3.Dispose();
|
||||
}
|
||||
}
|
||||
})
|
||||
.Select(inputTensor =>
|
||||
{
|
||||
@@ -141,46 +152,46 @@ public class Rec(
|
||||
{
|
||||
var resultArray = resultTensor.Item2;
|
||||
var resultShape = resultTensor.Item1;
|
||||
GCHandle dataHandle = default;
|
||||
try
|
||||
{
|
||||
dataHandle = GCHandle.Alloc(resultArray, GCHandleType.Pinned);
|
||||
var dataPtr = dataHandle.AddrOfPinnedObject();
|
||||
var labelCount = resultShape[2];
|
||||
var charCount = resultShape[1];
|
||||
var labelCount = resultShape[2];
|
||||
var charCount = resultShape[1];
|
||||
|
||||
return Enumerable.Range(0, resultShape[0])
|
||||
.Select(i =>
|
||||
return Enumerable.Range(0, resultShape[0])
|
||||
.Select(i =>
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
var lastIndex = 0;
|
||||
float score = 0;
|
||||
var batchOffset = i * charCount * labelCount;
|
||||
for (var n = 0; n < charCount; ++n)
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
var lastIndex = 0;
|
||||
float score = 0;
|
||||
for (var n = 0; n < charCount; ++n)
|
||||
var rowOffset = batchOffset + n * labelCount;
|
||||
var maxVal = float.MinValue;
|
||||
var maxIndex = 0;
|
||||
for (var c = 0; c < labelCount; c++)
|
||||
{
|
||||
using var mat = Mat.FromPixelData(1, labelCount, MatType.CV_32FC1,
|
||||
dataPtr + (n + i * charCount) * labelCount * sizeof(float));
|
||||
var maxIdx = new int[2];
|
||||
mat.MinMaxIdx(out _, out var maxVal, [], maxIdx);
|
||||
|
||||
if (maxIdx[1] > 0 && !(n > 0 && maxIdx[1] == lastIndex))
|
||||
var value = resultArray[rowOffset + c];
|
||||
if (value > maxVal)
|
||||
{
|
||||
score += (float)maxVal;
|
||||
sb.Append(OcrUtils.GetLabelByIndex(maxIdx[1], labels));
|
||||
maxVal = value;
|
||||
maxIndex = c;
|
||||
}
|
||||
|
||||
lastIndex = maxIdx[1];
|
||||
}
|
||||
|
||||
return new OcrRecognizerResult(sb.ToString(), score / sb.Length);
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
finally
|
||||
{
|
||||
dataHandle.Free();
|
||||
}
|
||||
if (maxIndex > 0 && !(n > 0 && maxIndex == lastIndex))
|
||||
{
|
||||
score += maxVal;
|
||||
sb.Append(OcrUtils.GetLabelByIndex(maxIndex, labels));
|
||||
}
|
||||
|
||||
lastIndex = maxIndex;
|
||||
}
|
||||
|
||||
var text = sb.ToString();
|
||||
return new OcrRecognizerResult(text, text.Length > 0 ? score / text.Length : 0);
|
||||
})
|
||||
.ToArray();
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
public string GetConfigName => config.Name;
|
||||
}
|
||||
}
|
||||
@@ -311,6 +311,17 @@ public class BgiOnnxFactory
|
||||
: new BgiYoloPredictor(model, cached, CreateSessionOptions(model, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据模型创建一个 RedNet 分类预测器
|
||||
/// </summary>
|
||||
/// <param name="model">模型</param>
|
||||
/// <param name="labelRelativePath">标签文件相对路径,可选,支持 .txt/.json</param>
|
||||
/// <returns>BgiRedNetPredictor</returns>
|
||||
public BgiRedNetPredictor CreateRedNetPredictor(BgiOnnxModel model, string? labelRelativePath = null)
|
||||
{
|
||||
return new BgiRedNetPredictor(model, CreateInferenceSession(model), labelRelativePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据模型创建一个onnx运行时的InferenceSession
|
||||
/// </summary>
|
||||
@@ -407,11 +418,11 @@ public class BgiOnnxFactory
|
||||
break;
|
||||
case ProviderType.Cpu:
|
||||
sessionOptions.AppendExecutionProvider_CPU();
|
||||
if (model.Name.Contains("PpOcr") || model.Name.Contains("Yap"))
|
||||
{
|
||||
sessionOptions.IntraOpNumThreads = 2; // 限制算子内部并行线程数
|
||||
sessionOptions.InterOpNumThreads = 1; // 限制算子间并行线程数(顺序执行)
|
||||
}
|
||||
// if (model.Name.Contains("PpOcr") || model.Name.Contains("Yap"))
|
||||
// {
|
||||
// sessionOptions.IntraOpNumThreads = 2; // 限制算子内部并行线程数
|
||||
// sessionOptions.InterOpNumThreads = 1; // 限制算子间并行线程数(顺序执行)
|
||||
// }
|
||||
break;
|
||||
case ProviderType.Dnnl:
|
||||
sessionOptions.AppendExecutionProvider_Dnnl();
|
||||
@@ -582,4 +593,4 @@ public class BgiOnnxFactory
|
||||
result["enable_opencl_throttling"] = "true";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,12 @@ public class BgiOnnxModel
|
||||
public static readonly BgiOnnxModel BgiAvatarSide =
|
||||
Register("BgiAvatarSide", @"Assets\Model\Common\avatar_side_classify_sim.onnx");
|
||||
|
||||
/// <summary>
|
||||
/// 角色识别(RedNet-110)
|
||||
/// </summary>
|
||||
public static readonly BgiOnnxModel BgiPickRedNet110 =
|
||||
Register("BgiPickRedNet110", @"Assets\Model\Common\resnet_pick.onnx");
|
||||
|
||||
/// <summary>
|
||||
/// paddleOCR V4 检测模型
|
||||
/// </summary>
|
||||
@@ -139,4 +145,4 @@ public class BgiOnnxModel
|
||||
RegisteredModels.Add(model);
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using Microsoft.ML.OnnxRuntime;
|
||||
using Microsoft.ML.OnnxRuntime.Tensors;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recognition.ONNX;
|
||||
|
||||
public sealed class BgiRedNetPredictor : IDisposable
|
||||
{
|
||||
private const int DefaultInputSize = 224;
|
||||
|
||||
private static readonly float[] ImagenetMean = [0.485f, 0.456f, 0.406f];
|
||||
private static readonly float[] ImagenetStd = [0.229f, 0.224f, 0.225f];
|
||||
|
||||
private readonly InferenceSession _session;
|
||||
private readonly string[]? _labels;
|
||||
private readonly string _inputName;
|
||||
private readonly int _inputWidth;
|
||||
private readonly int _inputHeight;
|
||||
|
||||
/// <summary>
|
||||
/// 使用 BgiOnnxFactory 创建这个类的实例
|
||||
/// </summary>
|
||||
internal BgiRedNetPredictor(BgiOnnxModel model, InferenceSession session, string? labelRelativePath = null)
|
||||
{
|
||||
_session = session;
|
||||
|
||||
var input = _session.InputMetadata.FirstOrDefault();
|
||||
if (input.Key is null || input.Value is null)
|
||||
{
|
||||
throw new InvalidDataException("ONNX 模型输入信息为空");
|
||||
}
|
||||
|
||||
_inputName = input.Key;
|
||||
var dimensions = input.Value.Dimensions;
|
||||
if (dimensions.Length < 4)
|
||||
{
|
||||
throw new InvalidDataException($"ONNX 模型输入维度不正确,预期 >=4,实际 {dimensions.Length}");
|
||||
}
|
||||
|
||||
_inputHeight = dimensions[^2] > 0 ? dimensions[^2] : DefaultInputSize;
|
||||
_inputWidth = dimensions[^1] > 0 ? dimensions[^1] : DefaultInputSize;
|
||||
_labels = LoadLabels(labelRelativePath ?? Path.ChangeExtension(model.ModelRelativePath, ".labels.txt"));
|
||||
}
|
||||
|
||||
public RedNetPrediction Predict(Image<Rgb24> image)
|
||||
{
|
||||
using var resized = image.Clone(ctx => ctx.Resize(_inputWidth, _inputHeight));
|
||||
var tensorInput = BuildInputTensor(resized);
|
||||
using var results = _session.Run([
|
||||
NamedOnnxValue.CreateFromTensor(_inputName, tensorInput)
|
||||
]);
|
||||
|
||||
var logits = results.First().AsEnumerable<float>().ToArray();
|
||||
if (logits.Length == 0)
|
||||
{
|
||||
throw new InvalidDataException("ONNX 模型输出为空");
|
||||
}
|
||||
|
||||
var probabilities = Softmax(logits);
|
||||
var maxIndex = 0;
|
||||
var maxValue = probabilities[0];
|
||||
for (var i = 1; i < probabilities.Length; i++)
|
||||
{
|
||||
if (probabilities[i] <= maxValue) continue;
|
||||
maxValue = probabilities[i];
|
||||
maxIndex = i;
|
||||
}
|
||||
|
||||
var label = maxIndex >= 0 && _labels is not null && maxIndex < _labels.Length
|
||||
? _labels[maxIndex]
|
||||
: $"Class_{maxIndex}";
|
||||
return new RedNetPrediction(maxIndex, label, maxValue);
|
||||
}
|
||||
|
||||
private DenseTensor<float> BuildInputTensor(Image<Rgb24> image)
|
||||
{
|
||||
var tensor = new DenseTensor<float>([1, 3, _inputHeight, _inputWidth]);
|
||||
for (var y = 0; y < _inputHeight; y++)
|
||||
{
|
||||
for (var x = 0; x < _inputWidth; x++)
|
||||
{
|
||||
var pixel = image[x, y];
|
||||
var r = pixel.R / 255f;
|
||||
var g = pixel.G / 255f;
|
||||
var b = pixel.B / 255f;
|
||||
|
||||
tensor[0, 0, y, x] = (r - ImagenetMean[0]) / ImagenetStd[0];
|
||||
tensor[0, 1, y, x] = (g - ImagenetMean[1]) / ImagenetStd[1];
|
||||
tensor[0, 2, y, x] = (b - ImagenetMean[2]) / ImagenetStd[2];
|
||||
}
|
||||
}
|
||||
|
||||
return tensor;
|
||||
}
|
||||
|
||||
private static float[] Softmax(float[] logits)
|
||||
{
|
||||
var max = logits.Max();
|
||||
var result = new float[logits.Length];
|
||||
var sum = 0d;
|
||||
|
||||
for (var i = 0; i < logits.Length; i++)
|
||||
{
|
||||
var value = Math.Exp(logits[i] - max);
|
||||
result[i] = (float)value;
|
||||
sum += value;
|
||||
}
|
||||
|
||||
if (sum <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
for (var i = 0; i < result.Length; i++)
|
||||
{
|
||||
result[i] = (float)(result[i] / sum);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string[]? LoadLabels(string labelRelativePath)
|
||||
{
|
||||
var labelAbsolutePath = Core.Config.Global.Absolute(labelRelativePath);
|
||||
if (!File.Exists(labelAbsolutePath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var ext = Path.GetExtension(labelAbsolutePath);
|
||||
if (ext.Equals(".json", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var labels = JsonSerializer.Deserialize<string[]>(File.ReadAllText(labelAbsolutePath));
|
||||
return labels is { Length: > 0 } ? labels : null;
|
||||
}
|
||||
|
||||
var lines = File.ReadAllLines(labelAbsolutePath)
|
||||
.Where(t => !string.IsNullOrWhiteSpace(t))
|
||||
.Select(t => t.Trim())
|
||||
.ToArray();
|
||||
return lines.Length > 0 ? lines : null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_session.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public readonly record struct RedNetPrediction(int ClassIndex, string ClassLabel, float Confidence);
|
||||
@@ -1,4 +1,4 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using Microsoft.ML.OnnxRuntime;
|
||||
using Microsoft.ML.OnnxRuntime.Tensors;
|
||||
using OpenCvSharp;
|
||||
@@ -8,9 +8,9 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR.Engine;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recognition.ONNX.SVTR;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class PickTextInference : ITextInference
|
||||
if (!File.Exists(wordJsonPath)) throw new FileNotFoundException("Yap字典文件不存在", wordJsonPath);
|
||||
|
||||
var json = File.ReadAllText(wordJsonPath);
|
||||
_wordDictionary = JsonSerializer.Deserialize<Dictionary<int, string>>(json) ??
|
||||
_wordDictionary = JsonConvert.DeserializeObject<Dictionary<int, string>>(json) ??
|
||||
throw new Exception("index_2_word.json deserialize failed");
|
||||
}
|
||||
|
||||
@@ -116,4 +116,4 @@ public class PickTextInference : ITextInference
|
||||
|
||||
return new DenseTensor<float>(memory, [1, 1, 32, 384]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace BetterGenshinImpact.Core.Recognition.ONNX.SVTR;
|
||||
|
||||
public class TextInferenceFactory
|
||||
{
|
||||
public static ITextInference Pick { get; } = Create(OcrEngineTypes.YapModel);
|
||||
public static readonly Lazy<ITextInference> Pick = new(() => Create(OcrEngineTypes.YapModel));
|
||||
|
||||
public static ITextInference Create(OcrEngineTypes type)
|
||||
{
|
||||
|
||||
@@ -87,4 +87,24 @@ public static class CommonExtension
|
||||
{
|
||||
return list.ConvertAll(ToPoint2d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将矩形钳位到指定尺寸范围内(交集语义),防止 OpenCV ROI 越界
|
||||
/// </summary>
|
||||
public static Rect ClampTo(this Rect rect, int maxWidth, int maxHeight)
|
||||
{
|
||||
int x1 = Math.Clamp(rect.X, 0, maxWidth);
|
||||
int y1 = Math.Clamp(rect.Y, 0, maxHeight);
|
||||
int x2 = Math.Clamp(rect.X + rect.Width, 0, maxWidth);
|
||||
int y2 = Math.Clamp(rect.Y + rect.Height, 0, maxHeight);
|
||||
return new Rect(x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将矩形钳位到 Mat 范围内(交集语义),防止 OpenCV ROI 越界
|
||||
/// </summary>
|
||||
public static Rect ClampTo(this Rect rect, Mat mat)
|
||||
{
|
||||
return rect.ClampTo(mat.Cols, mat.Rows);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using OpenCvSharp;
|
||||
|
||||
@@ -24,7 +25,7 @@ public static class Feature2DExtensions
|
||||
public static void SaveFeatures(this Feature2D feature2D, string trainImagePath, string trainKeyPointsPath, string trainDescriptorsPath)
|
||||
{
|
||||
Mat trainDescriptors = new();
|
||||
var img = Cv2.ImRead(trainImagePath, ImreadModes.Grayscale);
|
||||
var img = Bv.ImRead(trainImagePath, ImreadModes.Grayscale);
|
||||
|
||||
feature2D.DetectAndCompute(img, null, out var trainKeyPoints, trainDescriptors);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using System.Threading.Tasks;
|
||||
@@ -12,11 +12,13 @@ public class AutoPathingScript
|
||||
{
|
||||
private object? _config = null;
|
||||
private string _rootPath;
|
||||
private readonly LimitedFile _autoPathingFile;
|
||||
|
||||
public AutoPathingScript(string rootPath, object? config)
|
||||
{
|
||||
_config = config;
|
||||
_rootPath = rootPath;
|
||||
_autoPathingFile = new LimitedFile(Global.Absolute(@"User\AutoPathing"));
|
||||
}
|
||||
|
||||
public async Task Run(string json)
|
||||
@@ -59,7 +61,40 @@ public class AutoPathingScript
|
||||
/// <param name="path">在 `\User\AutoPathing` 目录下获取文件</param>
|
||||
public async Task RunFileFromUser(string path)
|
||||
{
|
||||
var json = await new LimitedFile(Global.Absolute(@"User\AutoPathing")).ReadText(path);
|
||||
var json = await AutoPathingFile.ReadText(path);
|
||||
await Run(json);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断 AutoPathing 目录下的路径是否存在
|
||||
/// </summary>
|
||||
/// <param name="subPath">相对于 User\AutoPathing 的路径</param>
|
||||
/// <returns>存在返回 true,否则返回 false</returns>
|
||||
public bool IsExists(string subPath) => AutoPathingFile.IsExists(subPath);
|
||||
|
||||
/// <summary>
|
||||
/// 判断 AutoPathing 目录下的路径是否为文件
|
||||
/// </summary>
|
||||
/// <param name="subPath">相对于 User\AutoPathing 的路径</param>
|
||||
/// <returns>是文件返回 true,否则返回 false</returns>
|
||||
public bool IsFile(string subPath) => AutoPathingFile.IsFile(subPath);
|
||||
|
||||
/// <summary>
|
||||
/// 判断 AutoPathing 目录下的路径是否为文件夹
|
||||
/// </summary>
|
||||
/// <param name="subPath">相对于 User\AutoPathing 的路径</param>
|
||||
/// <returns>是文件夹返回 true,否则返回 false</returns>
|
||||
public bool IsFolder(string subPath) => AutoPathingFile.IsFolder(subPath);
|
||||
|
||||
/// <summary>
|
||||
/// 读取 AutoPathing 目录下指定文件夹的内容(非递归方式)
|
||||
/// </summary>
|
||||
/// <param name="subPath">相对于 User\AutoPathing 的子目录路径,默认为相对根目录</param>
|
||||
/// <returns>文件夹内所有文件和文件夹的相对路径数组,出错时返回空数组</returns>
|
||||
public string[] ReadPathSync(string subPath = "./") => AutoPathingFile.ReadPathSync(subPath);
|
||||
|
||||
/// <summary>
|
||||
/// LimitedFile 实例,用于操作 AutoPathing 目录
|
||||
/// </summary>
|
||||
private LimitedFile AutoPathingFile => _autoPathingFile;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.ClearScript;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence;
|
||||
|
||||
public class CustomHostFunctions : HostFunctions
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建指定维度的交错数组变量
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数组元素类型</typeparam>
|
||||
/// <param name="dimensions">数组维度</param>
|
||||
/// <returns>交错数组变量</returns>
|
||||
public object NewVarOfArr<T>(int dimensions)
|
||||
{
|
||||
try
|
||||
{
|
||||
Type arrayType = typeof(T);
|
||||
for (int i = 0; i < dimensions; i++)
|
||||
{
|
||||
arrayType = arrayType.MakeArrayType();
|
||||
}
|
||||
|
||||
MethodInfo newVarMethod = typeof(HostFunctions).GetMethod(nameof(newVar))!;
|
||||
MethodInfo genericMethod = newVarMethod.MakeGenericMethod(arrayType);
|
||||
return genericMethod.Invoke(this, new object?[] { null })!;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidOperationException($"创建维度为 {dimensions} 的数组失败: {ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.AutoDomain;
|
||||
using BetterGenshinImpact.GameTask.AutoEat;
|
||||
using BetterGenshinImpact.GameTask.AutoFishing;
|
||||
using BetterGenshinImpact.GameTask.AutoCook;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
using BetterGenshinImpact.GameTask.AutoWood;
|
||||
@@ -19,6 +20,8 @@ using System.Dynamic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.GameTask.AutoLeyLineOutcrop;
|
||||
using BetterGenshinImpact.GameTask.AutoStygianOnslaught;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence;
|
||||
|
||||
@@ -193,6 +196,9 @@ public class Dispatcher
|
||||
await new AutoFishingTask(AutoFishingTaskParam.BuildFromSoloTaskConfig(soloTask.Config)).Start(
|
||||
cancellationToken);
|
||||
return null;
|
||||
case "AutoCook":
|
||||
await new AutoCookTask().Start(cancellationToken);
|
||||
return null;
|
||||
case "AutoEat":
|
||||
{
|
||||
string? foodName = soloTask.Config == null ? null : ScriptObjectConverter.GetValue((ScriptObject)soloTask.Config, "foodName", (string?)null);
|
||||
@@ -339,4 +345,39 @@ public class Dispatcher
|
||||
CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;
|
||||
await new AutoFightTask(param).Start(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 运行自动地脉花任务
|
||||
/// </summary>
|
||||
/// <param name="param">自动地脉花任务参数</param>
|
||||
/// <param name="customCt">自定义取消令牌</param>
|
||||
/// <returns></returns>
|
||||
public async Task RunAutoLeyLineOutcropTask(AutoLeyLineOutcropParam param, CancellationToken? customCt = null)
|
||||
{
|
||||
if (param == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(param), "自动地脉花任务参数不能为空");
|
||||
}
|
||||
|
||||
CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;
|
||||
await new AutoLeyLineOutcropTask(param).Start(cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 运行自动幽境危战任务
|
||||
/// </summary>
|
||||
/// <param name="param">自动幽境危战任务参数</param>
|
||||
/// <param name="customCt">自定义取消令牌</param>
|
||||
/// <returns></returns>
|
||||
public async Task RunAutoStygianOnslaughtTask(AutoStygianOnslaughtParam param, CancellationToken? customCt = null)
|
||||
{
|
||||
if (param == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(param), "自动幽境危战任务参数不能为空");
|
||||
}
|
||||
|
||||
CancellationToken cancellationToken = customCt ?? CancellationContext.Instance.Cts.Token;
|
||||
await new AutoStygianOnslaughtTask(param).Start(cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using BetterGenshinImpact.Core.Monitor;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
@@ -40,6 +42,9 @@ public class KeyMouseHook: IDisposable
|
||||
private EventHandler<MouseEventExtArgs>? _mouseMoveExtHandler;
|
||||
private EventHandler<MouseEventExtArgs>? _mouseWheelExtHandler;
|
||||
|
||||
private readonly object _mouseMoveLock = new();
|
||||
private DateTime _lastProcessMouseMoveTime = DateTime.MinValue;
|
||||
|
||||
private readonly ILogger<KeyMouseHook> _logger = App.GetLogger<KeyMouseHook>();
|
||||
|
||||
/// <summary>
|
||||
@@ -110,182 +115,259 @@ public class KeyMouseHook: IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private readonly System.Threading.Channels.Channel<Action> _eventChannel =
|
||||
System.Threading.Channels.Channel.CreateBounded<Action>(
|
||||
new System.Threading.Channels.BoundedChannelOptions(2048)
|
||||
{
|
||||
FullMode = System.Threading.Channels.BoundedChannelFullMode.Wait,
|
||||
SingleReader = true,
|
||||
SingleWriter = false
|
||||
});
|
||||
private readonly CancellationTokenSource _cts = new();
|
||||
|
||||
public KeyMouseHook()
|
||||
{
|
||||
// 启动后台事件处理器,确保不阻塞钩子线程
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var reader = _eventChannel.Reader;
|
||||
while (await reader.WaitToReadAsync(_cts.Token))
|
||||
{
|
||||
while (reader.TryRead(out var action))
|
||||
{
|
||||
try
|
||||
{
|
||||
action();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 内部错误已在 action 闭包中通过 HandleCallbackException 处理
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) { }
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "键鼠钩子后台处理器发生异常");
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化事件处理程序
|
||||
_keyDownHandler = (_, args) =>
|
||||
{
|
||||
// 创建回调列表的副本,避免迭代期间修改集合导致异常
|
||||
if (_keyDownDataCallbacks.Count == 0 && _keyDownCodeCallbacks.Count == 0) return;
|
||||
|
||||
var keyDownDataCallbacksCopy = new List<ScriptObject>(_keyDownDataCallbacks);
|
||||
var keyDownCodeCallbacksCopy = new List<ScriptObject>(_keyDownCodeCallbacks);
|
||||
|
||||
// 调用KeyData回调
|
||||
foreach (var callback in keyDownDataCallbacksCopy)
|
||||
{
|
||||
try
|
||||
var keyDataStr = args.KeyData.ToString();
|
||||
var keyCodeStr = args.KeyCode.ToString();
|
||||
|
||||
if (!_eventChannel.Writer.TryWrite(() =>
|
||||
{
|
||||
callback.InvokeAsFunction(args.KeyData.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "键盘按下事件");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 调用KeyCode回调
|
||||
foreach (var callback in keyDownCodeCallbacksCopy)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.InvokeAsFunction(args.KeyCode.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "键盘按下事件");
|
||||
return;
|
||||
}
|
||||
|
||||
// 调用KeyData回调
|
||||
foreach (var callback in keyDownDataCallbacksCopy)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.InvokeAsFunction(keyDataStr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "键盘按下事件");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 调用KeyCode回调
|
||||
foreach (var callback in keyDownCodeCallbacksCopy)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.InvokeAsFunction(keyCodeStr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "键盘按下事件");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}))
|
||||
{
|
||||
_logger.LogWarning("事件队列已满或已关闭,忽略键盘按下回调");
|
||||
}
|
||||
};
|
||||
|
||||
_keyUpHandler = (_, args) =>
|
||||
{
|
||||
// 创建回调列表的副本,避免迭代期间修改集合导致异常
|
||||
if (_keyUpDataCallbacks.Count == 0 && _keyUpCodeCallbacks.Count == 0) return;
|
||||
|
||||
var keyUpDataCallbacksCopy = new List<ScriptObject>(_keyUpDataCallbacks);
|
||||
var keyUpCodeCallbacksCopy = new List<ScriptObject>(_keyUpCodeCallbacks);
|
||||
|
||||
// 调用KeyData回调
|
||||
foreach (var callback in keyUpDataCallbacksCopy)
|
||||
{
|
||||
try
|
||||
var keyDataStr = args.KeyData.ToString();
|
||||
var keyCodeStr = args.KeyCode.ToString();
|
||||
if (!_eventChannel.Writer.TryWrite(() =>
|
||||
{
|
||||
callback.InvokeAsFunction(args.KeyData.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "键盘释放事件");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 调用KeyCode回调
|
||||
foreach (var callback in keyUpCodeCallbacksCopy)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.InvokeAsFunction(args.KeyCode.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "键盘释放事件");
|
||||
return;
|
||||
}
|
||||
// 调用KeyData回调
|
||||
foreach (var callback in keyUpDataCallbacksCopy)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.InvokeAsFunction(keyDataStr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "键盘释放事件");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 调用KeyCode回调
|
||||
foreach (var callback in keyUpCodeCallbacksCopy)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.InvokeAsFunction(keyCodeStr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "键盘释放事件");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}))
|
||||
{
|
||||
_logger.LogWarning("事件队列已满或已关闭,忽略键盘释放回调");
|
||||
}
|
||||
};
|
||||
|
||||
_mouseDownExtHandler = (_, args) =>
|
||||
{
|
||||
// 创建回调列表的副本,避免迭代期间修改集合导致异常
|
||||
if (_mouseDownCallbacks.Count == 0) return;
|
||||
|
||||
var mouseDownCallbacksCopy = new List<ScriptObject>(_mouseDownCallbacks);
|
||||
|
||||
// 转换为局部坐标
|
||||
var (localX, localY) = ConvertToLocalCoordinates(args.X, args.Y);
|
||||
|
||||
foreach (var callback in mouseDownCallbacksCopy)
|
||||
{
|
||||
try
|
||||
var buttonStr = args.Button.ToString();
|
||||
|
||||
if (!_eventChannel.Writer.TryWrite(() =>
|
||||
{
|
||||
callback.InvokeAsFunction(args.Button.ToString(), localX, localY);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "鼠标按下事件");
|
||||
return;
|
||||
}
|
||||
foreach (var callback in mouseDownCallbacksCopy)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.InvokeAsFunction(buttonStr, localX, localY);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "鼠标按下事件");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}))
|
||||
{
|
||||
_logger.LogWarning("事件队列已满或已关闭,忽略鼠标按下回调");
|
||||
}
|
||||
};
|
||||
|
||||
_mouseUpExtHandler = (_, args) =>
|
||||
{
|
||||
// 创建回调列表的副本,避免迭代期间修改集合导致异常
|
||||
if (_mouseUpCallbacks.Count == 0) return;
|
||||
|
||||
var mouseUpCallbacksCopy = new List<ScriptObject>(_mouseUpCallbacks);
|
||||
|
||||
// 转换为局部坐标
|
||||
var (localX, localY) = ConvertToLocalCoordinates(args.X, args.Y);
|
||||
|
||||
foreach (var callback in mouseUpCallbacksCopy)
|
||||
var buttonStr = args.Button.ToString();
|
||||
|
||||
if (!_eventChannel.Writer.TryWrite(() =>
|
||||
{
|
||||
foreach (var callback in mouseUpCallbacksCopy)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.InvokeAsFunction(buttonStr, localX, localY);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "鼠标释放事件");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}))
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.InvokeAsFunction(args.Button.ToString(), localX, localY);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "鼠标释放事件");
|
||||
return;
|
||||
}
|
||||
_logger.LogWarning("事件队列已满或已关闭,忽略鼠标释放回调");
|
||||
}
|
||||
};
|
||||
|
||||
_mouseMoveExtHandler = (_, args) =>
|
||||
{
|
||||
if (_mouseMoveCallbacks.Count == 0) return;
|
||||
|
||||
var now = DateTime.Now;
|
||||
// 创建回调列表的副本,避免迭代期间修改集合导致异常
|
||||
if ((now - _lastProcessMouseMoveTime).TotalMilliseconds < 10) return;
|
||||
_lastProcessMouseMoveTime = now;
|
||||
|
||||
var mouseMoveCallbacksCopy = new List<ScriptObject>(_mouseMoveCallbacks);
|
||||
|
||||
// 转换为局部坐标
|
||||
var (localX, localY) = ConvertToLocalCoordinates(args.X, args.Y);
|
||||
|
||||
foreach (var callback in mouseMoveCallbacksCopy)
|
||||
{
|
||||
try
|
||||
|
||||
if (!_eventChannel.Writer.TryWrite(() =>
|
||||
{
|
||||
// 获取回调的间隔时间
|
||||
if (_mouseMoveCallbackIntervals.TryGetValue(callback, out var interval))
|
||||
foreach (var callback in mouseMoveCallbacksCopy)
|
||||
{
|
||||
// 获取上次调用时间
|
||||
if (_lastMouseMoveCallbackTimes.TryGetValue(callback, out var lastTime))
|
||||
|
||||
try
|
||||
{
|
||||
// 计算时间差
|
||||
var timeSpan = now - lastTime;
|
||||
// 如果时间差大于等于间隔时间,则执行回调
|
||||
if (timeSpan.TotalMilliseconds >= interval)
|
||||
lock (_mouseMoveLock)
|
||||
{
|
||||
callback.InvokeAsFunction(localX, localY);
|
||||
// 更新上次调用时间
|
||||
_lastMouseMoveCallbackTimes[callback] = now;
|
||||
if (_mouseMoveCallbackIntervals.TryGetValue(callback, out var interval) &&
|
||||
_lastMouseMoveCallbackTimes.TryGetValue(callback, out var lastTime))
|
||||
{
|
||||
var timeSpan = now - lastTime;
|
||||
if (timeSpan.TotalMilliseconds >= interval)
|
||||
{
|
||||
callback.InvokeAsFunction(localX, localY);
|
||||
_lastMouseMoveCallbackTimes[callback] = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "鼠标移动事件");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "鼠标移动事件");
|
||||
return;
|
||||
}
|
||||
}))
|
||||
{
|
||||
_logger.LogWarning("事件队列已满或已关闭,忽略鼠标移动回调");
|
||||
}
|
||||
};
|
||||
|
||||
_mouseWheelExtHandler = (_, args) =>
|
||||
{
|
||||
// 创建回调列表的副本,避免迭代期间修改集合导致异常
|
||||
if (_mouseWheelCallbacks.Count == 0) return;
|
||||
|
||||
var mouseWheelCallbacksCopy = new List<ScriptObject>(_mouseWheelCallbacks);
|
||||
|
||||
// 转换为局部坐标
|
||||
var (localX, localY) = ConvertToLocalCoordinates(args.X, args.Y);
|
||||
|
||||
foreach (var callback in mouseWheelCallbacksCopy)
|
||||
var delta = args.Delta;
|
||||
|
||||
if (!_eventChannel.Writer.TryWrite(() =>
|
||||
{
|
||||
foreach (var callback in mouseWheelCallbacksCopy)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.InvokeAsFunction(delta, localX, localY);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "鼠标滚轮事件");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}))
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.InvokeAsFunction(args.Delta, localX, localY);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleCallbackException(ex, "鼠标滚轮事件");
|
||||
return;
|
||||
}
|
||||
_logger.LogWarning("事件队列已满或已关闭,忽略鼠标滚轮回调");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -376,6 +458,8 @@ public class KeyMouseHook: IDisposable
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_cts.Cancel();
|
||||
_eventChannel.Writer.TryComplete();
|
||||
// 移除所有事件监听器
|
||||
if (_keyDownHandler != null)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using BetterGenshinImpact.Core.Script.Utils;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using OpenCvSharp;
|
||||
@@ -72,6 +74,44 @@ public class LimitedFile(string rootPath)
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断指定路径是否为文件
|
||||
/// </summary>
|
||||
/// <param name="path">文件路径(相对于根目录)</param>
|
||||
/// <returns>如果是文件则返回 true,否则返回 false</returns>
|
||||
public bool IsFile(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
string normalizedPath = NormalizePath(path);
|
||||
return File.Exists(normalizedPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskControl.Logger.LogError("IsFile 异常: {Message}", ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断指定的文件或目录是否存在
|
||||
/// </summary>
|
||||
/// <param name="path">文件或目录路径(相对于根目录)</param>
|
||||
/// <returns>如果存在返回 true,否则返回 false</returns>
|
||||
public bool IsExists(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
string normalizedPath = NormalizePath(path);
|
||||
return File.Exists(normalizedPath) || Directory.Exists(normalizedPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskControl.Logger.LogError("IsExists 异常: {Message}", ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Normalize and validate a path.
|
||||
/// </summary>
|
||||
@@ -447,4 +487,51 @@ public class LimitedFile(string rootPath)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重命名文件或文件夹(相对于根目录)
|
||||
/// </summary>
|
||||
/// <param name="oldPath">原路径</param>
|
||||
/// <param name="newPath">新路径</param>
|
||||
/// <returns>是否重命名成功</returns>
|
||||
public bool RenamePathSync(string oldPath, string newPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 标准化路径
|
||||
oldPath = NormalizePath(oldPath);
|
||||
newPath = NormalizePath(newPath);
|
||||
|
||||
// 检查原路径是否存在
|
||||
if (!File.Exists(oldPath) && !Directory.Exists(oldPath))
|
||||
{
|
||||
TaskControl.Logger.LogError("RenamePathSync 异常: 原路径不存在 {Path}", oldPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
//验证扩展名合法性
|
||||
if (File.Exists(oldPath) && !IsValid(newPath))
|
||||
{
|
||||
TaskControl.Logger.LogError("RenamePathSync 异常: 新文件路径不合法 {Path}", newPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 确保目标目录存在
|
||||
string? directoryPath = Path.GetDirectoryName(newPath);
|
||||
if (!string.IsNullOrEmpty(directoryPath) && !Directory.Exists(directoryPath))
|
||||
{
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
}
|
||||
|
||||
// 执行重命名
|
||||
Directory.Move(oldPath, newPath);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskControl.Logger.LogError("RenamePathSync 异常: {Message}", ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using BetterGenshinImpact.Core.Script.Dependence.Model;
|
||||
using Microsoft.ClearScript;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.BgiVision;
|
||||
using OpenCvSharp;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
@@ -12,7 +13,9 @@ using BetterGenshinImpact.Core.Script.Utils;
|
||||
using BetterGenshinImpact.GameTask.AutoDomain;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Model;
|
||||
using BetterGenshinImpact.GameTask.AutoLeyLineOutcrop;
|
||||
using BetterGenshinImpact.GameTask.AutoSkip;
|
||||
using BetterGenshinImpact.GameTask.AutoStygianOnslaught;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script;
|
||||
|
||||
@@ -72,10 +75,19 @@ public class EngineExtend
|
||||
|
||||
engine.AddHostType("AutoDomainParam", typeof(AutoDomainParam));
|
||||
engine.AddHostType("AutoFightParam", typeof(AutoFightParam));
|
||||
engine.AddHostType("AutoLeyLineOutcropParam", typeof(AutoLeyLineOutcropParam));
|
||||
engine.AddHostType("AutoStygianOnslaughtParam", typeof(AutoStygianOnslaughtParam));
|
||||
//鼠标回调
|
||||
engine.AddHostType("KeyMouseHook", typeof(KeyMouseHook));
|
||||
// 添加C#的类型
|
||||
engine.AddHostType(typeof(Task));
|
||||
|
||||
// 新的BvPage类
|
||||
engine.AddHostType("BvPage", typeof(BvPage));
|
||||
engine.AddHostType("BvLocator", typeof(BvLocator));
|
||||
engine.AddHostType("BvImage", typeof(BvImage));
|
||||
|
||||
engine.AddHostObject("host", new CustomHostFunctions());
|
||||
|
||||
// 导入 JavaScript 模块
|
||||
// https://microsoft.github.io/ClearScript/2023/01/24/module-interop.html
|
||||
|
||||
@@ -216,6 +216,9 @@ public partial class ScriptGroupProject : ObservableObject
|
||||
}
|
||||
JsScriptSettingsObject ??= new ExpandoObject();
|
||||
|
||||
// 清理配置中的无效值
|
||||
CleanInvalidSettingsValues();
|
||||
|
||||
var pathingPartyConfig = GroupInfo?.Config.PathingConfig;
|
||||
await Project.ExecuteAsync(JsScriptSettingsObject, pathingPartyConfig);
|
||||
}
|
||||
@@ -336,6 +339,67 @@ public partial class ScriptGroupProject : ObservableObject
|
||||
{
|
||||
OnPropertyChanged(nameof(ScheduleDesc));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理 JsScriptSettingsObject 中不在 settings.json 定义的 Options 列表中的无效值
|
||||
/// </summary>
|
||||
private void CleanInvalidSettingsValues()
|
||||
{
|
||||
if (Project == null || JsScriptSettingsObject == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 加载 settings.json 中定义的配置项
|
||||
var settingItems = Project.Manifest.LoadSettingItems(Project.ProjectPath);
|
||||
if (settingItems.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var settingsDict = JsScriptSettingsObject as IDictionary<string, object?>;
|
||||
if (settingsDict == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历所有 multi-checkbox 类型的配置项
|
||||
foreach (var item in settingItems.Where(i => i.Type == "multi-checkbox"))
|
||||
{
|
||||
if (!settingsDict.ContainsKey(item.Name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取当前保存的值
|
||||
var savedValue = settingsDict[item.Name];
|
||||
List<string>? checkedValues = null;
|
||||
|
||||
if (savedValue is List<string> stringList)
|
||||
{
|
||||
checkedValues = stringList;
|
||||
}
|
||||
else if (savedValue is List<object> objectList)
|
||||
{
|
||||
checkedValues = objectList.Select(i => (string)i).ToList();
|
||||
settingsDict[item.Name] = checkedValues;
|
||||
}
|
||||
|
||||
// 清理不在 Options 列表中的无效值
|
||||
if (checkedValues != null && item.Options != null)
|
||||
{
|
||||
checkedValues.RemoveAll(value => !item.Options.Contains(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 清理失败不影响脚本执行,只记录日志
|
||||
TaskControl.Logger.LogDebug(ex, "清理JS脚本配置中的无效值时发生异常");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ScriptGroupProjectExtensions
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.ClearScript;
|
||||
using Microsoft.ClearScript.JavaScript;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script
|
||||
{
|
||||
public class PackageDocumentLoader : DocumentLoader
|
||||
{
|
||||
private readonly string _scriptRootPath;
|
||||
|
||||
public PackageDocumentLoader(string scriptRootPath)
|
||||
{
|
||||
_scriptRootPath = Path.GetFullPath(scriptRootPath);
|
||||
}
|
||||
|
||||
public override async Task<Document> LoadDocumentAsync(DocumentSettings settings, DocumentInfo? sourceInfo, string specifier, DocumentCategory category, DocumentContextCallback contextCallback)
|
||||
{
|
||||
string? targetPath = ResolvePhysicalPath(settings, sourceInfo, specifier);
|
||||
|
||||
if (targetPath == null || !File.Exists(targetPath))
|
||||
{
|
||||
return await Default.LoadDocumentAsync(settings, sourceInfo, specifier, category, contextCallback);
|
||||
}
|
||||
|
||||
// 处理 JS 文件的重写
|
||||
if (Path.GetExtension(targetPath).ToLower() == ".js")
|
||||
{
|
||||
string content = await File.ReadAllTextAsync(targetPath);
|
||||
string processedCode = RewriteScriptCode(content, targetPath);
|
||||
return new StringDocument(new DocumentInfo(targetPath) { Category = ModuleCategory.Standard }, processedCode);
|
||||
}
|
||||
|
||||
return await Default.LoadDocumentAsync(settings, sourceInfo, specifier, category, contextCallback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// js重写
|
||||
/// </summary>
|
||||
public string RewriteScriptCode(string code, string currentFilePath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(code)) return code;
|
||||
|
||||
string result = code.Replace("../../../packages", "packages");
|
||||
|
||||
// 拦截资源导入
|
||||
var resourceRegex = new Regex(@"import\s+([\w\d_*$]+|[\s\S]*?)\s+from\s+(['""])([^'""\n]+)(['""])");
|
||||
result = resourceRegex.Replace(result, match =>
|
||||
{
|
||||
string importPart = match.Groups[1].Value.Trim();
|
||||
string quote = match.Groups[2].Value;
|
||||
string rawPath = match.Groups[3].Value;
|
||||
|
||||
string path = rawPath.Replace("../../../packages", "packages");
|
||||
string? resourceFullPath = ResolvePathInternal(null, currentFilePath, path);
|
||||
|
||||
if (resourceFullPath != null && File.Exists(resourceFullPath))
|
||||
{
|
||||
string normalizedPath = Path.GetRelativePath(_scriptRootPath, resourceFullPath).Replace("\\", "/");
|
||||
bool isJs = resourceFullPath.EndsWith(".js", StringComparison.OrdinalIgnoreCase);
|
||||
bool isImage = IsImageFile(resourceFullPath);
|
||||
|
||||
// 图片 -> Mat
|
||||
if (isImage)
|
||||
{
|
||||
if (importPart.StartsWith("{")) return match.Value;
|
||||
return $"const {importPart} = file.ReadImageMatSync({quote}{normalizedPath}{quote});";
|
||||
}
|
||||
|
||||
// 非 JS 资源 -> 文本内容
|
||||
if (!isJs)
|
||||
{
|
||||
if (importPart.StartsWith("{")) return match.Value;
|
||||
return $"const {importPart} = file.ReadTextSync({quote}{normalizedPath}{quote});";
|
||||
}
|
||||
}
|
||||
|
||||
return match.Value;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private string? ResolvePhysicalPath(DocumentSettings settings, DocumentInfo? sourceInfo, string specifier)
|
||||
{
|
||||
return ResolvePathInternal(settings.SearchPath, sourceInfo?.Name, specifier);
|
||||
}
|
||||
|
||||
private string? ResolvePathInternal(string? searchPath, string? referrer, string specifier)
|
||||
{
|
||||
if (specifier.StartsWith("packages/", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ProbeFile(Path.Combine(_scriptRootPath, specifier));
|
||||
}
|
||||
|
||||
if (specifier.StartsWith("."))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(referrer))
|
||||
{
|
||||
string? dir = Path.GetDirectoryName(referrer);
|
||||
if (dir != null)
|
||||
{
|
||||
return ProbeFile(Path.GetFullPath(Path.Combine(dir, specifier)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(searchPath))
|
||||
{
|
||||
var paths = searchPath.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var p in paths)
|
||||
{
|
||||
string combined = Path.Combine(p, specifier);
|
||||
string? found = ProbeFile(combined);
|
||||
if (found != null) return found;
|
||||
}
|
||||
}
|
||||
|
||||
return ProbeFile(Path.Combine(_scriptRootPath, specifier));
|
||||
}
|
||||
|
||||
private string? ProbeFile(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(path)) return path;
|
||||
if (File.Exists(path + ".js")) return path + ".js";
|
||||
}
|
||||
catch { }
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool IsImageFile(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path)) return false;
|
||||
string ext = Path.GetExtension(path).ToLower();
|
||||
string[] imageExtensions = { ".png", ".jpg", ".jpeg", ".bmp", ".tiff", ".webp" };
|
||||
return imageExtensions.Contains(ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,10 @@ using BetterGenshinImpact.Core.Config;
|
||||
using Microsoft.ClearScript;
|
||||
using Microsoft.ClearScript.V8;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -69,10 +71,24 @@ public class ScriptProject
|
||||
return scrollViewer;
|
||||
}
|
||||
|
||||
public IScriptEngine BuildScriptEngine(PathingPartyConfig? partyConfig = null)
|
||||
private IScriptEngine BuildScriptEngine(PathingPartyConfig? partyConfig)
|
||||
{
|
||||
IScriptEngine engine = new V8ScriptEngine(V8ScriptEngineFlags.UseCaseInsensitiveMemberBinding | V8ScriptEngineFlags.EnableTaskPromiseConversion);
|
||||
EngineExtend.InitHost(engine, ProjectPath, Manifest.Library,partyConfig);
|
||||
V8ScriptEngine engine = new V8ScriptEngine(V8ScriptEngineFlags.UseCaseInsensitiveMemberBinding | V8ScriptEngineFlags.EnableTaskPromiseConversion);
|
||||
|
||||
// packages 依赖和资源重载
|
||||
var loader = new PackageDocumentLoader(ProjectPath);
|
||||
engine.DocumentSettings.Loader = loader;
|
||||
|
||||
// 添加 packages 到搜索路径
|
||||
var libraries = new HashSet<string>(Manifest.Library ?? Array.Empty<string>())
|
||||
{
|
||||
".",
|
||||
"./packages"
|
||||
};
|
||||
|
||||
var libraryList = libraries.ToList();
|
||||
|
||||
EngineExtend.InitHost(engine, ProjectPath, libraryList.ToArray(), partyConfig);
|
||||
return engine;
|
||||
}
|
||||
|
||||
@@ -83,6 +99,10 @@ public class ScriptProject
|
||||
// 加载代码
|
||||
var code = await LoadCode();
|
||||
var engine = BuildScriptEngine(partyConfig);
|
||||
|
||||
// 使用自定义加载器解析脚本文件
|
||||
var loader = (PackageDocumentLoader)engine.DocumentSettings.Loader;
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
// 写入配置的内容
|
||||
@@ -90,12 +110,19 @@ public class ScriptProject
|
||||
}
|
||||
try
|
||||
{
|
||||
if (Manifest.Library.Length != 0)
|
||||
bool useModule = Manifest.Library.Length != 0 ||
|
||||
code.Contains("import ", StringComparison.Ordinal) ||
|
||||
code.Contains("export ", StringComparison.Ordinal);
|
||||
|
||||
if (useModule)
|
||||
{
|
||||
// 清除Document缓存
|
||||
DocumentLoader.Default.DiscardCachedDocuments();
|
||||
|
||||
var evaluation = engine.Evaluate(new DocumentInfo { Category = ModuleCategory.Standard }, code);
|
||||
string mainScriptPath = Path.Combine(ProjectPath, Manifest.Main);
|
||||
string runtimeCode = loader.RewriteScriptCode(code, mainScriptPath);
|
||||
|
||||
var evaluation = engine.Evaluate(new DocumentInfo(mainScriptPath) { Category = ModuleCategory.Standard }, runtimeCode);
|
||||
if (evaluation is Task task) await task;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -78,6 +78,28 @@ public sealed class RepoWebBridge
|
||||
return await File.ReadAllTextAsync(userConfigPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前仓库的已订阅脚本路径列表(JSON 数组)。
|
||||
/// 相比 GetUserConfigJson() 更轻量,仅返回当前仓库的订阅路径。
|
||||
/// </summary>
|
||||
public string GetSubscribedScriptPaths()
|
||||
{
|
||||
try
|
||||
{
|
||||
var paths = ScriptRepoUpdater.GetSubscribedPathsForCurrentRepo();
|
||||
if (paths.Count > 0)
|
||||
{
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(paths);
|
||||
}
|
||||
|
||||
return "[]";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "[]";
|
||||
}
|
||||
}
|
||||
|
||||
public Task<string> GetFile(string relPath)
|
||||
{
|
||||
try
|
||||
@@ -183,7 +205,7 @@ public sealed class RepoWebBridge
|
||||
throw new FileNotFoundException("找不到原始 repo.json 文件");
|
||||
}
|
||||
|
||||
string targetPath = Path.Combine(ScriptRepoUpdater.ReposPath, "repo_updated.json");
|
||||
string targetPath = ScriptRepoUpdater.RepoUpdatedJsonPath;
|
||||
|
||||
File.Copy(repoJsonPath, targetPath, overwrite: true);
|
||||
|
||||
@@ -228,10 +250,7 @@ public sealed class RepoWebBridge
|
||||
|
||||
private static string GetRepoJsonPath()
|
||||
{
|
||||
string updatedRepoJsonPath = Path.Combine(
|
||||
Path.GetDirectoryName(Path.Combine(ScriptRepoUpdater.ReposPath, "bettergi-scripts-list-git"))!,
|
||||
"repo_updated.json"
|
||||
);
|
||||
string updatedRepoJsonPath = ScriptRepoUpdater.RepoUpdatedJsonPath;
|
||||
|
||||
if (File.Exists(updatedRepoJsonPath))
|
||||
{
|
||||
@@ -245,7 +264,7 @@ public sealed class RepoWebBridge
|
||||
return repoJson ?? throw new FileNotFoundException("repo.json 仓库索引文件不存在,请至少成功更新一次仓库!");
|
||||
}
|
||||
|
||||
private static void ProcessPathRecursively(JArray array, string[] pathParts, int currentIndex)
|
||||
internal static void ProcessPathRecursively(JArray array, string[] pathParts, int currentIndex)
|
||||
{
|
||||
foreach (JObject item in array.OfType<JObject>())
|
||||
{
|
||||
@@ -263,7 +282,7 @@ public sealed class RepoWebBridge
|
||||
}
|
||||
}
|
||||
|
||||
private static void ResetHasUpdateFlag(JObject node)
|
||||
internal static void ResetHasUpdateFlag(JObject node)
|
||||
{
|
||||
if (node["hasUpdate"] is { Type: JTokenType.Boolean } hasUpdate &&
|
||||
(bool)hasUpdate)
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoCook;
|
||||
|
||||
/// <summary>
|
||||
///自动烹饪配置
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public partial class AutoCookConfig : ObservableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 触发器是否启用
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _enabled = false;
|
||||
private int _checkIntervalMs = 10;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _stopTaskWhenRecoverButtonDetected = true;
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoCook;
|
||||
|
||||
public class AutoCookTask : ISoloTask
|
||||
{
|
||||
private readonly ILogger<AutoCookTask> _logger = App.GetLogger<AutoCookTask>();
|
||||
private const int UiCheckIntervalMs = 400;
|
||||
private const int PeakMinCount = 600; // 最小仙跳墙 700 多
|
||||
private const int PeakTolerance = 20;
|
||||
private const int PeakStableFrameCount = 3;
|
||||
private const int TriggerDropCount = 300; // 正常是 400多
|
||||
private static readonly Rect CookColorRect1080P = new(600, 660, 730, 190);
|
||||
private static readonly Scalar TargetCookColor = new(255, 192, 64);
|
||||
|
||||
public string Name => "自动烹饪";
|
||||
|
||||
public async Task Start(CancellationToken ct)
|
||||
{
|
||||
var assetScale = TaskContext.Instance().SystemInfo.AssetScale;
|
||||
var autoCookConfig = TaskContext.Instance().Config.AutoCookConfig;
|
||||
var checkIntervalMs = Math.Max(1, autoCookConfig.CheckIntervalMs);
|
||||
var stopTaskWhenRecoverButtonDetected = autoCookConfig.StopTaskWhenRecoverButtonDetected;
|
||||
var peakMinCount = (int)(PeakMinCount * assetScale);
|
||||
var triggerDropCount = (int)(TriggerDropCount * assetScale);
|
||||
var cookColorRect = ScaleRect(CookColorRect1080P, assetScale);
|
||||
_logger.LogInformation("自动烹饪任务启动");
|
||||
var lastUiCheckTime = DateTime.MinValue;
|
||||
var inCookUi = false;
|
||||
int? peakColorCount = null;
|
||||
int? peakCandidate = null;
|
||||
var peakCandidateStableFrames = 0;
|
||||
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
using var captureRegion = CaptureToRectArea();
|
||||
var now = DateTime.UtcNow;
|
||||
if (!inCookUi || (now - lastUiCheckTime).TotalMilliseconds >= UiCheckIntervalMs)
|
||||
{
|
||||
var currentInCookUi = IsInCookUi(captureRegion);
|
||||
if (currentInCookUi != inCookUi)
|
||||
{
|
||||
ResetPeakState(ref peakColorCount, ref peakCandidate, ref peakCandidateStableFrames);
|
||||
}
|
||||
|
||||
inCookUi = currentInCookUi;
|
||||
lastUiCheckTime = now;
|
||||
if (!inCookUi)
|
||||
{
|
||||
ResetPeakState(ref peakColorCount, ref peakCandidate, ref peakCandidateStableFrames);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stopTaskWhenRecoverButtonDetected)
|
||||
{
|
||||
var e = captureRegion.Find(ElementAssets.Instance.BtnWhiteRecover);
|
||||
if (e.IsExist())
|
||||
{
|
||||
_logger.LogInformation("自动烹饪:{Text}", "检测到自动烹饪按钮,结束任务");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Bv.ClickWhiteConfirmButton(captureRegion))
|
||||
{
|
||||
ResetPeakState(ref peakColorCount, ref peakCandidate, ref peakCandidateStableFrames);
|
||||
_logger.LogInformation("自动烹饪:{Text}", "自动点击确认");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inCookUi)
|
||||
{
|
||||
var currentColorCount = CountTargetColor(captureRegion, cookColorRect);
|
||||
if (peakColorCount.HasValue)
|
||||
{
|
||||
if (currentColorCount <= peakColorCount.Value - triggerDropCount)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_SPACE);
|
||||
_logger.LogInformation("自动烹饪:{Text}", $"烹饪条像素数量较峰值下降超过{triggerDropCount},按下空格。峰值:{peakColorCount.Value} 当前:{currentColorCount}");
|
||||
ResetPeakState(ref peakColorCount, ref peakCandidate, ref peakCandidateStableFrames);
|
||||
}
|
||||
}
|
||||
else if (TryBuildPeak(currentColorCount, peakMinCount, ref peakCandidate, ref peakCandidateStableFrames, out var builtPeak))
|
||||
{
|
||||
peakColorCount = builtPeak;
|
||||
_logger.LogInformation("自动烹饪:{Text}", $"识别到完美烹饪条峰值像素数:{builtPeak}");
|
||||
}
|
||||
}
|
||||
|
||||
await Delay(checkIntervalMs, ct);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ResetPeakState(ref int? peakColorCount, ref int? peakCandidate, ref int peakCandidateStableFrames)
|
||||
{
|
||||
peakColorCount = null;
|
||||
peakCandidate = null;
|
||||
peakCandidateStableFrames = 0;
|
||||
}
|
||||
|
||||
private static bool TryBuildPeak(int currentColorCount, int peakMinCount, ref int? peakCandidate, ref int peakCandidateStableFrames, out int builtPeak)
|
||||
{
|
||||
builtPeak = 0;
|
||||
if (currentColorCount <= peakMinCount)
|
||||
{
|
||||
peakCandidate = null;
|
||||
peakCandidateStableFrames = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!peakCandidate.HasValue)
|
||||
{
|
||||
peakCandidate = currentColorCount;
|
||||
peakCandidateStableFrames = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Math.Abs(currentColorCount - peakCandidate.Value) <= PeakTolerance)
|
||||
{
|
||||
peakCandidate = Math.Max(peakCandidate.Value, currentColorCount);
|
||||
peakCandidateStableFrames++;
|
||||
if (peakCandidateStableFrames >= PeakStableFrameCount && peakCandidate.Value > peakMinCount)
|
||||
{
|
||||
builtPeak = peakCandidate.Value;
|
||||
peakCandidate = null;
|
||||
peakCandidateStableFrames = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
peakCandidate = currentColorCount;
|
||||
peakCandidateStableFrames = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Rect ScaleRect(Rect rect, double scale)
|
||||
{
|
||||
return new Rect(
|
||||
(int)(rect.X * scale),
|
||||
(int)(rect.Y * scale),
|
||||
(int)(rect.Width * scale),
|
||||
(int)(rect.Height * scale));
|
||||
}
|
||||
|
||||
private bool IsInCookUi(ImageRegion captureRegion)
|
||||
{
|
||||
using var cookIcon = captureRegion.Find(ElementAssets.Instance.UiLeftTopCookIcon);
|
||||
return cookIcon.IsExist();
|
||||
}
|
||||
|
||||
private int CountTargetColor(ImageRegion captureRegion, Rect cookColorRect)
|
||||
{
|
||||
using var crop = captureRegion.DeriveCrop(cookColorRect);
|
||||
using var rgb = new Mat();
|
||||
using var mask = new Mat();
|
||||
Cv2.CvtColor(crop.SrcMat, rgb, ColorConversionCodes.BGR2RGB);
|
||||
Cv2.InRange(rgb, TargetCookColor, TargetCookColor, mask);
|
||||
return Cv2.CountNonZero(mask);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
using BetterGenshinImpact.Core.Recognition.OpenCv;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenCvSharp;
|
||||
using System.Linq;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoCook;
|
||||
|
||||
public class AutoCookTrigger : ITaskTrigger
|
||||
{
|
||||
private readonly ILogger<AutoCookTrigger> _logger = App.GetLogger<AutoCookTrigger>();
|
||||
|
||||
public string Name => "自动烹饪";
|
||||
public bool IsEnabled { get; set; }
|
||||
public int Priority => 50;
|
||||
public bool IsExclusive { get; set; }
|
||||
|
||||
public void Init()
|
||||
{
|
||||
IsEnabled = TaskContext.Instance().Config.AutoCookConfig.Enabled;
|
||||
IsExclusive = false;
|
||||
}
|
||||
|
||||
public void OnCapture(CaptureContent content)
|
||||
{
|
||||
// 判断是否处于烹饪界面
|
||||
IsExclusive = false;
|
||||
content.CaptureRectArea.Find(ElementAssets.Instance.UiLeftTopCookIcon, _ =>
|
||||
{
|
||||
IsExclusive = true;
|
||||
var captureRect = TaskContext.Instance().SystemInfo.ScaleMax1080PCaptureRect;
|
||||
using var region = content.CaptureRectArea.DeriveCrop(0, captureRect.Height / 2, captureRect.Width, captureRect.Height / 2);
|
||||
var perfectBarRects = ContoursHelper.FindSpecifyColorRects(region.SrcMat, new Scalar(255, 192, 64), 0, 8);
|
||||
if (perfectBarRects.Count >= 2)
|
||||
{
|
||||
// 点击烹饪按钮
|
||||
var btnList = ContoursHelper.FindSpecifyColorRects(region.SrcMat, new Scalar(255, 255, 192), 12, 12);
|
||||
if (btnList.Count >= 1)
|
||||
{
|
||||
if (btnList.Count > 1)
|
||||
{
|
||||
_logger.LogWarning("自动烹饪:{Text}", "识别到多个结束烹饪按钮");
|
||||
btnList = [.. btnList.OrderByDescending(r => r.Width)];
|
||||
}
|
||||
var btn = btnList[0];
|
||||
var x = btn.X + btn.Width / 2;
|
||||
var y = btn.Y + btn.Height / 2;
|
||||
region.ClickTo(x, y);
|
||||
_logger.LogInformation("自动烹饪:{Text}", "点击结束按钮");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,49 @@
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.GameTask.Model;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoDomain.Assets;
|
||||
|
||||
public class AutoDomainAssets : BaseAssets<AutoDomainAssets>
|
||||
{
|
||||
public RecognitionObject ResinSwitchBtnRo;
|
||||
public RecognitionObject ResinSwitchBtnNoActiveRo;
|
||||
|
||||
|
||||
private AutoDomainAssets() : base()
|
||||
{
|
||||
Initialization(this.systemInfo);
|
||||
}
|
||||
|
||||
protected AutoDomainAssets(ISystemInfo systemInfo) : base(systemInfo)
|
||||
{
|
||||
Initialization(systemInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Initialization(ISystemInfo systemInfo)
|
||||
{
|
||||
// 可点击状态的树脂切换按钮
|
||||
ResinSwitchBtnRo = new RecognitionObject
|
||||
{
|
||||
Name = "ResinSwitchBtn",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoDomain", "resin_switch_btn.png", this.systemInfo),
|
||||
RegionOfInterest = new Rect((int)(960 * AssetScale), (int)(430 * AssetScale), (int)(400 * AssetScale), (int)(130 * AssetScale)),
|
||||
Threshold = 0.8,
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
|
||||
// 不可点击状态的树脂切换按钮
|
||||
ResinSwitchBtnNoActiveRo = new RecognitionObject
|
||||
{
|
||||
Name = "ResinSwitchBtnNoActive",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoDomain", "resin_switch_btn_no_active.png", this.systemInfo),
|
||||
RegionOfInterest = new Rect((int)(960 * AssetScale), (int)(430 * AssetScale), (int)(400 * AssetScale), (int)(130 * AssetScale)),
|
||||
Threshold = 0.8,
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,13 @@ public partial class AutoDomainConfig : ObservableObject
|
||||
// 使用原粹树脂刷取副本次数
|
||||
[ObservableProperty]
|
||||
private int _originalResinUseCount = 0;
|
||||
// 使用原粹树脂(20)刷取副本次数
|
||||
[ObservableProperty]
|
||||
private int _originalResin20UseCount = 0;
|
||||
|
||||
// 使用原粹树脂(40)刷取副本次数
|
||||
[ObservableProperty]
|
||||
private int _originalResin40UseCount = 0;
|
||||
|
||||
//使用浓缩树脂刷取副本次数
|
||||
[ObservableProperty]
|
||||
|
||||
@@ -34,9 +34,13 @@ public class AutoDomainParam : BaseTaskParam<AutoDomainTask>
|
||||
"浓缩树脂",
|
||||
"原粹树脂"
|
||||
];
|
||||
|
||||
// 使用原粹树脂刷取副本次数
|
||||
public int OriginalResinUseCount { get; set; } = 0;
|
||||
// 使用原粹树脂(20)刷取副本次数
|
||||
public int OriginalResin20UseCount { get; set; } = 0;
|
||||
|
||||
// 使用原粹树脂(40)刷取副本次数
|
||||
public int OriginalResin40UseCount { get; set; } = 0;
|
||||
|
||||
// 使用浓缩树脂刷取副本次数
|
||||
public int CondensedResinUseCount { get; set; } = 0;
|
||||
@@ -73,6 +77,8 @@ public class AutoDomainParam : BaseTaskParam<AutoDomainTask>
|
||||
TransientResinUseCount = config.TransientResinUseCount;
|
||||
FragileResinUseCount = config.FragileResinUseCount;
|
||||
SpecifyResinUse = config.SpecifyResinUse;
|
||||
OriginalResin20UseCount = config.OriginalResin20UseCount;
|
||||
OriginalResin40UseCount = config.OriginalResin40UseCount;
|
||||
}
|
||||
|
||||
public AutoDomainParam(int domainRoundNum = 0) : base(null, null)
|
||||
|
||||
@@ -41,6 +41,7 @@ using BetterGenshinImpact.GameTask.Common;
|
||||
using Compunet.YoloSharp;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.GameTask.AutoDomain.Assets;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoDomain;
|
||||
|
||||
@@ -94,7 +95,7 @@ public class AutoDomainTask : ISoloTask
|
||||
this.clickanywheretocloseLocalizedString = stringLocalizer.WithCultureGet(cultureInfo, "点击任意位置关闭");
|
||||
this.matchingChallengeString = stringLocalizer.WithCultureGet(cultureInfo, "匹配挑战");
|
||||
this.rapidformationString = stringLocalizer.WithCultureGet(cultureInfo, "快速编队");
|
||||
this.limitedFullyString = stringLocalizer.WithCultureGet(cultureInfo, "限时全开");
|
||||
this.limitedFullyString = stringLocalizer.WithCultureGet(cultureInfo, "限时全部开放");
|
||||
this.limitedFullyAllString = stringLocalizer.WithCultureGet(cultureInfo, "限时开放");
|
||||
}
|
||||
|
||||
@@ -207,8 +208,6 @@ public class AutoDomainTask : ISoloTask
|
||||
Logger.LogInformation("体力耗尽或者设置轮次已达标,结束自动秘境");
|
||||
break;
|
||||
}
|
||||
|
||||
Notify.Event(NotificationEvent.DomainReward).Success("自动秘境奖励领取");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +380,7 @@ public class AutoDomainTask : ISoloTask
|
||||
using var limitedFullyStringRa = CaptureToRectArea();
|
||||
var limitedFullyStringRaocrList =
|
||||
limitedFullyStringRa.FindMulti(RecognitionObject.Ocr(0, 0, limitedFullyStringRa.Width * 0.5,
|
||||
limitedFullyStringRa.Height));
|
||||
limitedFullyStringRa.Height * 0.5));
|
||||
var limitedFullyStringRaocrListdone = limitedFullyStringRaocrList.LastOrDefault(t =>
|
||||
Regex.IsMatch(t.Text, this.limitedFullyString) || Regex.IsMatch(t.Text, this.limitedFullyAllString));
|
||||
// 检测是否为限时全开秘境
|
||||
@@ -456,7 +455,7 @@ public class AutoDomainTask : ISoloTask
|
||||
// 点击单人挑战确认并等待队伍界面--使用图像模版匹配的方法,也可以使用文字OCR的方法识别“单人挑战”直到消失
|
||||
await NewRetry.WaitForElementAppear(
|
||||
ElementAssets.Instance.PartyBtnChooseView,
|
||||
async void () =>
|
||||
() =>
|
||||
{
|
||||
using var ra = CaptureToRectArea();
|
||||
var ra2 = ra.Find(fightAssets.ConfirmRa);
|
||||
@@ -1151,6 +1150,26 @@ public class AutoDomainTask : ISoloTask
|
||||
{
|
||||
if (record.RemainCount > 0)
|
||||
{
|
||||
if (record.Name == "原粹树脂20" || record.Name == "原粹树脂40")
|
||||
{
|
||||
int expectedNum = record.Name == "原粹树脂20" ? 20 : 40;
|
||||
bool switched;
|
||||
try
|
||||
{
|
||||
switched = SwitchOriginalResinType(expectedNum, _ct);
|
||||
}
|
||||
catch (RetryException)
|
||||
{
|
||||
Logger.LogWarning("自动秘境:切换原粹树脂类型重试超时,跳过 {Name}", record.Name);
|
||||
switched = false;
|
||||
}
|
||||
|
||||
if (!switched)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var (success, _) = PressUseResin(textListInPrompt2, record.Name);
|
||||
if (success)
|
||||
{
|
||||
@@ -1183,6 +1202,8 @@ public class AutoDomainTask : ISoloTask
|
||||
// 如果没有选择树脂的提示,说明只有原粹树脂
|
||||
// 继续向下执行
|
||||
}
|
||||
|
||||
Notify.Event(NotificationEvent.DomainReward).Success("自动秘境奖励领取");
|
||||
|
||||
Sleep(1000, _ct);
|
||||
|
||||
@@ -1258,6 +1279,11 @@ public class AutoDomainTask : ISoloTask
|
||||
|
||||
public static (bool, int) PressUseResin(List<Region> regionList, string resinName)
|
||||
{
|
||||
if (resinName == "原粹树脂20" || resinName == "原粹树脂40")
|
||||
{
|
||||
resinName = "原粹树脂";
|
||||
}
|
||||
|
||||
var resinKey = regionList.FirstOrDefault(t => t.Text.Contains(resinName));
|
||||
if (resinKey != null)
|
||||
{
|
||||
@@ -1293,6 +1319,46 @@ public class AutoDomainTask : ISoloTask
|
||||
return (false, 0);
|
||||
}
|
||||
|
||||
private bool SwitchOriginalResinType(int expectedNum, CancellationToken ct)
|
||||
{
|
||||
return NewRetry.Do(() =>
|
||||
{
|
||||
using var ra0 = CaptureToRectArea();
|
||||
var regionList = ra0.FindMulti(RecognitionObject.Ocr(ra0.Width * 0.25, ra0.Height * 0.2, ra0.Width * 0.5, ra0.Height * 0.6));
|
||||
var has20 = regionList.Any(t => t.Text.Contains("20"));
|
||||
var has40 = regionList.Any(t => t.Text.Contains("40"));
|
||||
if (expectedNum == 20 && has20)
|
||||
{
|
||||
Logger.LogInformation("自动秘境:已切换到使用20原粹树脂");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (expectedNum == 40 && has40)
|
||||
{
|
||||
Logger.LogInformation("自动秘境:已切换到使用40原粹树脂");
|
||||
return true;
|
||||
}
|
||||
|
||||
//切换20/40原粹树脂的按钮是亮的
|
||||
var clickable = ra0.Find(AutoDomainAssets.Instance.ResinSwitchBtnRo);
|
||||
if (clickable.IsExist())
|
||||
{
|
||||
Logger.LogDebug("自动秘境:切换原粹树脂使用数量");
|
||||
clickable.Click();
|
||||
}
|
||||
|
||||
//切换20/40原粹树脂的按钮是暗的
|
||||
var disabled = ra0.Find(AutoDomainAssets.Instance.ResinSwitchBtnNoActiveRo);
|
||||
if (disabled.IsExist())
|
||||
{
|
||||
Logger.LogWarning("自动秘境:切换原粹树脂的使用数量失败,可能是体力不足,当前目标:{Num}", expectedNum);
|
||||
return false; // 不可点击
|
||||
}
|
||||
|
||||
throw new RetryException("未检测到按钮"); // 继续重试
|
||||
}, TimeSpan.FromMilliseconds(500), 10);
|
||||
}
|
||||
|
||||
private static int GetResinNum(Region region, string resinName)
|
||||
{
|
||||
if (resinName == "原粹树脂")
|
||||
@@ -1335,7 +1401,7 @@ public class AutoDomainTask : ISoloTask
|
||||
return (region1Top <= region2Bottom && region1Bottom >= region2Top);
|
||||
}
|
||||
|
||||
private async Task ArtifactSalvage()
|
||||
private async Task ArtifactSalvage()
|
||||
{
|
||||
if (!_taskParam.AutoArtifactSalvage)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,14 @@ public class ResinUseRecord
|
||||
{
|
||||
list.Add(new ResinUseRecord("浓缩树脂", taskParam.CondensedResinUseCount));
|
||||
}
|
||||
if (taskParam.OriginalResin40UseCount > 0)
|
||||
{
|
||||
list.Add(new ResinUseRecord("原粹树脂40", taskParam.OriginalResin40UseCount));
|
||||
}
|
||||
if (taskParam.OriginalResin20UseCount > 0)
|
||||
{
|
||||
list.Add(new ResinUseRecord("原粹树脂20", taskParam.OriginalResin20UseCount));
|
||||
}
|
||||
if (taskParam.OriginalResinUseCount > 0)
|
||||
{
|
||||
list.Add(new ResinUseRecord("原粹树脂", taskParam.OriginalResinUseCount));
|
||||
@@ -54,7 +62,7 @@ public class ResinUseRecord
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ResinUseRecord> BuildFromDomainParam(AutoStygianOnslaughtConfig taskParam)
|
||||
public static List<ResinUseRecord> BuildFromDomainParam(AutoStygianOnslaughtParam taskParam)
|
||||
{
|
||||
List<ResinUseRecord> list = [];
|
||||
if (taskParam.SpecifyResinUse)
|
||||
|
||||
@@ -9,13 +9,12 @@ using BetterGenshinImpact.Service.Notification.Model.Enum;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using static Vanara.PInvoke.User32;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoEat;
|
||||
|
||||
/// <summary>
|
||||
/// 自动吃药触发器
|
||||
/// 检测红血状态时自动使用Recovery.png,检测到Resurrection.png时按z复活
|
||||
/// 检测红血状态时自动使用Recovery.png,检测到Resurrection.png时按快捷使用小道具键复活
|
||||
/// </summary>
|
||||
public class AutoEatTrigger : ITaskTrigger
|
||||
{
|
||||
@@ -94,8 +93,8 @@ public class AutoEatTrigger : ITaskTrigger
|
||||
// 检查复活CD(2秒)
|
||||
if ((now - _lastResurrectionTime).TotalSeconds >= 2)
|
||||
{
|
||||
// 按z键复活
|
||||
Simulation.SendInput.Keyboard.KeyPress(VK.VK_Z);
|
||||
// 走原神动作映射,跟随“快捷使用小道具”键位配置
|
||||
Simulation.SendInput.SimulateAction(GIActions.QuickUseGadget);
|
||||
_lastResurrectionTime = now;
|
||||
_logger.LogInformation("检测到复活图标,自动复活");
|
||||
}
|
||||
@@ -140,4 +139,4 @@ public class AutoEatTrigger : ITaskTrigger
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
@@ -1,8 +1,12 @@
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.GameTask.Model;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
@@ -45,6 +49,11 @@ public class AutoFightAssets : BaseAssets<AutoFightAssets>
|
||||
|
||||
public RecognitionObject AbnormalIconRa;
|
||||
|
||||
/// <summary>
|
||||
/// 经验值模板识别对象列表,用于检测怪物死亡时掉落的经验值数字图标
|
||||
/// </summary>
|
||||
public IReadOnlyList<RecognitionObject> ExperienceRecognitionObjects { get; private set; } = Array.Empty<RecognitionObject>();
|
||||
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑添加 "required" 修饰符或声明为可为 null。
|
||||
private AutoFightAssets() : base()
|
||||
{
|
||||
@@ -264,5 +273,56 @@ public class AutoFightAssets : BaseAssets<AutoFightAssets>
|
||||
RegionOfInterest = new Rect(0, (int)(CaptureRect.Height * 0.08), (int)(CaptureRect.Width * 0.04), (int)(CaptureRect.Height * 0.07)),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
|
||||
// 加载经验值模板图片(用于检测精英怪死亡时的经验值数字图标)
|
||||
try
|
||||
{
|
||||
LoadExperienceRecognitionObjects();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// 经验值模板加载失败不应阻止 AutoFightAssets 初始化
|
||||
ExperienceRecognitionObjects = Array.Empty<RecognitionObject>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载经验值模板图片,文件缺失时跳过,不影响其他功能
|
||||
/// </summary>
|
||||
private void LoadExperienceRecognitionObjects()
|
||||
{
|
||||
var experienceValues = new[] { 57, 58, 60 };
|
||||
var threshold = CaptureRect.Width > 1920 ? 0.6 : 0.9;
|
||||
var roi = new Rect(
|
||||
(int)(CaptureRect.Width * 0.145),
|
||||
(int)(CaptureRect.Height * 0.5),
|
||||
(int)(CaptureRect.Width * 0.02),
|
||||
(int)(CaptureRect.Height * 0.22));
|
||||
|
||||
var list = new List<RecognitionObject>();
|
||||
foreach (var exp in experienceValues)
|
||||
{
|
||||
var fileName = $"experience_{exp}.png";
|
||||
try
|
||||
{
|
||||
var ro = new RecognitionObject
|
||||
{
|
||||
Name = $"Experience_{exp}",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoFight", fileName, this.systemInfo),
|
||||
RegionOfInterest = roi,
|
||||
UseMask = true,
|
||||
Threshold = threshold,
|
||||
DrawOnWindow = true,
|
||||
}.InitTemplate();
|
||||
list.Add(ro);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// 构造阶段 Logger 可能不可用,静默跳过缺失的模板
|
||||
}
|
||||
}
|
||||
|
||||
ExperienceRecognitionObjects = list.AsReadOnly();
|
||||
}
|
||||
}
|
||||
@@ -2049,5 +2049,31 @@
|
||||
"nameEn": "Illuga",
|
||||
"skillCD": 15,
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [
|
||||
"法尔伽",
|
||||
"Varka",
|
||||
"团长",
|
||||
"法尔加"
|
||||
],
|
||||
"burstCD": 16,
|
||||
"id": "10000128",
|
||||
"name": "法尔伽",
|
||||
"nameEn": "Varka",
|
||||
"skillCD": 16,
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [
|
||||
"莉奈娅",
|
||||
"Linnea"
|
||||
],
|
||||
"burstCD": 15,
|
||||
"id": "10000130",
|
||||
"name": "莉奈娅",
|
||||
"nameEn": "Linnea",
|
||||
"skillCD": 18,
|
||||
"weapon": "10"
|
||||
}
|
||||
]
|
||||
@@ -157,6 +157,12 @@ public partial class AutoFightConfig : ObservableObject
|
||||
[ObservableProperty]
|
||||
private bool _swimmingEnabled = false;
|
||||
|
||||
/// <summary>
|
||||
/// 基于经验值判断是否执行战后拾取(检测到精英怪经验值图标时才拾取)
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _expBasedPickupEnabled = false;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗超时,单位秒
|
||||
/// </summary>
|
||||
|
||||
@@ -56,6 +56,7 @@ public class AutoFightParam : BaseTaskParam<AutoFightTask>
|
||||
RotaryFactor = autoFightConfig.FinishDetectConfig.RotaryFactor;
|
||||
QinDoublePickUp = autoFightConfig.QinDoublePickUp;
|
||||
SwimmingEnabled = autoFightConfig.SwimmingEnabled;
|
||||
ExpBasedPickupEnabled = autoFightConfig.ExpBasedPickupEnabled;
|
||||
}
|
||||
|
||||
public FightFinishDetectConfig FinishDetectConfig { get; set; } = new();
|
||||
@@ -84,6 +85,11 @@ public class AutoFightParam : BaseTaskParam<AutoFightTask>
|
||||
public bool QinDoublePickUp { get; set; } = false;
|
||||
public static bool SwimmingEnabled { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 基于经验值判断是否执行战后拾取
|
||||
/// </summary>
|
||||
public bool ExpBasedPickupEnabled { get; set; } = false;
|
||||
|
||||
public AutoFightParam(string? strategyName = null) : base(null, null)
|
||||
{
|
||||
SetCombatStrategyPath(strategyName);
|
||||
@@ -140,5 +146,6 @@ public class AutoFightParam : BaseTaskParam<AutoFightTask>
|
||||
GuardianAvatarHold = autoFightConfig.GuardianAvatarHold;
|
||||
SwimmingEnabled = autoFightConfig.SwimmingEnabled;
|
||||
QinDoublePickUp = autoFightConfig.QinDoublePickUp;
|
||||
ExpBasedPickupEnabled = autoFightConfig.ExpBasedPickupEnabled;
|
||||
}
|
||||
}
|
||||
@@ -461,7 +461,7 @@ namespace BetterGenshinImpact.GameTask.AutoFight
|
||||
{
|
||||
while (attempt < retryCount)
|
||||
{
|
||||
if (guardianAvatar.TrySwitch(10, false))
|
||||
if (guardianAvatar.TrySwitch(10))
|
||||
{
|
||||
guardianAvatar.ManualSkillCd = -1;
|
||||
if (await AvatarSkillAsync(Logger, guardianAvatar, false, 1, ct))
|
||||
@@ -550,7 +550,7 @@ namespace BetterGenshinImpact.GameTask.AutoFight
|
||||
Logger.LogInformation("优先第 {text} 盾奶位 {GuardianAvatar} 元素爆发状态:{attempt},尝试释放",
|
||||
guardianAvatarName, guardianAvatar.Name, "就绪");
|
||||
|
||||
if (guardianAvatar.TrySwitch(8, false))
|
||||
if (guardianAvatar.TrySwitch(8))
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalBurst);
|
||||
Sleep(500, ct);
|
||||
|
||||
@@ -25,6 +25,7 @@ using BetterGenshinImpact.GameTask.AutoPick.Assets;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
@@ -299,6 +300,16 @@ public class AutoFightTask : ISoloTask
|
||||
|
||||
AutoFightSeek.RotationCount= 0; // 重置旋转次数
|
||||
|
||||
// 基于经验值的战后拾取检测:在战斗过程中异步检测精英怪经验值图标
|
||||
// 仅在万叶拾取总开关开启时才启动经验值检测
|
||||
ExperienceDetector? expDetector = null;
|
||||
if (_taskParam.KazuhaPickupEnabled && _taskParam.ExpBasedPickupEnabled)
|
||||
{
|
||||
var expRos = AutoFightAssets.Instance.ExperienceRecognitionObjects;
|
||||
expDetector = new ExperienceDetector(expRos, cts2.Token);
|
||||
expDetector.Start();
|
||||
}
|
||||
|
||||
// 战斗操作
|
||||
var fightTask = Task.Run(async () =>
|
||||
{
|
||||
@@ -418,7 +429,7 @@ public class AutoFightTask : ISoloTask
|
||||
fightEndFlag = await CheckFightFinish(delayTime, detectDelayTime);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
command.Execute(combatScenes, lastCommand);
|
||||
//统计战斗人次
|
||||
if (i == combatCommands.Count - 1 || command.Name != combatCommands[i + 1].Name)
|
||||
@@ -426,6 +437,13 @@ public class AutoFightTask : ISoloTask
|
||||
countFight++;
|
||||
}
|
||||
|
||||
#region check动作触发战斗结束检测
|
||||
if (command.Method == Method.Check)
|
||||
{
|
||||
fightEndFlag = await CheckFightFinish(delayTime, detectDelayTime);
|
||||
}
|
||||
#endregion
|
||||
|
||||
lastFightName = command.Name;
|
||||
if (!fightEndFlag && _taskParam is { FightFinishDetectEnabled: true })
|
||||
{
|
||||
@@ -482,6 +500,50 @@ public class AutoFightTask : ISoloTask
|
||||
}, cts2.Token);
|
||||
|
||||
await fightTask;
|
||||
|
||||
try
|
||||
{
|
||||
// 基于经验值检测结果的拾取判断
|
||||
if (_taskParam.KazuhaPickupEnabled && _taskParam.ExpBasedPickupEnabled && expDetector != null)
|
||||
{
|
||||
// 战斗结束与怪物死亡可能几乎同时发生,检测器可能还没来得及捕获经验值图标
|
||||
// 保持检测器运行,每 100ms 轮询一次结果,最多等待 1.1 秒
|
||||
if (!expDetector.HasDetectedExperience)
|
||||
{
|
||||
Logger.LogInformation("基于经验值判断:等待经验值检测结果");
|
||||
var waitMs = 1100;
|
||||
while (!expDetector.HasDetectedExperience && waitMs > 0)
|
||||
{
|
||||
await Delay(100, ct);
|
||||
waitMs -= 100;
|
||||
}
|
||||
}
|
||||
|
||||
await expDetector.StopAsync();
|
||||
var shouldPickup = expDetector.HasDetectedExperience;
|
||||
Logger.LogInformation("基于经验值判断:{Result} 战后拾取", shouldPickup ? "执行" : "不执行");
|
||||
|
||||
if (!shouldPickup)
|
||||
{
|
||||
// 经验值检测未通过,跳过拾取(但仍执行扫描拾取逻辑)
|
||||
if (_taskParam is { PickDropsAfterFightEnabled: true })
|
||||
{
|
||||
await new ScanPickTask().Start(ct);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// 确保检测器在任何路径(异常/取消/正常)都被停止和释放
|
||||
if (expDetector != null)
|
||||
{
|
||||
await expDetector.StopAsync();
|
||||
expDetector.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
if (_taskParam.BattleThresholdForLoot>=2 && countFight < _taskParam.BattleThresholdForLoot)
|
||||
{
|
||||
Logger.LogInformation($"战斗人次({countFight})低于配置人次({_taskParam.BattleThresholdForLoot}),跳过此次拾取!");
|
||||
@@ -520,60 +582,62 @@ public class AutoFightTask : ISoloTask
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await Delay(1000, ct);
|
||||
|
||||
//等待寻找2秒队伍按钮出现
|
||||
var timeWaitStart = 0;
|
||||
while(timeWaitStart < 6000)
|
||||
{
|
||||
using var ra = CaptureToRectArea();
|
||||
var partyViewBtn = ra.Find(ElementAssets.Instance.PartyBtnChooseView);
|
||||
if (partyViewBtn.IsExist())
|
||||
|
||||
if (!string.IsNullOrEmpty(_taskParam.KazuhaPartyName)){
|
||||
await Delay(1000, ct);
|
||||
|
||||
//等待寻找2秒队伍按钮出现
|
||||
var timeWaitStart = 0;
|
||||
while(timeWaitStart < 6000)
|
||||
{
|
||||
// OCR 当前队伍名称(无法单字,中间禁止空格)
|
||||
// 读取OCR原始识别文本
|
||||
var rawPartyName = ra.Find(new RecognitionObject
|
||||
{
|
||||
RecognitionType = RecognitionTypes.Ocr,
|
||||
RegionOfInterest = new Rect(partyViewBtn.Right, partyViewBtn.Top, (int)(350 * _assetScale),
|
||||
partyViewBtn.Height)
|
||||
}).Text;
|
||||
|
||||
// 核心处理逻辑:1.空值兜底 2.去首尾空白 3.移除末尾的“口”字(仅最后一个是口才删)
|
||||
if (string.IsNullOrWhiteSpace(rawPartyName))
|
||||
{
|
||||
oldPartyName = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
//有概率把编辑图标识别为字符,并且含有空格或换行符,需要过滤
|
||||
var tempName = rawPartyName
|
||||
.Replace("\"", "") // 移除所有双引号(核心新增,解决日志里的""问题)
|
||||
.Replace("\r\n", "") // 清理Windows换行符
|
||||
.Replace("\r", ""); // 先清理所有双引号,避免引号干扰后续处理
|
||||
|
||||
// 核心逻辑:找到第一个换行符(\n)的位置,截断并删除换行+后面所有字符
|
||||
int firstNewLineIndex = tempName.IndexOf('\n');
|
||||
if (firstNewLineIndex != -1) // 存在换行符,截取到换行符前
|
||||
{
|
||||
tempName = tempName.Substring(0, firstNewLineIndex);
|
||||
}
|
||||
|
||||
// 最后统一去首尾所有空白(空格、制表符、回车符\r等),得到纯净队伍名
|
||||
oldPartyName = tempName.Trim();
|
||||
}
|
||||
|
||||
// 后续原有逻辑不变
|
||||
Logger.LogInformation("换队拾取:当前队伍名称读取为:{oldPartyName}", oldPartyName);
|
||||
// 加在rawPartyName赋值后,打印原始文本的“原始形态”(转义符会显示)
|
||||
Logger.LogDebug("OCR原始识别文本(含转义):{rawPartyName}", rawPartyName);
|
||||
RunnerContext.Instance.PartyName = oldPartyName;
|
||||
// await _returnMainUiTask.Start(ct);
|
||||
break;
|
||||
using var ra = CaptureToRectArea();
|
||||
var partyViewBtn = ra.Find(ElementAssets.Instance.PartyBtnChooseView);
|
||||
if (partyViewBtn.IsExist())
|
||||
{
|
||||
// OCR 当前队伍名称(无法单字,中间禁止空格)
|
||||
// 读取OCR原始识别文本
|
||||
var rawPartyName = ra.Find(new RecognitionObject
|
||||
{
|
||||
RecognitionType = RecognitionTypes.Ocr,
|
||||
RegionOfInterest = new Rect(partyViewBtn.Right, partyViewBtn.Top, (int)(350 * _assetScale),
|
||||
partyViewBtn.Height)
|
||||
}).Text;
|
||||
|
||||
// 核心处理逻辑:1.空值兜底 2.去首尾空白 3.移除末尾的“口”字(仅最后一个是口才删)
|
||||
if (string.IsNullOrWhiteSpace(rawPartyName))
|
||||
{
|
||||
oldPartyName = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
//有概率把编辑图标识别为字符,并且含有空格或换行符,需要过滤
|
||||
var tempName = rawPartyName
|
||||
.Replace("\"", "") // 移除所有双引号(核心新增,解决日志里的""问题)
|
||||
.Replace("\r\n", "") // 清理Windows换行符
|
||||
.Replace("\r", ""); // 先清理所有双引号,避免引号干扰后续处理
|
||||
|
||||
// 核心逻辑:找到第一个换行符(\n)的位置,截断并删除换行+后面所有字符
|
||||
int firstNewLineIndex = tempName.IndexOf('\n');
|
||||
if (firstNewLineIndex != -1) // 存在换行符,截取到换行符前
|
||||
{
|
||||
tempName = tempName.Substring(0, firstNewLineIndex);
|
||||
}
|
||||
|
||||
// 最后统一去首尾所有空白(空格、制表符、回车符\r等),得到纯净队伍名
|
||||
oldPartyName = tempName.Trim();
|
||||
}
|
||||
|
||||
// 后续原有逻辑不变
|
||||
Logger.LogInformation("换队拾取:当前队伍名称读取为:{oldPartyName}", oldPartyName);
|
||||
// 加在rawPartyName赋值后,打印原始文本的“原始形态”(转义符会显示)
|
||||
Logger.LogDebug("OCR原始识别文本(含转义):{rawPartyName}", rawPartyName);
|
||||
RunnerContext.Instance.PartyName = oldPartyName;
|
||||
// await _returnMainUiTask.Start(ct);
|
||||
break;
|
||||
}
|
||||
await Delay(200, ct);
|
||||
timeWaitStart += 200;
|
||||
}
|
||||
await Delay(200, ct);
|
||||
timeWaitStart += 200;
|
||||
}
|
||||
|
||||
var switchPartyFlag = false;
|
||||
@@ -605,7 +669,12 @@ public class AutoFightTask : ISoloTask
|
||||
if (picker.Name == "枫原万叶")
|
||||
{
|
||||
var time = TimeSpan.FromSeconds(picker.GetSkillCdSeconds());
|
||||
if (!(lastFightName == picker.Name && time.TotalSeconds > 3))
|
||||
|
||||
// 如果配置了二次拾取,或者不满足跳过条件(上次是万叶且冷却时间>3秒),则执行拾取
|
||||
bool shouldSkip = lastFightName == picker.Name && time.TotalSeconds > 3;
|
||||
bool forcePickup = _taskParam.QinDoublePickUp;
|
||||
|
||||
if (forcePickup || !shouldSkip)
|
||||
{
|
||||
Logger.LogInformation("使用 枫原万叶-长E 拾取掉落物");
|
||||
await Delay(200, ct);
|
||||
@@ -722,7 +791,7 @@ public class AutoFightTask : ISoloTask
|
||||
|
||||
if (_taskParam is { PickDropsAfterFightEnabled: true } )
|
||||
{
|
||||
// 执行自动拾取掉落物的功能
|
||||
// 执行扫描掉落物光柱并靠近的功能
|
||||
await new ScanPickTask().Start(ct);
|
||||
}
|
||||
}
|
||||
@@ -895,4 +964,4 @@ public class AutoFightTask : ISoloTask
|
||||
// // 要大于 gadgetMat 的 1/2
|
||||
// return list.Any(r => r.Width > gadgetMat.Width / 2 && r.Height > gadgetMat.Height / 2);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
/// <summary>
|
||||
/// 经验值检测器:在战斗过程中异步检测屏幕上怪物死亡时掉落的经验值数字图标,
|
||||
/// 用于判断是否有精英怪被击杀,从而决定战后是否执行拾取。
|
||||
/// </summary>
|
||||
public sealed class ExperienceDetector : IDisposable
|
||||
{
|
||||
private static readonly ILogger Logger = TaskControl.Logger;
|
||||
|
||||
/// <summary>
|
||||
/// 经验值图标左侧特征像素的水平偏移量(相对于模板匹配位置)
|
||||
/// </summary>
|
||||
private const int ExpIconPixelOffsetX = -147;
|
||||
|
||||
/// <summary>
|
||||
/// 经验值图标特征颜色 BGR 范围(用于二次验证模板匹配结果)
|
||||
/// </summary>
|
||||
private static readonly Vec3b ExpColorMin = new(200, 200, 150);
|
||||
private static readonly Vec3b ExpColorMax = new(255, 255, 200);
|
||||
|
||||
/// <summary>
|
||||
/// 检测循环间隔(毫秒)
|
||||
/// </summary>
|
||||
private const int DetectionIntervalMs = 100;
|
||||
|
||||
private readonly IReadOnlyList<RecognitionObject> _experienceRos;
|
||||
private readonly CancellationTokenSource _linkedCts;
|
||||
private readonly TaskCompletionSource<bool> _resultTcs;
|
||||
private Task? _detectionTask;
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>
|
||||
/// 获取检测结果:是否检测到经验值图标
|
||||
/// </summary>
|
||||
public bool HasDetectedExperience =>
|
||||
_resultTcs.Task.IsCompletedSuccessfully && _resultTcs.Task.Result;
|
||||
|
||||
public ExperienceDetector(
|
||||
IReadOnlyList<RecognitionObject> experienceRos,
|
||||
CancellationToken externalToken)
|
||||
{
|
||||
_experienceRos = experienceRos ?? throw new ArgumentNullException(nameof(experienceRos));
|
||||
_linkedCts = CancellationTokenSource.CreateLinkedTokenSource(externalToken);
|
||||
_resultTcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动后台经验值检测循环
|
||||
/// </summary>
|
||||
public void
|
||||
Start()
|
||||
{
|
||||
if (_experienceRos.Count == 0)
|
||||
{
|
||||
Logger.LogWarning("经验值检测:无可用模板,跳过检测");
|
||||
return;
|
||||
}
|
||||
|
||||
_detectionTask = Task.Run(() => DetectionLoop(_linkedCts.Token), _linkedCts.Token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止检测并等待后台任务结束
|
||||
/// </summary>
|
||||
public async Task StopAsync()
|
||||
{
|
||||
_linkedCts.Cancel();
|
||||
if (_detectionTask != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _detectionTask.ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// 正常取消,忽略
|
||||
}
|
||||
}
|
||||
|
||||
// 确保结果有值(未检测到时设为 false)
|
||||
_resultTcs.TrySetResult(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 后台检测循环:截屏 → 模板匹配 → 像素颜色验证
|
||||
/// </summary>
|
||||
private void DetectionLoop(CancellationToken ct)
|
||||
{
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var capture = TaskControl.CaptureToRectArea();
|
||||
|
||||
foreach (var ro in _experienceRos)
|
||||
{
|
||||
ct.ThrowIfCancellationRequested();
|
||||
|
||||
var matchResult = capture.Find(ro);
|
||||
if (!matchResult.IsExist())
|
||||
continue;
|
||||
|
||||
// 模板匹配成功,执行像素颜色二次验证
|
||||
if (ValidateExpPixelColor(capture, matchResult))
|
||||
{
|
||||
Logger.LogInformation("基于经验值判断:检测到 {Name} 经验值图标,启用战后拾取", ro.Name.Replace("Experience_", ""));
|
||||
_resultTcs.TrySetResult(true);
|
||||
return; // 检测到后退出循环
|
||||
}
|
||||
}
|
||||
|
||||
// 短暂等待后继续下一轮检测
|
||||
Thread.Sleep(DetectionIntervalMs);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "经验值检测循环中发生异常,继续下一轮");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 像素颜色验证:检查匹配位置左侧偏移处的像素是否符合经验值图标特征色
|
||||
/// </summary>
|
||||
private static bool ValidateExpPixelColor(ImageRegion capture, Region matchResult)
|
||||
{
|
||||
var checkX = matchResult.X + ExpIconPixelOffsetX;
|
||||
var checkY = matchResult.Y;
|
||||
|
||||
// 边界检查
|
||||
if (checkX < 0 || checkX >= capture.SrcMat.Cols || checkY < 0 || checkY >= capture.SrcMat.Rows)
|
||||
return false;
|
||||
|
||||
var pixel = capture.SrcMat.At<Vec3b>(checkY, checkX);
|
||||
return pixel[0] >= ExpColorMin[0] && pixel[0] <= ExpColorMax[0] // B
|
||||
&& pixel[1] >= ExpColorMin[1] && pixel[1] <= ExpColorMax[1] // G
|
||||
&& pixel[2] >= ExpColorMin[2] && pixel[2] <= ExpColorMax[2]; // R
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
_disposed = true;
|
||||
|
||||
_linkedCts.Cancel();
|
||||
_linkedCts.Dispose();
|
||||
_resultTcs.TrySetResult(false);
|
||||
_detectionTask = null;
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,19 @@ public class Avatar
|
||||
/// 战斗场景
|
||||
/// </summary>
|
||||
public CombatScenes CombatScenes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 脱困方向数组(前/后/左/右)
|
||||
/// </summary>
|
||||
private static readonly GIActions[] UnstuckDirections =
|
||||
{
|
||||
GIActions.MoveForward,
|
||||
GIActions.MoveBackward,
|
||||
GIActions.MoveLeft,
|
||||
GIActions.MoveRight
|
||||
};
|
||||
|
||||
private static readonly Random UnstuckRandom = new();
|
||||
|
||||
|
||||
public Avatar(CombatScenes combatScenes, string name, int index, Rect nameRect, double manualSkillCd = -1)
|
||||
@@ -175,8 +188,9 @@ public class Avatar
|
||||
/// </summary>
|
||||
private static bool SwimmingConfirm(Region region)
|
||||
{
|
||||
using var mask = OpenCvCommonHelper.Threshold(region.ToImageRegion().DeriveCrop(1819, 1025, 9, 11).SrcMat,
|
||||
new Scalar(242, 223, 39),new Scalar(255, 233, 44));
|
||||
using var imageRegion = region.ToImageRegion();
|
||||
using var cropped = imageRegion.DeriveCrop(1819, 1025, 9, 11);
|
||||
using var mask = OpenCvCommonHelper.Threshold(cropped.SrcMat, new Scalar(242, 223, 39), new Scalar(255, 233, 44));
|
||||
using var labels = new Mat();
|
||||
using var stats = new Mat();
|
||||
using var centroids = new Mat();
|
||||
@@ -228,6 +242,13 @@ public class Avatar
|
||||
SimulateSwitchAction(Index);
|
||||
// Debug.WriteLine($"切换到{Index}号位");
|
||||
// Cv2.ImWrite($"log/切换.png", region.SrcMat);
|
||||
|
||||
// 第13次重试时,战斗状态下执行脱困动作
|
||||
if (i == 10 && AutoFightTask.FightStatusFlag)
|
||||
{
|
||||
PerformUnstuckAction(Ct);
|
||||
}
|
||||
|
||||
Sleep(250, Ct);
|
||||
}
|
||||
}
|
||||
@@ -238,7 +259,7 @@ public class Avatar
|
||||
/// <param name="tryTimes"></param>
|
||||
/// <param name="needLog"></param>
|
||||
/// <returns></returns>
|
||||
public bool TrySwitch(int tryTimes = 4, bool needLog = true)
|
||||
public bool TrySwitch(int tryTimes = 4)
|
||||
{
|
||||
var context = new AvatarActiveCheckContext();
|
||||
for (var i = 0; i < tryTimes; i++)
|
||||
@@ -254,14 +275,23 @@ public class Avatar
|
||||
// 切换成功
|
||||
if (CombatScenes.GetActiveAvatarIndex(region, context) == Index)
|
||||
{
|
||||
// if (needLog && i > 0)
|
||||
// {
|
||||
// Logger.LogInformation("成功切换角色:{Name}", Name);
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (i == tryTimes - 1 && tryTimes == 4) //默认状态,没有特意设置重试次数的情况下,最后一次重试失败才输出日志
|
||||
{
|
||||
Logger.LogWarning("切换角色失败,最后一次尝试,当前角色编号:{CurrentIndex},期望角色编号:{ExpectedIndex}", CombatScenes.GetActiveAvatarIndex(region, context), Index);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 特意需要脱困情形下,会设置重试次数激活脱困检测,第10次重试时(2.5秒切换失败,超过角色的大招动画时间),如在盾奶位功能中次数会到第十次。
|
||||
if (i == 9 && AutoFightTask.FightStatusFlag)
|
||||
{
|
||||
PerformUnstuckAction(Ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SimulateSwitchAction(Index);
|
||||
|
||||
@@ -298,6 +328,23 @@ public class Avatar
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 战斗中切换角色卡住时的脱困动作:跳跃 → 随机方向移动+切换 → 攻击 → 释放按键
|
||||
/// </summary>
|
||||
private void PerformUnstuckAction(CancellationToken ct)
|
||||
{
|
||||
var direction = UnstuckDirections[UnstuckRandom.Next(4)];
|
||||
Logger.LogWarning("切换角色卡住,执行脱困(方向:{Dir})", direction);
|
||||
|
||||
Simulation.SendInput.SimulateAction(GIActions.Jump);
|
||||
Sleep(200, ct);
|
||||
Simulation.SendInput.SimulateAction(direction, KeyType.KeyDown);
|
||||
SimulateSwitchAction(Index);
|
||||
Sleep(1000, ct);
|
||||
Simulation.SendInput.SimulateAction(GIActions.NormalAttack);
|
||||
Simulation.ReleaseAllKey();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换到本角色
|
||||
/// 切换cd是1秒,如果切换失败,会尝试再次切换,最多尝试5次
|
||||
@@ -637,7 +684,7 @@ public class Avatar
|
||||
/// </summary>
|
||||
public void Ready()
|
||||
{
|
||||
Sleep(200, Ct);
|
||||
Sleep(10, Ct);
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
|
||||
@@ -177,6 +177,48 @@ public class CombatScenes : IDisposable
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 静默模式下的队伍识别(用于后台挂件)
|
||||
/// </summary>
|
||||
public CombatScenes InitializeTeamSilent(ImageRegion imageRegion, AutoFightConfig? autoFightConfig = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (autoFightConfig == null)
|
||||
{
|
||||
autoFightConfig = TaskContext.Instance().Config.AutoFightConfig;
|
||||
}
|
||||
|
||||
// 优先取配置
|
||||
if (!string.IsNullOrEmpty(autoFightConfig.TeamNames))
|
||||
{
|
||||
InitializeTeamFromConfig(autoFightConfig.TeamNames, autoFightConfig);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 使用 NullLogger 彻底屏蔽底层工具类的日志输出
|
||||
var nullLogger = Microsoft.Extensions.Logging.Abstractions.NullLogger.Instance;
|
||||
|
||||
CurrentMultiGameStatus = PartyAvatarSideIndexHelper.DetectedMultiGameStatus(imageRegion, _autoFightAssets, nullLogger);
|
||||
var (avatarIndexRectList, avatarSideIconRectList) = PartyAvatarSideIndexHelper.GetAllIndexRects(imageRegion, CurrentMultiGameStatus, nullLogger, _elementAssets, _systemInfo);
|
||||
ExpectedTeamAvatarNum = avatarIndexRectList.Count;
|
||||
|
||||
var names = new string[avatarSideIconRectList.Count];
|
||||
for (var i = 0; i < avatarSideIconRectList.Count; i++)
|
||||
{
|
||||
using var ra = imageRegion.DeriveCrop(avatarSideIconRectList[i]);
|
||||
var pair = ClassifyAvatarCnName(ra.CacheImage, i + 1);
|
||||
names[i] = pair.Item1;
|
||||
}
|
||||
Avatars = BuildAvatars([.. names], null, avatarIndexRectList, autoFightConfig);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 静默模式下完全不抛出、不记录异常
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 这个个方法主要用于在切人判断有误的情况下,且能够找到预期数量的角色编号框。此时只有两种情况
|
||||
|
||||
@@ -407,7 +407,8 @@ public class PartyAvatarSideIndexHelper
|
||||
// 方法3:使用更加靠谱的差值识别(-1是未识别),但是不支持非满队
|
||||
if (mats.Length == 4)
|
||||
{
|
||||
return ImageDifferenceDetector.FindMostDifferentImage(mats);
|
||||
var result = ImageDifferenceDetector.FindMostDifferentImage(mats);
|
||||
return result >= 0 ? result + 1 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -108,7 +108,8 @@ public class CombatCommand
|
||||
&& Method != Method.KeyDown
|
||||
&& Method != Method.KeyUp
|
||||
&& Method != Method.KeyPress
|
||||
&& Method != Method.Scroll)
|
||||
&& Method != Method.Scroll
|
||||
&& Method != Method.Ready)
|
||||
{
|
||||
avatar.Switch();
|
||||
}
|
||||
@@ -202,6 +203,10 @@ public class CombatCommand
|
||||
{
|
||||
avatar.Ready();
|
||||
}
|
||||
else if (Method == Method.Check)
|
||||
{
|
||||
// check动作在AutoFightTask主循环中处理,此处不做任何操作
|
||||
}
|
||||
else if (Method == Method.Aim)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -13,6 +13,7 @@ public class Method
|
||||
public static readonly Method Charge = new(["charge", "重击"]);
|
||||
public static readonly Method Wait = new(["wait", "after", "等待"]);
|
||||
public static readonly Method Ready = new(["ready", "完成"]);
|
||||
public static readonly Method Check = new(["check", "检测"]);
|
||||
|
||||
public static readonly Method Walk = new(["walk", "行走"]);
|
||||
public static readonly Method W = new(["w"]);
|
||||
@@ -45,6 +46,7 @@ public class Method
|
||||
yield return Charge;
|
||||
yield return Wait;
|
||||
yield return Ready;
|
||||
yield return Check;
|
||||
|
||||
yield return Walk;
|
||||
yield return W;
|
||||
|
||||
@@ -391,6 +391,9 @@ namespace BetterGenshinImpact.GameTask.AutoFishing
|
||||
clickWhiteConfirmButtonWaitEndTime < timeProvider.GetLocalNow()) &&
|
||||
Bv.ClickWhiteConfirmButton(imageRegion))
|
||||
{
|
||||
// 截取鱼饵图标区域(正方形,宽高均取 6.5% 的屏幕宽度)
|
||||
// 最后一个参数有意用 Width 而非 Height,目的是保持正方形裁剪
|
||||
// 经验算在 16:9 常见分辨率(720p/1080p/1440p)下 Y+H 不会超出图像高度,暂不加钳位
|
||||
using Mat subMat = imageRegion.SrcMat.SubMat(new Rect((int)(0.824 * imageRegion.Width), (int)(0.669 * imageRegion.Height), (int)(0.065 * imageRegion.Width), (int)(0.065 * imageRegion.Width)));
|
||||
using Mat resized = subMat.Resize(new Size(125, 125));
|
||||
(string predName, _) = GridIconsAccuracyTestTask.Infer(resized, this.session, this.prototypes);
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing
|
||||
|
||||
// 寻找鱼饵
|
||||
var boxAndBaits = FindBait(imageRegion);
|
||||
;
|
||||
|
||||
foreach ((Rect box, string? predName) in boxAndBaits)
|
||||
{
|
||||
if (predName == blackboard.selectedBait.GetDescription())
|
||||
@@ -201,6 +201,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing
|
||||
}
|
||||
else
|
||||
{
|
||||
blackboard.Sleep(200);
|
||||
return BehaviourStatus.Running;
|
||||
}
|
||||
}
|
||||
@@ -857,8 +858,13 @@ namespace BetterGenshinImpact.GameTask.AutoFishing
|
||||
}
|
||||
|
||||
int hExtra = _cur.Height, vExtra = _cur.Height / 4;
|
||||
blackboard.fishBoxRect = new Rect(_cur.X - hExtra, _cur.Y - vExtra,
|
||||
(topMat.Width / 2 - _cur.X) * 2 + hExtra * 2, _cur.Height + vExtra * 2);
|
||||
{
|
||||
int rx = _cur.X - hExtra;
|
||||
int ry = _cur.Y - vExtra;
|
||||
int rw = (topMat.Width / 2 - _cur.X) * 2 + hExtra * 2;
|
||||
int rh = _cur.Height + vExtra * 2;
|
||||
blackboard.fishBoxRect = new Rect(rx, ry, rw, rh).ClampTo(imageRegion.SrcMat);
|
||||
}
|
||||
using var boxRa = imageRegion.Derive(blackboard.fishBoxRect);
|
||||
boxRa.DrawSelf("FishBox", System.Drawing.Pens.LightPink);
|
||||
logger.LogInformation(" 识别到钓鱼框");
|
||||
|
||||
@@ -1001,7 +1001,7 @@
|
||||
"nameEn": "escoffier",
|
||||
"type": "character",
|
||||
"name": "爱可菲",
|
||||
"hp": 11,
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "冰元素",
|
||||
"weapon": "长柄武器",
|
||||
@@ -1073,12 +1073,160 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1116,
|
||||
"nameEn": "skirk",
|
||||
"type": "character",
|
||||
"name": "丝柯克",
|
||||
"hp": 10,
|
||||
"energy": 0,
|
||||
"element": "冰元素",
|
||||
"weapon": "单手剑",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "havoc_sunder",
|
||||
"name": "极恶技·断",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1101,
|
||||
"nameEn": "cryo",
|
||||
"type": "冰元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "havoc_warp",
|
||||
"name": "极恶技·闪",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1101,
|
||||
"nameEn": "cryo",
|
||||
"type": "冰元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "havoc_ruin",
|
||||
"name": "极恶技·灭",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1101,
|
||||
"nameEn": "cryo",
|
||||
"type": "冰元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "reason_beyond_reason",
|
||||
"name": "理外之理",
|
||||
"skillTag": [
|
||||
"被动技能"
|
||||
],
|
||||
"cost": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1117,
|
||||
"nameEn": "mika",
|
||||
"type": "character",
|
||||
"name": "米卡",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "冰元素",
|
||||
"weapon": "长柄武器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "spear_of_favonius_arrows_passage",
|
||||
"name": "西风枪术·镝传",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1101,
|
||||
"nameEn": "cryo",
|
||||
"type": "冰元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "starfrost_swirl",
|
||||
"name": "星霜的流旋",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1101,
|
||||
"nameEn": "cryo",
|
||||
"type": "冰元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "skyfeather_song",
|
||||
"name": "苍翎的颂愿",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1101,
|
||||
"nameEn": "cryo",
|
||||
"type": "冰元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "suppressive_barrage",
|
||||
"name": "速射牵制",
|
||||
"skillTag": [
|
||||
"被动技能"
|
||||
],
|
||||
"cost": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1201,
|
||||
"nameEn": "barbara",
|
||||
"type": "character",
|
||||
"name": "芭芭拉",
|
||||
"hp": 10,
|
||||
"hp": 12,
|
||||
"energy": 3,
|
||||
"element": "水元素",
|
||||
"weapon": "法器",
|
||||
@@ -1646,7 +1794,7 @@
|
||||
"nameEn": "yelan",
|
||||
"type": "character",
|
||||
"name": "夜兰",
|
||||
"hp": 10,
|
||||
"hp": 11,
|
||||
"energy": 3,
|
||||
"element": "水元素",
|
||||
"weapon": "弓",
|
||||
@@ -2010,6 +2158,152 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1215,
|
||||
"nameEn": "dahlia",
|
||||
"type": "character",
|
||||
"name": "塔利雅",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "水元素",
|
||||
"weapon": "单手剑",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "favonius_bladework_ritual",
|
||||
"name": "西风剑术·祭仪",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1102,
|
||||
"nameEn": "hydro",
|
||||
"type": "水元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "immersive_ordinance",
|
||||
"name": "圣浸的礼典",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1102,
|
||||
"nameEn": "hydro",
|
||||
"type": "水元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "radiant_psalter",
|
||||
"name": "纯耀的祷咏",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1102,
|
||||
"nameEn": "hydro",
|
||||
"type": "水元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1216,
|
||||
"nameEn": "aino",
|
||||
"type": "character",
|
||||
"name": "爱诺",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "水元素",
|
||||
"weapon": "双手剑",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "bishbashbosh_repair",
|
||||
"name": "敲打修理法",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1102,
|
||||
"nameEn": "hydro",
|
||||
"type": "水元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "musecatcher",
|
||||
"name": "妙思捕手",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1102,
|
||||
"nameEn": "hydro",
|
||||
"type": "水元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "precision_hydronic_cooler",
|
||||
"name": "精密水冷仪",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1102,
|
||||
"nameEn": "hydro",
|
||||
"type": "水元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "modular_efficiency_protocol",
|
||||
"name": "模块式高效运作",
|
||||
"skillTag": [
|
||||
"被动技能"
|
||||
],
|
||||
"cost": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1301,
|
||||
"nameEn": "diluc",
|
||||
@@ -4299,6 +4593,83 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1417,
|
||||
"nameEn": "ineffa",
|
||||
"type": "character",
|
||||
"name": "伊涅芙",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "雷元素",
|
||||
"weapon": "长柄武器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "cyclonic_duster",
|
||||
"name": "除尘旋刃",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1104,
|
||||
"nameEn": "electro",
|
||||
"type": "雷元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "cleaning_mode_carrier_frequency",
|
||||
"name": "涤净模式·稳态载频",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1104,
|
||||
"nameEn": "electro",
|
||||
"type": "雷元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "supreme_instruction_cyclonic_exterminator",
|
||||
"name": "至高律令·全域扫灭",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1104,
|
||||
"nameEn": "electro",
|
||||
"type": "雷元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "moonsign_benediction_assemblage_hub",
|
||||
"name": "月兆祝赐·象拟中继",
|
||||
"skillTag": [
|
||||
"被动技能"
|
||||
],
|
||||
"cost": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1501,
|
||||
"nameEn": "sucrose",
|
||||
@@ -7388,7 +7759,7 @@
|
||||
"nameEn": "alldevouring_narwhal",
|
||||
"type": "character",
|
||||
"name": "吞星之鲸",
|
||||
"hp": 5,
|
||||
"hp": 6,
|
||||
"energy": 2,
|
||||
"element": "水元素",
|
||||
"weapon": "其他武器",
|
||||
@@ -7534,7 +7905,7 @@
|
||||
"nameEn": "hydro_tulpa",
|
||||
"type": "character",
|
||||
"name": "水形幻人",
|
||||
"hp": 11,
|
||||
"hp": 10,
|
||||
"energy": 3,
|
||||
"element": "水元素",
|
||||
"weapon": "其他武器",
|
||||
@@ -7688,7 +8059,7 @@
|
||||
"nameEn": "fatui_pyro_agent",
|
||||
"type": "character",
|
||||
"name": "愚人众·火之债务处理人",
|
||||
"hp": 9,
|
||||
"hp": 11,
|
||||
"energy": 2,
|
||||
"element": "火元素",
|
||||
"weapon": "其他武器",
|
||||
@@ -8068,6 +8439,83 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2306,
|
||||
"nameEn": "goldflame_qucusaur_tyrant",
|
||||
"type": "character",
|
||||
"name": "金焰绒翼龙暴君",
|
||||
"hp": 11,
|
||||
"energy": 2,
|
||||
"element": "火元素",
|
||||
"weapon": "其他武器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "wingcleave",
|
||||
"name": "翼斩",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1103,
|
||||
"nameEn": "pyro",
|
||||
"type": "火元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "rising_scorchwind",
|
||||
"name": "升腾炽风",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1103,
|
||||
"nameEn": "pyro",
|
||||
"type": "火元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "goldflame_detonation",
|
||||
"name": "金焰爆轰",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1103,
|
||||
"nameEn": "pyro",
|
||||
"type": "火元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "ancient_bloodline",
|
||||
"name": "古老者的血脉",
|
||||
"skillTag": [
|
||||
"被动技能"
|
||||
],
|
||||
"cost": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2401,
|
||||
"nameEn": "electro_hypostasis",
|
||||
@@ -8772,7 +9220,7 @@
|
||||
"nameEn": "stonehide_lawachurl",
|
||||
"type": "character",
|
||||
"name": "丘丘岩盔王",
|
||||
"hp": 8,
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "岩元素",
|
||||
"weapon": "其他武器",
|
||||
@@ -9072,7 +9520,7 @@
|
||||
"nameEn": "jadeplume_terrorshroom",
|
||||
"type": "character",
|
||||
"name": "翠翎恐蕈",
|
||||
"hp": 10,
|
||||
"hp": 12,
|
||||
"energy": 2,
|
||||
"element": "草元素",
|
||||
"weapon": "其他武器",
|
||||
@@ -9376,26 +9824,26 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 6605,
|
||||
"nameEn": "skirk",
|
||||
"id": 2705,
|
||||
"nameEn": "consecrated_fanged_beast",
|
||||
"type": "character",
|
||||
"name": "丝柯克",
|
||||
"name": "圣骸牙兽",
|
||||
"hp": 10,
|
||||
"energy": 0,
|
||||
"element": "冰元素",
|
||||
"weapon": "单手剑",
|
||||
"energy": 2,
|
||||
"element": "草元素",
|
||||
"weapon": "其他武器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "havoc_sunder",
|
||||
"name": "极恶技·断",
|
||||
"nameEn": "claw_slash",
|
||||
"name": "利爪猛击",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1101,
|
||||
"nameEn": "cryo",
|
||||
"type": "冰元素",
|
||||
"id": 1107,
|
||||
"nameEn": "dendro",
|
||||
"type": "草元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
@@ -9407,38 +9855,44 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "havoc_warp",
|
||||
"name": "极恶技·闪",
|
||||
"nameEn": "siphon_wave",
|
||||
"name": "掠能绿波",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1101,
|
||||
"nameEn": "cryo",
|
||||
"type": "冰元素",
|
||||
"count": 2
|
||||
"id": 1107,
|
||||
"nameEn": "dendro",
|
||||
"type": "草元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "havoc_extinction",
|
||||
"name": "极恶技·尽",
|
||||
"nameEn": "sprawling_blighted_vines",
|
||||
"name": "横生厄蔓",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1101,
|
||||
"nameEn": "cryo",
|
||||
"type": "冰元素",
|
||||
"count": 1
|
||||
"id": 1107,
|
||||
"nameEn": "dendro",
|
||||
"type": "草元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "reason_beyond_reason",
|
||||
"name": "理外之理",
|
||||
"nameEn": "hunger_from_the_remains",
|
||||
"name": "亡骸饥渴",
|
||||
"skillTag": [
|
||||
"被动技能"
|
||||
],
|
||||
|
||||
@@ -564,6 +564,75 @@ public class GeniusInvokationControl
|
||||
m.LeftButtonUp();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 月之五伊涅芙会导致手牌不可调和,根据传入的手牌数量,从左往右尝试
|
||||
/// </summary>
|
||||
private bool ActionPhaseElementalTuningAlternatives(int currentCardCount)
|
||||
{
|
||||
var rect = TaskContext.Instance().SystemInfo.CaptureAreaRect;
|
||||
var info = TaskContext.Instance().SystemInfo;
|
||||
var m = Simulation.SendInput.Mouse;
|
||||
|
||||
var startY = rect.Y + rect.Height - 50;
|
||||
var endX = rect.X + rect.Width - 50;
|
||||
var endY = rect.Y + rect.Height / 2d;
|
||||
|
||||
// 手牌数量对应的起点(中心)和间距
|
||||
var table = new Dictionary<int, (double startX, double spacing)>
|
||||
{
|
||||
{10, (570.0, 120.0)},
|
||||
{9, (570.0, 130.0)},
|
||||
{8, (600.0, 145.0)},
|
||||
{7, (630.0, 160.0)},
|
||||
{6, (620.0, 200.0)},
|
||||
{5, (720.0, 200.0)},
|
||||
{4, (820.0, 200.0)},
|
||||
{3, (920.0, 200.0)},
|
||||
{2, (1020.0, 200.0)},
|
||||
{1, (1120.0, 200.0)}
|
||||
};
|
||||
|
||||
if (!table.ContainsKey(currentCardCount))
|
||||
{
|
||||
_logger.LogWarning("未找到手牌数量对应的起始位置配置: {Count}", currentCardCount);
|
||||
return false;
|
||||
}
|
||||
|
||||
var (startX, spacing) = table[currentCardCount];
|
||||
|
||||
// 先点中间位置,确保牌是展开状态
|
||||
ClickExtension.Click(rect.X + rect.Width / 2d, rect.Y + rect.Height - 50);
|
||||
Sleep(1500);
|
||||
|
||||
// 从左往右尝试
|
||||
for (int idx = 0; idx < currentCardCount; idx++)
|
||||
{
|
||||
var x = rect.X + startX * info.AssetScale + idx * spacing * info.AssetScale;
|
||||
|
||||
ClickExtension.Click(x, startY);
|
||||
Sleep(500);
|
||||
|
||||
m.LeftButtonDown();
|
||||
Sleep(100);
|
||||
m = ClickExtension.Move(endX, endY);
|
||||
Sleep(100);
|
||||
m.LeftButtonUp();
|
||||
|
||||
// 等待动画并确认
|
||||
Sleep(1200);
|
||||
if (ActionPhaseElementalTuningConfirm())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
_logger.LogWarning("烧牌位置尝试失败,手牌数:{Count},位置索引:{Idx}", currentCardCount, idx);
|
||||
ClickGameWindowCenter(); // 复位
|
||||
Sleep(1000);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 烧牌确认(元素调和按钮)
|
||||
/// </summary>
|
||||
@@ -692,16 +761,13 @@ public class GeniusInvokationControl
|
||||
for (var i = 0; i < needSpecifyElementDiceCount; i++)
|
||||
{
|
||||
_logger.LogInformation("- 烧第{Count}张牌", i + 1);
|
||||
ActionPhaseElementalTuning(duel.CurrentCardCount);
|
||||
Sleep(1200);
|
||||
var res = ActionPhaseElementalTuningConfirm();
|
||||
if (res == false)
|
||||
|
||||
// 尝试对当前手牌从左往右依次进行烧牌
|
||||
var tuned = ActionPhaseElementalTuningAlternatives(duel.CurrentCardCount);
|
||||
if (!tuned)
|
||||
{
|
||||
_logger.LogWarning("烧牌失败,重试");
|
||||
i--;
|
||||
ClickGameWindowCenter(); // 复位
|
||||
Sleep(1000);
|
||||
continue;
|
||||
_logger.LogWarning("所有手牌尝试烧牌均失败,取消释放技能");
|
||||
return false;
|
||||
}
|
||||
|
||||
Sleep(1000); // 烧牌动画
|
||||
@@ -998,11 +1064,10 @@ public class GeniusInvokationControl
|
||||
|
||||
public void AppendCharacterStatus(Character character, Mat greyMat, int hp = -2)
|
||||
{
|
||||
// 截取出战角色区域扩展
|
||||
using var characterMat = new Mat(greyMat, new Rect(character.Area.X,
|
||||
character.Area.Y,
|
||||
character.Area.Width + 40,
|
||||
character.Area.Height + 10));
|
||||
// 截取出战角色区域扩展,钳位到图像边界防止越界
|
||||
var charRect = new Rect(character.Area.X, character.Area.Y,
|
||||
character.Area.Width + 40, character.Area.Height + 10).ClampTo(greyMat);
|
||||
using var characterMat = new Mat(greyMat, charRect);
|
||||
// 识别角色异常状态
|
||||
var pCharacterStatusFreeze = MatchTemplateHelper.MatchTemplate(characterMat, _assets.CharacterStatusFreezeMat,
|
||||
TemplateMatchModes.CCoeffNormed);
|
||||
@@ -1144,9 +1209,13 @@ public class GeniusInvokationControl
|
||||
}
|
||||
else
|
||||
{
|
||||
hpMat = new Mat(imageRegion.SrcMat, new Rect(cardRect.X + _config.CharacterCardExtendHpRect.X,
|
||||
// 出战角色 HP 区域向上偏移,钳位到图像边界防止越界
|
||||
var activeHpRect = new Rect(
|
||||
cardRect.X + _config.CharacterCardExtendHpRect.X,
|
||||
cardRect.Y + _config.CharacterCardExtendHpRect.Y - _config.ActiveCharacterCardSpace,
|
||||
_config.CharacterCardExtendHpRect.Width, _config.CharacterCardExtendHpRect.Height));
|
||||
_config.CharacterCardExtendHpRect.Width,
|
||||
_config.CharacterCardExtendHpRect.Height).ClampTo(imageRegion.SrcMat);
|
||||
hpMat = new Mat(imageRegion.SrcMat, activeHpRect);
|
||||
text = OcrFactory.Paddle.Ocr(hpMat);
|
||||
//Cv2.ImWrite($"log\\hp_active_{i}.jpg", hpMat);
|
||||
Debug.WriteLine($"角色{i}出战HP位置识别结果{text}");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model
|
||||
{
|
||||
@@ -15,6 +15,11 @@ namespace BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model
|
||||
/// 目标编号(技能编号,从右往左)
|
||||
/// </summary>
|
||||
public int TargetIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 灵活改变骰子的数量(因为在不同的牌局中或者角色技能中会发生骰子实际需要的数量增加或减少)
|
||||
/// </summary>
|
||||
public int DiceDelta { get; set; } = 0;
|
||||
|
||||
public override string? ToString()
|
||||
{
|
||||
@@ -22,11 +27,11 @@ namespace BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model
|
||||
{
|
||||
if (string.IsNullOrEmpty(Character.Skills[TargetIndex].Name))
|
||||
{
|
||||
return $"【{Character.Name}】使用【技能{TargetIndex}】";
|
||||
return $"【{Character.Name}】使用【技能{TargetIndex}】{(DiceDelta != 0 ? $"(骰子{(DiceDelta > 0 ? "增加" : "减少")}{Math.Abs(DiceDelta)})" : "")}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"【{Character.Name}】使用【{Character.Skills[TargetIndex].Name}】";
|
||||
return $"【{Character.Name}】使用【{Character.Skills[TargetIndex].Name}】{(DiceDelta != 0 ? $"(骰子{(DiceDelta > 0 ? "增加" : "减少")}{Math.Abs(DiceDelta)})" : "")}";
|
||||
}
|
||||
}
|
||||
else if (Action == ActionEnum.SwitchLater)
|
||||
|
||||
@@ -203,7 +203,7 @@ public class Duel
|
||||
}
|
||||
|
||||
// 2. 判断使用技能
|
||||
if (actionCommand.GetAllDiceUseCount() > CurrentDiceCount)
|
||||
if (actionCommand.GetAllDiceUseCount() + actionCommand.DiceDelta > CurrentDiceCount)// 判断条件加上 DiceDelta 骰子变化
|
||||
{
|
||||
_logger.LogInformation("骰子不足以进行下一步:{Action}", actionCommand);
|
||||
break;
|
||||
@@ -213,7 +213,9 @@ public class Duel
|
||||
bool useSkillRes = actionCommand.UseSkill(this);
|
||||
if (useSkillRes)
|
||||
{
|
||||
CurrentDiceCount -= actionCommand.GetAllDiceUseCount();
|
||||
int realCost = actionCommand.GetAllDiceUseCount() + actionCommand.DiceDelta;
|
||||
realCost = Math.Max(realCost, 0);
|
||||
CurrentDiceCount -= realCost;
|
||||
alreadyExecutedActionIndex.Add(i);
|
||||
alreadyExecutedActionCommand.Add(actionCommand);
|
||||
_logger.LogInformation("→指令执行完成:{Action}", actionCommand);
|
||||
@@ -344,7 +346,7 @@ public class Duel
|
||||
}
|
||||
|
||||
// 2. 判断使用技能
|
||||
actionUseDiceSum += actionCommand.GetAllDiceUseCount();
|
||||
actionUseDiceSum += Math.Max(actionCommand.GetAllDiceUseCount() + actionCommand.DiceDelta, 0);
|
||||
if (actionUseDiceSum > CurrentDiceCount)
|
||||
{
|
||||
break;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ScriptParser
|
||||
MyAssert(duel.Characters[3] != null, "角色未定义");
|
||||
|
||||
string[] actionParts = line.Split(" ", StringSplitOptions.RemoveEmptyEntries);
|
||||
MyAssert(actionParts.Length == 3, "策略中的行动命令解析错误");
|
||||
MyAssert(actionParts.Length >= 3 && actionParts.Length <= 4, "策略中的行动命令解析错误");
|
||||
MyAssert(actionParts[1] == "使用", "策略中的行动命令解析错误");
|
||||
|
||||
var actionCommand = new ActionCommand();
|
||||
@@ -83,6 +83,26 @@ public class ScriptParser
|
||||
int skillNum = int.Parse(RegexHelper.ExcludeNumberRegex().Replace(actionParts[2], ""));
|
||||
MyAssert(skillNum < 5, "策略中的行动命令解析错误:技能编号错误");
|
||||
actionCommand.TargetIndex = skillNum;
|
||||
|
||||
// 解析骰子增减
|
||||
actionCommand.DiceDelta = 0;
|
||||
if (actionParts.Length >= 4)
|
||||
{
|
||||
if (actionParts[3].StartsWith("骰子增加"))
|
||||
{
|
||||
int delta = int.Parse(RegexHelper.ExcludeNumberRegex().Replace(actionParts[3], ""));
|
||||
actionCommand.DiceDelta = delta;
|
||||
}
|
||||
else if (actionParts[3].StartsWith("骰子减少"))
|
||||
{
|
||||
int delta = int.Parse(RegexHelper.ExcludeNumberRegex().Replace(actionParts[3], ""));
|
||||
actionCommand.DiceDelta = -delta;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyAssert(false, $"策略中的行动命令解析错误:骰子增减参数格式不正确(应为 骰子增加N 或 骰子减少N ),实际:{actionParts[3]}");
|
||||
}
|
||||
}
|
||||
duel.ActionCommandQueue.Add(actionCommand);
|
||||
}
|
||||
else
|
||||
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
After Width: | Height: | Size: 918 B |
|
After Width: | Height: | Size: 350 B |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 707 B |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 755 B |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 682 B |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.7 KiB |