js:锄地一条龙&锄地路线测试 (#1377)

* js:锄地一条龙

新增“自动优化”,根据运行记录按一定权重修改路线的预期用时

* js:锄地路线测试

用于测试锄地路线的怪物信息,运行时间,并根据运行记录修改description字段,以适配js锄地一条龙
This commit is contained in:
mno
2025-07-21 15:17:37 +08:00
committed by GitHub
parent b79e21d423
commit 66cd769a3b
304 changed files with 2771 additions and 33 deletions

View File

@@ -34,7 +34,7 @@
- **执行模式:**
- - 默认选择 **运行锄地路线** ,选择该模式会按照后续设置选择并运行相应路线
- - 选项 **输出地图追踪文件** 会将选择的路线读取并分组输出到js文件夹下pathingOut文件夹
- - 选项 **强制刷新所有路线cd** 用于清除js记录的运行历史
- - 选项 **强制刷新所有运行记录** 用于清除js记录的运行历史
- **选择执行第几个路径组:** 本js会分组运行地图追踪分组方式详见后续选项需要分组运行时请确保精英目标数量小怪目标数量各个路径组的标签等信息【完全相同】复制配置组时未知原因无法正确复制配置请不要使用
- **本路径组使用配队名称:** 填写该路径组使用的配队名称js会自动切换
- **拾取模式:** 本js采用黑白名单结合的方式实现仅拾取部分物品默认只拾取狗粮和晶蝶如果你想要使用bgi默认的拾取以拾取绝大部分物品请选择bgi拾取如果不想拾取任何物品请选择不拾取任何物品
@@ -52,6 +52,7 @@
- **输入不运行的时间或时间段的小时数** 当你需要让js在特定的时间终止运行时按描述填写js会在距离目标时间小于五分钟时终止运行并等待到目标时间
- **路线效率计算权重:** 影响js评估路线价值计算公式如下权重越大越看重总收益
- $$ 怪均^k \times 秒均 $$
- **自动优化:** js将根据运行记录调整每条路线的预期运行时间具体逻辑为至多6条记录去除一个最大值、一个最小值后每条记录占据20%的权重,剩余权重由默认数据填充。如果你不想要这个功能,请禁用。
- **目标数量:** 选取路线目标达到的精英怪数量默认为400同理小怪数量默认为2000
- **优先关键词:**含有关键词的路线会被视为拥有最高效率例如填写600来让所有600怪物优先考虑填写骗骗花来优先考虑骗骗花
- **排除关键词:** 含有关键词的路线会被排除,例如填写纳塔来排除所有纳塔路线,同样使用中文逗号分隔

View File

@@ -95,14 +95,16 @@ if (settings.activeDumperMode) { //处理泥头车信息
if (operationMode === "输出地图追踪文件") {
log.info("开始复制并输出地图追踪文件\n请前往js文件夹查看");
await copyPathingsByGroup(pathings);
await updateRecords(pathings, accountName);
} else if (operationMode === "运行锄地路线") {
await switchPartyIfNeeded(partyName)
log.info("开始运行锄地路线");
await updateRecords(pathings, accountName);
await processPathingsByGroup(pathings, whitelistKeywords, blacklistKeywords, accountName);
} else {
log.info("强制刷新所有路线CD");
log.info("强制刷新所有运行记录");
await initializeCdTime(pathings, "");
await updateCdTimeRecord(pathings, accountName);
await updateRecords(pathings, accountName);
}
})();
@@ -158,6 +160,32 @@ async function processPathings() {
// 初始化 pathing 对象的属性
pathing.t = routeInfo.time; // 预计用时初始化为60秒如果 description 中有值则覆盖
if (!settings.disableSelfOptimization && pathing.records) {
//如果用户没有禁用自动优化,则参考运行记录更改预期用时
const history = pathing.records.filter(v => v > 0);
if (history.length) {
const max = Math.max(...history);
const min = Math.min(...history);
let maxRemoved = false;
let minRemoved = false;
// 就地修改 history先去掉一个最大值再去掉一个最小值
for (let i = history.length - 1; i >= 0; i--) {
const v = history[i];
if (!maxRemoved && v === max) {
history.splice(i, 1);
maxRemoved = true;
} else if (!minRemoved && v === min) {
history.splice(i, 1);
minRemoved = true;
}
if (maxRemoved && minRemoved) break;
}
}
//每一个有效的record占用0.2权重,剩余权重为原时间
pathing.t = pathing.t * (1 - history.length * 0.2) + history.reduce((a, b) => a + b, 0);
}
pathing.m = 0; // 普通怪物数量
pathing.e = 0; // 精英怪物数量
pathing.mora_m = 0; // 普通怪物摩拉值
@@ -950,6 +978,9 @@ async function processPathingsByGroup(pathings, whitelistKeywords, blacklistKeyw
nextEightClock.setUTCHours(20 + 24, 0, 0, 0); // 设置为下一个 UTC 时间的 20:00
}
const pathTime = new Date() - now;
pathing.records = [...pathing.records, pathTime / 1000].slice(-6);
// 更新路径的 cdTime
pathing.cdTime = nextEightClock.toLocaleString();
@@ -962,64 +993,62 @@ async function processPathingsByGroup(pathings, whitelistKeywords, blacklistKeyw
const remainingseconds = predictRemainingTime % 60;
log.info(`当前进度:第 ${targetGroup} 组第 ${groupPathCount}/${totalPathsInGroup}${pathing.fileName}已完成,该组预计剩余: ${remaininghours}${remainingminutes}${remainingseconds.toFixed(0)}`);
await updateCdTimeRecord(pathings, accountName);
await updateRecords(pathings, accountName);
}
}
}
//加载cd信息
async function initializeCdTime(pathings, accountName) {
try {
// 构造文件路径
const filePath = `records/${accountName}.json`;
// 尝试读取文件内容
const fileContent = await file.readText(filePath);
// 解析 JSON 数据
const cdTimeData = JSON.parse(fileContent);
// 遍历 pathings 数组
pathings.forEach(pathing => {
// 找到对应的 cdTime 数据
const cdTimeEntry = cdTimeData.find(entry => entry.fileName === pathing.fileName);
const entry = cdTimeData.find(e => e.fileName === pathing.fileName);
// 如果找到对应的项,则更新 cdTime
if (cdTimeEntry) {
pathing.cdTime = new Date(cdTimeEntry.cdTime).toLocaleString();
} else {
// 如果没有找到对应的项,则使用默认值 new Date(0)
pathing.cdTime = new Date(0).toLocaleString();
}
// 读取 cdTime
pathing.cdTime = entry
? new Date(entry.cdTime).toLocaleString()
: new Date(0).toLocaleString();
// 确保当前 records 是数组
const current = Array.isArray(pathing.records) ? pathing.records : new Array(6).fill(-1);
// 读取文件中的 records若缺失则为空数组
const loaded = (entry && Array.isArray(entry.records)) ? entry.records : [];
// 合并:文件中的 records倒序最新在前→ 追加到当前数组末尾
// 再整体倒序恢复正确顺序,截取最新 5 项
pathing.records = [...current, ...loaded.reverse()].slice(-5);
});
} catch (error) {
// 文件不存在或解析错误,初始化为 6 个 -1
pathings.forEach(pathing => {
pathing.cdTime = new Date(0).toLocaleString();
pathing.records = new Array(6).fill(-1);
});
}
}
async function updateCdTimeRecord(pathings, accountName) {
async function updateRecords(pathings, accountName) {
try {
// 构造文件路径
const filePath = `records/${accountName}.json`;
// 构造要写入文件的 JSON 数据
const cdTimeData = pathings.map(pathing => ({
fileName: pathing.fileName,
//description: pathing.description,
//精英数量: pathing.e,
//小怪数量: pathing.m,
标签: pathing.tags,
cdTime: pathing.cdTime
预计用时: pathing.t,
cdTime: pathing.cdTime,
// 倒序:最新 → 最旧,再过滤 > 0 并保留两位小数
records: [...pathing.records] // 复制一份避免副作用
.reverse() // 倒序
.filter(v => v > 0) // 过滤大于 0
.map(v => Number(v.toFixed(2))) // 保留两位小数
}));
// 将更新后的内容写回文件
await file.writeText(filePath, JSON.stringify(cdTimeData, null, 2), false);
} catch (error) {
// 捕获并记录错误
log.error(`更新 cdTime 时出错: ${error.message}`);
}
}

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 1,
"name": "锄地一条龙",
"version": "1.1.11",
"version": "1.2.0",
"description": "一站式解决自动化锄地支持只拾取狗粮请阅读README.md后使用",
"authors": [
{

View File

@@ -6,7 +6,7 @@
"options": [
"运行锄地路线",
"输出地图追踪文件",
"强制刷新所有路线cd"
"强制刷新所有运行记录"
],
"default": "运行锄地路线"
},
@@ -81,6 +81,11 @@
"label": "路线效率计算权重填0以上的数字\n越大越倾向于花费较多时间提高总收益",
"default": "0.5"
},
{
"name": "disableSelfOptimization",
"type": "checkbox",
"label": "勾选后禁用根据运行记录优化路线选择的功能\n完全使用路线原有信息"
},
{
"name": "targetEliteNum",
"type": "input-text",

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 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.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

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