fix:小怪锄地规划 (#813)
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
(async function () {
|
||||
// 定义六个运行时变量,初始值分别为 2000、1000、0、0、0、0
|
||||
let runtime1 = 2000;
|
||||
let runtime2 = 1000;
|
||||
let runtime3 = 0;
|
||||
let runtime4 = 0;
|
||||
let runtime5 = 0;
|
||||
let runtime6 = 0;
|
||||
|
||||
// 从 settings 中获取最大循环次数,如果未配置则默认为 2000
|
||||
const maxLoopCount = parseInt(settings.maxLoopCount || 2000, 10);
|
||||
|
||||
@@ -27,6 +35,24 @@
|
||||
const currentHour = now.getHours(); // 获取当前时间的小时数
|
||||
const currentTime = now.toLocaleString(); // 获取完整的当前时间字符串
|
||||
|
||||
// 更新 runtime 变量
|
||||
runtime6 = runtime5;
|
||||
runtime5 = runtime4;
|
||||
runtime4 = runtime3;
|
||||
runtime3 = runtime2;
|
||||
runtime2 = runtime1;
|
||||
runtime1 = now.getTime();
|
||||
|
||||
// 检查时间差条件
|
||||
if ((runtime1 - runtime2) < 500 &&
|
||||
(runtime2 - runtime3) < 500 &&
|
||||
(runtime3 - runtime4) < 500 &&
|
||||
(runtime4 - runtime5) < 500 &&
|
||||
(runtime5 - runtime6) < 500) {
|
||||
log.info(`连续五次时间差小于 500 毫秒,循环终止。`);
|
||||
break; // 如果连续五次时间差小于 500 毫秒,退出循环
|
||||
}
|
||||
|
||||
// 如果当前时间的小时数与排除时间相同,则退出循环
|
||||
if (currentHour === excludeHour) {
|
||||
log.info(`当前时间是 ${currentTime},与排除时间小时数相同,将退出循环`);
|
||||
@@ -36,14 +62,7 @@
|
||||
// 记录当前时间
|
||||
log.info(`正在执行循环第 ${i + 1} 次,总共 ${maxLoopCount} 次,当前时间: ${currentTime}`);
|
||||
|
||||
try {
|
||||
// 运行路径追踪任务
|
||||
await pathingScript.runFile(pathFileName);
|
||||
} catch (error) {
|
||||
// 捕获并处理路径追踪任务中的错误
|
||||
log.error(`在第 ${i + 1} 次循环中运行路径追踪任务时发生错误: ${error.message}`);
|
||||
log.error("由于发生错误,将退出整个程序");
|
||||
return; // 退出整个程序
|
||||
}
|
||||
// 运行路径追踪任务
|
||||
await pathingScript.runFile(pathFileName);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -17,6 +17,15 @@
|
||||
let failCount = 0; // 失败复制的文件数量
|
||||
let routeIndex = 0; // 当前筛选的路线序号
|
||||
|
||||
// 定义六个运行时变量,初始值分别为 2000、1000、0、0、0、0
|
||||
let runtime1 = 2000;
|
||||
let runtime2 = 1000;
|
||||
let runtime3 = 0;
|
||||
let runtime4 = 0;
|
||||
let runtime5 = 0;
|
||||
let runtime6 = 0;
|
||||
|
||||
|
||||
// 日志输出配置参数
|
||||
log.info(
|
||||
`自动小怪锄地规划 - 配置信息:` +
|
||||
@@ -66,8 +75,28 @@ if (operationMode === "执行路径文件") {
|
||||
log.info(`当前任务为第 ${i + 1}/${savedRoutes.length} 个`);
|
||||
const now = new Date(); // 获取开始时间
|
||||
const startTime = now.toISOString();
|
||||
|
||||
// 更新 runtime 变量
|
||||
runtime6 = runtime5;
|
||||
runtime5 = runtime4;
|
||||
runtime4 = runtime3;
|
||||
runtime3 = runtime2;
|
||||
runtime2 = runtime1;
|
||||
runtime1 = now.getTime();
|
||||
|
||||
// 检查时间差条件
|
||||
if ((runtime1 - runtime2) < 500 &&
|
||||
(runtime2 - runtime3) < 500 &&
|
||||
(runtime3 - runtime4) < 500 &&
|
||||
(runtime4 - runtime5) < 500 &&
|
||||
(runtime5 - runtime6) < 500) {
|
||||
log.info(`连续五次时间差小于 500 毫秒,循环终止。`);
|
||||
break; // 如果连续五次时间差小于 500 毫秒,退出循环
|
||||
}
|
||||
|
||||
if (enableCooldownCheck && startTime < routeTimestamp) {
|
||||
log.info(`当前路线 ${routeName} 未刷新,跳过任务`);
|
||||
await sleep(500);
|
||||
continue; // 跳过当前循环
|
||||
}
|
||||
log.info(`当前路线 ${routeName} 已刷新或未启用CD检测,执行任务`);
|
||||
|
||||
@@ -9,6 +9,15 @@
|
||||
const requiredMonsterCount = parseInt(settings.requiredMonsterCount, 10) || 405; // 目标怪物数量
|
||||
const minSecPerMonster = parseFloat(settings.minSecPerMonster) || 0.1; // 最低秒均
|
||||
|
||||
// 定义六个运行时变量,初始值分别为 2000、1000、0、0、0、0
|
||||
let runtime1 = 2000;
|
||||
let runtime2 = 1000;
|
||||
let runtime3 = 0;
|
||||
let runtime4 = 0;
|
||||
let runtime5 = 0;
|
||||
let runtime6 = 0;
|
||||
|
||||
|
||||
// 初始化文件路径(直接内置生成)
|
||||
const indexPath = 'index.txt';
|
||||
const pathingDir = 'pathing/';
|
||||
@@ -77,11 +86,30 @@ try {
|
||||
const now = new Date();
|
||||
const startTime = now.toISOString(); // 获取开始时间
|
||||
|
||||
// 更新 runtime 变量
|
||||
runtime6 = runtime5;
|
||||
runtime5 = runtime4;
|
||||
runtime4 = runtime3;
|
||||
runtime3 = runtime2;
|
||||
runtime2 = runtime1;
|
||||
runtime1 = now.getTime();
|
||||
|
||||
// 检查时间差条件
|
||||
if ((runtime1 - runtime2) < 500 &&
|
||||
(runtime2 - runtime3) < 500 &&
|
||||
(runtime3 - runtime4) < 500 &&
|
||||
(runtime4 - runtime5) < 500 &&
|
||||
(runtime5 - runtime6) < 500) {
|
||||
log.info(`连续五次时间差小于 500 毫秒,循环终止。`);
|
||||
break; // 如果连续五次时间差小于 500 毫秒,退出循环
|
||||
}
|
||||
|
||||
// 如果启用了路线CD检测,检查当前时间是否不早于附加时间戳
|
||||
if (enableRouteCdCheck) {
|
||||
const pathCDDate = new Date(pathCD); // 将附加时间戳转换为Date对象
|
||||
if (now < pathCDDate) {
|
||||
log.info(`当前路线 ${pathName} 为第 ${i + 1}/${pathLines.length} 个,当前路线未刷新,放弃该路径`);
|
||||
await sleep(500);
|
||||
continue; // 放弃该路径
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
const recordFolder = "record"; // 存储记录文件的文件夹路径
|
||||
const timestamp = "::2000-01-01T00:00:00.000Z"; // 固定的时间戳
|
||||
|
||||
// 定义六个运行时变量,初始值分别为 2000、1000、0、0、0、0
|
||||
let runtime1 = 2000;
|
||||
let runtime2 = 1000;
|
||||
let runtime3 = 0;
|
||||
let runtime4 = 0;
|
||||
let runtime5 = 0;
|
||||
let runtime6 = 0;
|
||||
|
||||
// 从 settings 中读取用户配置,并设置默认值
|
||||
const userSettings = {
|
||||
operationMode: settings.operationMode || "执行任务(若不存在索引文件则自动创建)",
|
||||
@@ -172,10 +180,29 @@ try {
|
||||
// 获取开始时间
|
||||
const startTime = new Date();
|
||||
|
||||
// 更新 runtime 变量
|
||||
runtime6 = runtime5;
|
||||
runtime5 = runtime4;
|
||||
runtime4 = runtime3;
|
||||
runtime3 = runtime2;
|
||||
runtime2 = runtime1;
|
||||
runtime1 = startTime.getTime();
|
||||
|
||||
// 检查时间差条件
|
||||
if ((runtime1 - runtime2) < 500 &&
|
||||
(runtime2 - runtime3) < 500 &&
|
||||
(runtime3 - runtime4) < 500 &&
|
||||
(runtime4 - runtime5) < 500 &&
|
||||
(runtime5 - runtime6) < 500) {
|
||||
log.info(`连续五次时间差小于 500 毫秒,循环终止。`);
|
||||
break; // 如果连续五次时间差小于 500 毫秒,退出循环
|
||||
}
|
||||
|
||||
// 比较当前时间戳与任务的时间戳
|
||||
const entryDate = new Date(entryTimestamp);
|
||||
if (startTime <= entryDate) {
|
||||
log.info(`当前任务 ${entryName} 未刷新,跳过任务 ${i + 1}/${pathGroupEntries.length} 个`);
|
||||
await sleep(500);
|
||||
continue; // 跳过当前任务
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user