diff --git a/repo/js/CD-Aware-AutoGather/README.md b/repo/js/CD-Aware-AutoGather/README.md index c2e8bdcfc..8aef7ebb4 100644 --- a/repo/js/CD-Aware-AutoGather/README.md +++ b/repo/js/CD-Aware-AutoGather/README.md @@ -9,7 +9,7 @@ - 可设置一个或多个不运行的时间段 - 采集过程自动切换合适的队伍 -**若脚本有问题,可[点击此处进行反馈](https://github.com/babalae/bettergi-scripts-list/issues/new?template=bug_report.yml&script-name=CD-Aware-AutoGather:2.1.0&additional-info=保留此行以便通知作者:%20@Patrick-Ze%0A%0A---%0A)** +**若脚本有问题,可[点击此处进行反馈](https://github.com/babalae/bettergi-scripts-list/issues/new?template=bug_report.yml&script-name=CD-Aware-AutoGather:2.2.0&additional-info=保留此行以便通知作者:%20@Patrick-Ze%0A%0A---%0A)** # 使用前准备 diff --git a/repo/js/CD-Aware-AutoGather/lib/inventory.js b/repo/js/CD-Aware-AutoGather/lib/inventory.js index 070989e2e..0b6bab76a 100644 --- a/repo/js/CD-Aware-AutoGather/lib/inventory.js +++ b/repo/js/CD-Aware-AutoGather/lib/inventory.js @@ -132,7 +132,8 @@ const csvText = `物品,刷新机制,背包分类 烛伞蘑菇,每天0点,食物 ` -const renameMap = { "晶蝶": "晶核", "「冷鲜肉」": "冷鲜肉", "白铁矿": "白铁块", "铁矿": "铁块" }; +// 材料文件夹名: 背包物品名(准确地说是API返回的材料名) +const renameMap = { "晶蝶": "晶核", "「冷鲜肉」": "冷鲜肉"}; const supportFile = "native_supported.json"; const materialMetadata = {}; diff --git a/repo/js/CD-Aware-AutoGather/lib/lib.js b/repo/js/CD-Aware-AutoGather/lib/lib.js index 7e9c8ca2c..a975f5986 100644 --- a/repo/js/CD-Aware-AutoGather/lib/lib.js +++ b/repo/js/CD-Aware-AutoGather/lib/lib.js @@ -736,6 +736,9 @@ async function waitTpFinish(timeout = 30000) { } function calculateDistance(point1, point2) { + if (point1 === null || point2 === null) { + return null; + } const deltaX = point1.x - point2.x; const deltaY = point1.y - point2.y; const distance = Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)); diff --git a/repo/js/CD-Aware-AutoGather/main.js b/repo/js/CD-Aware-AutoGather/main.js index 0eed75ba1..690351f67 100644 --- a/repo/js/CD-Aware-AutoGather/main.js +++ b/repo/js/CD-Aware-AutoGather/main.js @@ -943,11 +943,22 @@ async function runPathTaskIfCooldownExpired(material, taskInfo) { let pathStart = logFakePathStart(fileName); let pathStartPos = await genshin.getPositionFromMap(currentMap); // 延迟抛出`UserCancelled`,以便正确更新运行记录 + const pathStartTime = new Date(); let cancel = await runPathScriptFile(jsonPath); await genshin.returnMainUi(); let pathEndPos = await genshin.getPositionFromMap(currentMap); let distance = calculateDistance(pathStartPos, pathEndPos); + if (distance === null) { + const timeDiff = (new Date() - pathStartTime) / 1000; + // TemplateMatch模式暂时无法获取新地图的坐标,在API支持前简单做个workaround + if (timeDiff > 10) { + log.warn("无法获取位置坐标,基于路径耗时更新刷新时间"); + distance = 20928; + } else { + log.warn("无法获取位置坐标,路径耗时较短,不更新刷新时间"); + } + } if (distance >= 5) { const jsonData = JSON.parse(readTextSync(jsonPath)); const jsonRegion = jsonData.info?.map_name || "Teyvat"; diff --git a/repo/js/CD-Aware-AutoGather/manifest.json b/repo/js/CD-Aware-AutoGather/manifest.json index 27b0b529b..f842c38ba 100644 --- a/repo/js/CD-Aware-AutoGather/manifest.json +++ b/repo/js/CD-Aware-AutoGather/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 1, "name": "带CD管理和目标设定的自动采集", "_version_note": "更新版本号时请一并更新README的问题反馈链接中的版本号", - "version": "2.1.0", + "version": "2.2.0", "bgi_version": "0.55.0", "description": "自动同步你通过BetterGI订阅的地图追踪任务,执行采集任务,并管理材料采集目标和刷新时间。\n支持联机模式采集和多账号记录。\n首次使用前请先简单阅读说明", "authors": [