Files
躁动的氨气 ffe9d777c6 feat: 莉奈娅挖矿一条龙 (#3174)
* feat: 莉奈娅挖矿一条龙

* feat: 更新版本号

* fix: 修复一些问题

* feat: 清理路线

* feat: 添加选择
2026-05-01 21:30:13 +08:00

124 lines
4.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { checkVersion } from "./utils/version.js";
import { checkAvatar } from "./utils/avatar.js";
import { getRoutes, filterByTags, filterByRegion } from "./utils/routes.js";
import { loadRefreshData, cleanupStaleRecords, recordRoute, filterRunnableRoutes, getRouteDuration, estimateRoutesDuration, formatDuration } from "./utils/refresh.js";
(async function () {
const version = getVersion()
const minVersion = '0.60.2'
if (!checkVersion(version, minVersion)) {
log.warn(`当前 BetterGI 版本(${version})低于最低要求(${minVersion}),内部算法缺少优化,出现异常为正常情况`)
}
setGameMetrics(1920, 1080, 1);
await genshin.returnMainUi();
const partyName = settings.partyName || "";
const excludeOreTypes = Array.from(settings.excludeOreTypes || []);
const excludeRegions = Array.from(settings.excludeRegions || []);
const skipBattleRoutes = settings.skipBattleRoutes === true;
// 切换队伍
async function switchParty(partyName) {
if (!partyName) {
return;
}
try {
partyName = partyName.trim();
log.info("切换队伍: " + partyName);
if (!await genshin.switchParty(partyName)) {
log.info("切换失败,前往七天神像重试");
await genshin.tpToStatueOfTheSeven();
await genshin.switchParty(partyName);
}
} catch {
log.error("队伍切换失败");
notification.error(`队伍切换失败`);
await genshin.returnMainUi();
}
}
// 运行单条路线
async function runRoute(routePath) {
try {
await pathingScript.runFile(routePath);
} catch (err) {
log.error(`路线运行失败 ${routePath}:`, err);
}
}
// 主逻辑
await switchParty(partyName);
if (!checkAvatar("莉奈娅")) {
log.error("队伍角色检查失败 - 未找到莉奈娅,脚本终止");
return;
}
const allRoutes = await getRoutes();
if (allRoutes.length === 0) {
log.error("未找到任何路线文件请确保paths目录下存在路线文件。");
return;
}
let routes = allRoutes;
routes = filterByRegion(routes, excludeRegions);
if (excludeRegions.length > 0 && routes.length < allRoutes.length) {
log.info(`地区筛选:排除 ${allRoutes.length - routes.length} 条路线`);
}
routes = filterByTags(routes, excludeOreTypes);
if (excludeOreTypes.length > 0 && routes.length < allRoutes.length) {
log.info(`矿物筛选:排除 ${allRoutes.length - routes.length} 条路线`);
}
if (skipBattleRoutes) {
routes = filterByTags(routes, ["战斗"]);
if (routes.length < allRoutes.length) {
log.info(`跳过战斗路线:排除 ${allRoutes.length - routes.length} 条路线`);
}
}
const refreshData = loadRefreshData();
cleanupStaleRecords(refreshData, routes);
const runnableRoutes = filterRunnableRoutes(routes, refreshData);
if (runnableRoutes.length === 0) {
log.info("所有路线均未刷新,无需运行");
return;
}
log.info(`将运行 ${runnableRoutes.length}/${allRoutes.length} 条路线`);
dispatcher.addTimer(new RealtimeTimer("AutoPick"));
for (let i = 0; i < runnableRoutes.length; i++) {
const route = runnableRoutes[i];
const fileName = route.split('\\').pop();
const remaining = runnableRoutes.slice(i);
const remainingEst = estimateRoutesDuration(remaining, refreshData);
const thisRouteEst = getRouteDuration(route, refreshData);
if (thisRouteEst !== null) {
log.info(`路线 ${i + 1}/${runnableRoutes.length}: ${fileName}(预计 ${formatDuration(thisRouteEst)},剩余 ${formatDuration(remainingEst)}`);
} else {
log.info(`路线 ${i + 1}/${runnableRoutes.length}: ${fileName}(预计 ${formatDuration(remainingEst)}`);
}
const startTime = Date.now();
await runRoute(route);
await sleep(10);
const duration = (Date.now() - startTime) / 1000;
recordRoute(route, refreshData, duration);
if (i < runnableRoutes.length - 1) {
await sleep(2000);
}
}
log.info("所有路线运行完成");
})();