diff --git a/repo/js/AutoArtifactsPro/assets/BackUp/record.txt b/repo/js/AutoArtifactsPro/assets/BackUp/record.txt index bd1508bf..3ed0da78 100644 --- a/repo/js/AutoArtifactsPro/assets/BackUp/record.txt +++ b/repo/js/AutoArtifactsPro/assets/BackUp/record.txt @@ -1,6 +1,7 @@ 上次运行完成日期: 2025/05/25 上次结束时间: 2025-05-24T20:00:00.000Z 上次运行路线: A +js版本:1.3.0 历史收益: 日期:2025/05/25,运行路线F,狗粮经验-1,摩拉-1 日期:2025/05/24,运行路线F,狗粮经验-1,摩拉-1 diff --git a/repo/js/AutoArtifactsPro/main.js b/repo/js/AutoArtifactsPro/main.js index 7a45b3e6..4cab3a19 100644 --- a/repo/js/AutoArtifactsPro/main.js +++ b/repo/js/AutoArtifactsPro/main.js @@ -6,13 +6,11 @@ const DEFAULT_FIGHT_TIMEOUT_SECONDS = 120; await fakeLog("自动狗粮重制版", true, true, 0); //预处理 - //settings 获取自定义配置 const minIntervalTime = settings.minIntervalTime; const waitTimePeriod = settings.waitTimePeriod; const friendshipPartyName = settings.friendshipPartyName; const grindPartyName = settings.grindPartyName; const operationType = settings.operationType || "不卡时间,ab交替运行"; - let enemyType = "无"; //处理操作模式信息 @@ -43,9 +41,50 @@ const DEFAULT_FIGHT_TIMEOUT_SECONDS = 120; break; } + //处理记录文件路径 + // 获取子文件夹路径 + const accountName = settings.accountName; + log.info(`当前账户名:${accountName}`); + let subFolderPath = `records/`; + let recordFilePath = `records/${accountName}.txt`; + // 读取子文件夹中的所有文件路径 + const filesInSubFolder = file.ReadPathSync(subFolderPath); + // 检查记录文件是否存在 + let indexDoExist = false; + for (const filePath of filesInSubFolder) { + log.info(filePath); + log.info(`records\\${accountName}.txt`); + if (filePath === `records\\${accountName}.txt`) { + indexDoExist = true; + break; + } + } + if (indexDoExist) { + log.info(`records\\${accountName}.txt 存在`); + } else { + recordFilePath = `record.txt`; + subFolderPath = ``; + // 读取子文件夹中的所有文件路径 + const filesInSubFolder = file.ReadPathSync(subFolderPath); + // 检查记录文件是否存在 + for (const filePath of filesInSubFolder) { + if (filePath === `record.txt`) { + indexDoExist = true; + break; + } + } + if (indexDoExist) { + log.info(`record.txt 存在`); + } else { + log.warn(`无记录文件,将使用默认数据`); + recordFilePath = `assets\\BackUp\\record.txt`; + } + } + await sleep(1000); + //处理卡时间信息 // 异步读取文件内容 - const content = await file.readText("record.txt"); + const content = await file.readText(recordFilePath); // 初始化变量并赋予默认值 let lastRunDate = "未知"; // 默认值 @@ -91,6 +130,25 @@ const DEFAULT_FIGHT_TIMEOUT_SECONDS = 120; log.info(`上次运行完成日期: ${lastRunDate}`); log.info(`上次狗粮开始时间: ${lastEndTime.toISOString()}`); log.info(`上次运行路线: ${lastRunRoute}`); + let version = "default"; + + try { + // 读取 manifest.json 文件的内容 + const content = await file.readText("manifest.json"); + + // 解析 JSON 内容为对象 + const manifest = JSON.parse(content); + + // 获取 version 字段的值 + version = manifest.version; + + log.info(`当前js版本:${version}`); + + } catch (error) { + // 如果发生错误,记录错误信息 + log.error("读取或解析 manifest.json 文件时出错:", error); + } + // 拆分 lastRunDate 为年、月、日 const [year, month, day] = lastRunDate.split('/').map(Number); @@ -320,7 +378,7 @@ const DEFAULT_FIGHT_TIMEOUT_SECONDS = 120; if (runArtifactsResult) { //修改文件内容 log.info('尝试修改记录文件'); - await writeRecordFile(lastRunDate, lastEndTime, lastRunRoute, records); + await writeRecordFile(lastRunDate, lastEndTime, lastRunRoute, records, `records/${accountName}.txt`, version); } } @@ -354,18 +412,19 @@ const DEFAULT_FIGHT_TIMEOUT_SECONDS = 120; })(); // 异步函数,用于将变量内容写回到文件 -async function writeRecordFile(lastRunDate, lastEndTime, lastRunRoute, records) { +async function writeRecordFile(lastRunDate, lastEndTime, lastRunRoute, records, recordFilePath, version) { try { // 构造要写入文件的内容 const content = [ `上次运行完成日期: ${lastRunDate}`, `上次结束时间: ${lastEndTime.toISOString()}`, `上次运行路线: ${lastRunRoute}`, + `js版本: ${version}`, "历史收益:" ].concat(records).join('\n'); // 异步写入文件 - const result = await file.writeText("record.txt", content, false); // 覆盖写入 + const result = await file.writeText(recordFilePath, content, false); // 覆盖写入 if (result) { log.info("文件写入成功"); } else { diff --git a/repo/js/AutoArtifactsPro/manifest.json b/repo/js/AutoArtifactsPro/manifest.json index 7cf5e69e..9a8bf4f3 100644 --- a/repo/js/AutoArtifactsPro/manifest.json +++ b/repo/js/AutoArtifactsPro/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 1, "name": "自动狗粮重制版", - "version": "1.23.6", + "version": "1.3.0", "tags": ["好感", "盗宝团", "愚人众", "鳄鱼", "兽肉", "狗粮"], "description": "通过不同好感任务卡时间后运行狗粮任务以提高狗粮总收益,需要正确配置好感队伍的战斗策略,并在自定义配置中指定好感和狗粮队伍名称", "authors": [ diff --git a/repo/js/AutoArtifactsPro/record.txt b/repo/js/AutoArtifactsPro/record.txt deleted file mode 100644 index bd1508bf..00000000 --- a/repo/js/AutoArtifactsPro/record.txt +++ /dev/null @@ -1,11 +0,0 @@ -上次运行完成日期: 2025/05/25 -上次结束时间: 2025-05-24T20:00:00.000Z -上次运行路线: A -历史收益: -日期:2025/05/25,运行路线F,狗粮经验-1,摩拉-1 -日期:2025/05/24,运行路线F,狗粮经验-1,摩拉-1 -日期:2025/05/23,运行路线F,狗粮经验-1,摩拉-1 -日期:2025/05/22,运行路线F,狗粮经验-1,摩拉-1 -日期:2025/05/21,运行路线F,狗粮经验-1,摩拉-1 -日期:2025/05/20,运行路线F,狗粮经验-1,摩拉-1 -日期:2025/05/19,运行路线F,狗粮经验-1,摩拉-1 diff --git a/repo/js/AutoArtifactsPro/records/占位.json b/repo/js/AutoArtifactsPro/records/占位.json new file mode 100644 index 00000000..e69de29b diff --git a/repo/js/AutoArtifactsPro/settings.json b/repo/js/AutoArtifactsPro/settings.json index 9d0b7fca..9452fb5e 100644 --- a/repo/js/AutoArtifactsPro/settings.json +++ b/repo/js/AutoArtifactsPro/settings.json @@ -12,6 +12,18 @@ ], "default": "不卡时间,ab交替运行" }, + { + "name": "minTimesForFirendship", + "type": "input-text", + "label": "好感任务最低运行次数\n【若卡时间好感次数不足该次数,则在狗粮结束后补齐】", + "default": "10" + }, + { + "name": "accountName", + "type": "input-text", + "label": "账户名称\n用于多用户运行时区分不同账户\n单用户无需修改", + "default": "默认账户" + }, { "name": "friendshipPartyName", "type": "input-text", @@ -37,7 +49,7 @@ { "name": "minIntervalTime", "type": "input-text", - "label": "最短间隔时间(分钟)\n【默认值为5分钟】", + "label": "最短间隔时间(分钟)\n【默认值为5分钟,过低可能导致狗粮收益下降】", "default": "5" }, { @@ -57,11 +69,5 @@ "type": "input-text", "label": "战斗超时时间(秒)\n【选填,默认为120秒】", "default": "120" - }, - { - "name": "minTimesForFirendship", - "type": "input-text", - "label": "好感任务最低运行次数\n【若卡时间好感次数不足该次数,则在狗粮结束后补齐】", - "default": "10" } ] \ No newline at end of file