js:采集cd管理2.1.0 (#2444)

* js:采集cd管理2.1.0

莫酱太坏了,怎么又往仓库塞一百多张图片

* js:只要大瓶

顺便改下大瓶

* Update main.js
This commit is contained in:
mno
2025-12-06 14:27:17 +08:00
committed by GitHub
parent 51b04c6e53
commit e5b358a260
183 changed files with 3068 additions and 476 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 882 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -18,15 +18,8 @@ fourStarRo.Threshold = +settings.Threshold1 || 0.97;
//fourStarRo.Use3Channels = true;
fourStarRo.InitTemplate();
const bigPngRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync(`assets/RecognitionObject/大瓶.png`), 1670, 900, 1890 - 1670, 980 - 900);
bigPngRo.Threshold = 0.995;
bigPngRo.Use3Channels = true;
bigPngRo.InitTemplate();
const smallPngRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync(`assets/RecognitionObject/大瓶和小瓶.png`), 1670, 900, 1890 - 1670, 980 - 900);
smallPngRo.Threshold = 0.995;
smallPngRo.Use3Channels = true;
smallPngRo.InitTemplate();
let pngRo1;
let pngRo2;
let bigBottleCount = 0;
let smallBottleCount = 0;
@@ -50,8 +43,74 @@ let rg;
//await genshin.tpToStatueOfTheSeven();
keyPress("B");
//切换到圣遗物界面
await clickPNG("狗粮界面");
if (settings.autoSwitchCount) {
log.info(`填写了临界小瓶数量为${(+settings.autoSwitchCount)},开始识别`);
await clickPNG("筛选");
await sleep(200);
click(30, 30);
await sleep(100);
await clickPNG("重置");
await clickPNG("祝圣之霜定义");
await clickPNG("未装备");
await clickPNG("未锁定");
await clickPNG("确认");
await sleep(200);
click(30, 30);
await sleep(100);
{
const smallBottleRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync(`assets/RecognitionObject/背包小瓶.png`));
smallBottleRo.InitTemplate();
for (let i = 0; i < 5; i++) {
const rg = captureGameRegion();
try {
const res = rg.find(smallBottleRo);
if (res.isExist()) {
const regionToCheck = { x: res.x, y: res.y + 110, width: 122, height: 30 };
const raw = await recognizeTextInRegion(regionToCheck);
// 只保留数字
const digits = (raw || '').replace(/\D/g, '');
log.info(`识别到小瓶数量为${digits}`);
if ((+digits) > settings.autoSwitchCount) {
settings.bottleType = "只要大瓶";
} else {
settings.bottleType = "只要小瓶";
}
log.info(`当前分解模式为${settings.bottleType}`);
break;
}
} finally { rg.dispose(); }
if (i < 5 - 1) await sleep(50);
}
}
}
if (settings.bottleType != "只要小瓶") {
pngRo1 = RecognitionObject.TemplateMatch(file.ReadImageMatSync(`assets/RecognitionObject/大瓶.png`), 1670, 900, 1890 - 1670, 980 - 900);
pngRo1.Threshold = 0.995;
pngRo1.Use3Channels = true;
pngRo1.InitTemplate();
pngRo2 = RecognitionObject.TemplateMatch(file.ReadImageMatSync(`assets/RecognitionObject/大瓶和小瓶.png`), 1670, 900, 1890 - 1670, 980 - 900);
pngRo2.Threshold = 0.995;
pngRo2.Use3Channels = true;
pngRo2.InitTemplate();
} else {
pngRo1 = RecognitionObject.TemplateMatch(file.ReadImageMatSync(`assets/RecognitionObject/三个小瓶.png`), 1670, 900, 1890 - 1670, 980 - 900);
pngRo1.Threshold = 0.995;
pngRo1.Use3Channels = true;
pngRo1.InitTemplate();
pngRo2 = RecognitionObject.TemplateMatch(file.ReadImageMatSync(`assets/RecognitionObject/大瓶.png`), 1670, 900, 1890 - 1670, 980 - 900);
pngRo2.Threshold = 0.995;
pngRo2.Use3Channels = true;
pngRo2.InitTemplate();
}
//点击分解
await clickPNG("分解");
//点击倒序
@@ -70,18 +129,26 @@ let rg;
rg = captureGameRegion();
try {
const bigRes = rg.find(bigPngRo);
const bigRes = rg.find(pngRo1);
if (bigRes.isExist()) {
foundBigBottle = true;
bigBottleCount++;
if (settings.bottleType === "只要大瓶") {
bigBottleCount++;
} else {
smallBottleCount += 3;
}
break;
}
const smallRes = rg.find(smallPngRo);
const smallRes = rg.find(pngRo2);
if (smallRes.isExist()) {
foundBigBottle = true;
bigBottleCount++;
smallBottleCount++;
if (settings.bottleType === "只要大瓶") {
bigBottleCount++;
smallBottleCount++;
} else {
bigBottleCount++;
}
break;
}
} finally {
@@ -94,7 +161,7 @@ let rg;
//log.info(`调试-用时${new Date() - time1}`);
}
if (foundBigBottle) {
log.info("成功选出分解大瓶所需狗粮");
log.info("成功选出分解所需狗粮");
} else {
log.info("结束分解");
break;
@@ -213,7 +280,7 @@ async function findAndClick(target, maxAttempts = 20) {
const rg = captureGameRegion();
try {
const res = rg.find(target);
if (res.isExist()) { res.click(); return true; }
if (res.isExist()) { await sleep(16); res.click(); return true; }
} finally { rg.dispose(); }
if (i < maxAttempts - 1) await sleep(50);
}
@@ -237,4 +304,30 @@ async function findWithoutClick(target, maxAttempts = 20) {
if (i < maxAttempts - 1) await sleep(50);
}
return false;
}
async function recognizeTextInRegion(ocrRegion, timeout = 5000) {
let startTime = Date.now();
let retryCount = 0; // 重试计数
while (Date.now() - startTime < timeout) {
try {
// 在指定区域进行 OCR 识别
const gameRegion = captureGameRegion();
let ocrResult = gameRegion.find(RecognitionObject.ocr(ocrRegion.x, ocrRegion.y, ocrRegion.width, ocrRegion.height));
gameRegion.dispose();
if (ocrResult) {
let correctedText = ocrResult.text;
return correctedText; // 返回识别到的内容
} else {
log.warn(`OCR 识别区域未找到内容`);
return null; // 如果 OCR 未识别到内容,返回 null
}
} catch (error) {
retryCount++; // 增加重试计数
log.warn(`OCR 识别失败,正在进行第 ${retryCount} 次重试...`);
}
await sleep(200);
}
log.warn(`经过多次尝试,仍然无法在指定区域识别到文字`);
return null; // 如果未识别到文字,返回 null
}

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 1,
"name": "只要大瓶",
"version": "1.0",
"version": "1.1",
"description": "分解狗粮尽量只要大瓶",
"authors": [
{

View File

@@ -11,6 +11,21 @@
],
"default": "3"
},
{
"name": "bottleType",
"type": "select",
"label": "分解成大瓶还是小瓶",
"options": [
"只要大瓶",
"只要小瓶"
],
"default": "只要大瓶"
},
{
"name": "autoSwitchCount",
"type": "input-text",
"label": "临界小瓶数量,填写后将会在每次开始时识别小瓶数量\n数量大于所填数值时将会自动切换为只要大瓶否则切换为只要小瓶\n不填时不识别保持自定义配置中的选项"
},
{
"name": "Threshold1",
"type": "input-text",

View File

@@ -1,19 +1,56 @@
# 采集CD管理脚本
采集CD管理脚本
## 简介
这是一个基于文件夹操作的自动化脚本用于管理采集路线的冷却时间CD。它会按照路径组的顺序依次运行任务直到指定的时间并根据给定的CD类型自动跳过未刷新的路线。同时加入了伪造日志功能日志分析可以解析具体路线的信息。
一、简介:
-
这是一个基于文件夹操作的自动化脚本用于管理采集路线的冷却时间CD。它会按照自定义配置中所选路径组的顺序依次运行任务直到指定的时间并根据给定的CD类型自动跳过未刷新的路线。同时加入了伪造日志功能日志分析可以解析具体路线的信息。
## 文件结构
二、文件结构
-
- `main.js`主要的脚本文件负责执行任务和管理CD。
- `manifest.json`:脚本的配置文件,包含脚本的基本信息和设置。
- `settings.json`用户配置文件用于设置操作模式、路径组CD类型、配队名称等。
- `pathing/`:存放路径文件的文件夹,路径组可选择其中一个子文件夹运行。
## 功能
- **操作模式选择**提供两种操作模式包括“执行任务若不存在索引文件则自动创建”和“重新生成索引文件用于强制刷新CD或更新文件”。
- **路径组CD类型**支持多种CD类型包括“1次0点刷新”、“2次0点刷新”、“3次0点刷新”、“4点刷新”、“12小时刷新”、“24小时刷新”和“46小时刷新”。
- **任务管理**自动读取路径组文件跳过未刷新的任务并根据CD类型更新任务的时间戳。同时支持跳过指定时间段的任务
- **配队管理**:支持为每个路径组指定配队名称,自动切换配队
三、功能
-
- 操作模式选择:提供两种操作模式:
- 执行任务(若不存在索引文件则自动创建):自动执行任务,若索引文件不存在则自动创建
- 重新生成索引文件用于强制刷新CD或更新文件重新生成索引文件可用于强制刷新CD或更新文件
- 路径组CD类型支持多种CD类型包括
- 1次0点刷新
- 2次0点刷新
- 3次0点刷新
- 4点刷新
- 12小时刷新
- 24小时刷新
- 46小时刷新
- 任务管理自动读取路径组文件跳过未刷新的任务并根据CD类型更新任务的时间戳。同时支持跳过指定时间段的任务。
- 配队管理:支持为每个路径组指定配队名称,自动切换配队。
- 伪造日志:支持伪造日志功能,便于日志分析工具解析具体路线信息。
## 使用方法
1. 将要运行的地图追踪文件放在pathing文件夹下的不同路径组中将会按照路径组的顺序执行并跳过未刷新的路线
2. 根据需要修改自定义配置设置操作模式、路径组CD类型、配队名称等参数。
四、使用方法
-
1. 准备路径文件:
- 将要运行的地图追踪文件放在 `pathing/` 文件夹下的不同路径组中,每个子文件夹代表一个路径组。
- 文件夹名称将可在自定义配置中供选择,例如 `pathing/矿物``pathing/地方特产` 等。
2. 构造自定义配置:
- 建议初次运行先勾选仅刷新选项。
- 填写需要的路径组数量
- 运行一次js将会根据所填的路径组数量构造出新的自定义配置
- 后续如果修改了pathing下文件夹的名字或在多个配置组使用本js时需要修改本配置组的自定义配置时强烈建议重新进行该步骤使自定义配置选项等与本配置组情况一致
3. 修改自定义配置:
- 根据所给表格结合自身情况选择每个路径组的刷新cd类型
- 选择每个路径组要运行的文件夹
- 填写运行该组使用的配队名称(不填就不换队,有啥用啥)
4. 运行脚本:
- 运行脚本,脚本将按照路径组的顺序依次执行任务。
- 如果当前时间处于 `timerule` 指定的时间范围内,脚本将终止。
- 如果任务的CD未刷新脚本将跳过该任务并继续执行下一个任务。
- 脚本会自动更新任务的时间戳确保任务按CD类型刷新后再运行。
五、注意事项
-
- 伪造日志:伪造日志功能仅用于日志分析,不会影响脚本的实际运行。
- 识别到满背包的物品将会被加入拾取黑名单,同时加入自定义配置中的 **禁用的路线的关键词** ,将会跳过文件路径包含该关键词的路线,其他你希望跳过的路线也可以使用该配置来跳过,如填写钟离来跳过部分需要钟离的挖矿路线(仅文件路径中包含钟离时有效,还是建议手动删除这些路线)
- 不同配置组中的本js仅共用相同账号的拾取黑名单路线刷新cd路径组等其他信息并不关联settings.json仅供配置每个配置组使用本身变化不影响其他配置组功能

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Some files were not shown because too many files have changed in this diff Show More