refactor: 优化进入尘歌壶流程,使用ocr判断是否结束 (#529)

This commit is contained in:
bling-yshs
2025-04-06 22:15:59 +08:00
committed by GitHub
parent cc9d1968d5
commit 6865eeea1a
3 changed files with 22 additions and 16 deletions

View File

@@ -18,11 +18,24 @@ async function main() {
// 进入尘歌壶,等待加载动画 // 进入尘歌壶,等待加载动画
keyPress("F"); keyPress("F");
let waitTime = settings.loadingWaitTime; // 先等待5秒应该不会比这快
if (!waitTime) { await sleep(5000);
waitTime = 10; // 等待传送完成
let isEntering = true;
while (isEntering) {
// 截图检测传送状态
let screen = captureGameRegion();
let targetRegion = screen.DeriveCrop(85, 1025, 69, 28);
let ocrRo = RecognitionObject.Ocr(0, 0, targetRegion.Width, targetRegion.Height);
let ocrResult = targetRegion.find(ocrRo);
if (ocrResult.Text.toLowerCase().includes("enter")) {
isEntering = false;
} }
await sleep(waitTime * 1000); await sleep(1000);
}
// 进入尘歌壶以后等待1秒
await sleep(1000);
// 移动到阿圆 // 移动到阿圆
await moveToAYuan(); await moveToAYuan();
@@ -33,7 +46,7 @@ async function main() {
await sleep(2000); await sleep(2000);
// 点击屏幕中间跳过对话 // 点击屏幕中间跳过对话
click(960, 540); click(960, 540);
await sleep(1000); await sleep(2000);
// 点击“信任等阶” // 点击“信任等阶”
click(1370, 432) click(1370, 432)
await sleep(1000); await sleep(1000);
@@ -60,7 +73,6 @@ async function main() {
} }
async function findSereniteaPot() { async function findSereniteaPot() {
let found = false;
let currentX = 178; // 起始X坐标 let currentX = 178; // 起始X坐标
let searchCount = 0; // 添加查找次数计数器 let searchCount = 0; // 添加查找次数计数器
const MAX_SEARCH_COUNT = 5; // 最大查找次数 const MAX_SEARCH_COUNT = 5; // 最大查找次数
@@ -82,7 +94,6 @@ async function findSereniteaPot() {
let ocrResult = targetRegion.find(ocrRo); let ocrResult = targetRegion.find(ocrRo);
if (!ocrResult.isEmpty() && ocrResult.Text.includes("尘歌壶")) { if (!ocrResult.isEmpty() && ocrResult.Text.includes("尘歌壶")) {
found = true;
// 点击指定坐标 // 点击指定坐标
click(1690, 1020); click(1690, 1020);
await sleep(1000); await sleep(1000);

View File

@@ -1,7 +1,7 @@
{ {
"manifest_version": 1, "manifest_version": 1,
"name": "尘歌壶一条龙-领取洞天宝钱和角色好感", "name": "尘歌壶一条龙-领取洞天宝钱和角色好感",
"version": "0.0.1", "version": "0.0.2",
"description": "自动放置并进入尘歌壶,寻找阿圆,领取洞天宝钱和好感(需要配置进入尘歌壶以后的路线)(更新时间5.5版本)", "description": "自动放置并进入尘歌壶,寻找阿圆,领取洞天宝钱和好感(需要配置进入尘歌壶以后的路线)(更新时间5.5版本)",
"authors": [ "authors": [
{ {

View File

@@ -3,10 +3,5 @@
"name": "route", "name": "route",
"type": "input-text", "type": "input-text",
"label": "进入尘歌壶以后寻找阿圆的路径\n填写规则方向键+空格+时间(单位:毫秒)\n多个路径用英文逗号隔开例如A 1000,S 1500,A 500" "label": "进入尘歌壶以后寻找阿圆的路径\n填写规则方向键+空格+时间(单位:毫秒)\n多个路径用英文逗号隔开例如A 1000,S 1500,A 500"
},
{
"name": "loadingWaitTime",
"type": "input-text",
"label": "按 F 进入尘歌壶后等待加载的时间(单位:秒)(默认10)"
} }
] ]