From 02b22be73f79a0f2abc6166b8161254c68f4bc7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E4=BA=91?= Date: Fri, 1 May 2026 21:02:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=88=98=E6=96=97?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8F=96=E6=B6=88=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot --- repo/js/AutoFriendshipFight/main.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/repo/js/AutoFriendshipFight/main.js b/repo/js/AutoFriendshipFight/main.js index 964356634..e65c7e02d 100644 --- a/repo/js/AutoFriendshipFight/main.js +++ b/repo/js/AutoFriendshipFight/main.js @@ -663,7 +663,7 @@ async function executeBattleTasks(fightTimeout, enemyType, cts, battlePointCoord // 同步战斗模式:依赖配置组的“战斗结束检测”让 AutoFight 自行退出 // 额外增加 watchdog:超过 fightTimeout 仍未退出则取消任务,避免无限战斗 const maxDetectMs = Math.max(0, Number(fightTimeout) * 1000); - battleTask = dispatcher.RunTask(new SoloTask("AutoFight"), cts); + battleTask = dispatcher.runTask(new SoloTask("AutoFight"), cts); const battleWrapped = battleTask .then(value => ({ kind: "battle_fulfilled", value })) .catch(error => ({ kind: "battle_rejected", error })); @@ -691,7 +691,7 @@ async function executeBattleTasks(fightTimeout, enemyType, cts, battlePointCoord } } else { // 异步战斗模式:并发启动战斗 + OCR 检测结果;检测到结果后取消战斗任务 - battleTask = dispatcher.RunTask(new SoloTask("AutoFight"), cts); + battleTask = dispatcher.runTask(new SoloTask("AutoFight"), cts); battleDetectTask = waitForBattleResult(fightTimeout * 1000, enemyType, cts, battlePointCoords); const maxDetectMs = Math.max(0, Number(fightTimeout) * 1000); const graceMs = Math.min(8000, maxDetectMs); @@ -1189,7 +1189,7 @@ async function waitForBattleResult(timeout = 2 * 60 * 1000, enemyType = "盗宝 text2 = text2 ? text2.replace(/\s+/g, "") : ""; if (enemyType === "蕈兽" && text2.includes("维沙瓦")) { log.info("战斗结果:成功"); - cts.cancel(); + try{ cts.cancel(); } catch{} // 取消任务 return "success"; } @@ -1199,7 +1199,7 @@ async function waitForBattleResult(timeout = 2 * 60 * 1000, enemyType = "盗宝 if (text.includes(keyword)) { log.info("检测到战斗成功关键词: {0}", keyword); log.info("战斗结果:成功"); - cts.cancel(); // 取消任务 + try{ cts.cancel(); } catch{} // 取消任务 return "success"; } } @@ -1209,7 +1209,7 @@ async function waitForBattleResult(timeout = 2 * 60 * 1000, enemyType = "盗宝 for (let keyword of failureKeywords) { if (text.includes(keyword)) { log.warn("检测到战斗失败关键词: {0}", keyword); - cts.cancel(); // 取消任务 + try{ cts.cancel(); } catch{} // 取消任务 return "failure"; } } @@ -1243,12 +1243,12 @@ async function waitForBattleResult(timeout = 2 * 60 * 1000, enemyType = "盗宝 if (nearBattlePoint) { log.info("触发关键词消失但仍在战斗点附近,视为本轮结束"); - cts.cancel(); + try{ cts.cancel(); } catch{} // 取消任务 return "success"; } log.warn("不在任务触发区域,战斗失败"); - cts.cancel(); // 取消任务 + try{ cts.cancel(); } catch{} // 取消任务 return "out_of_area"; } @@ -1269,7 +1269,7 @@ async function waitForBattleResult(timeout = 2 * 60 * 1000, enemyType = "盗宝 } log.warn("在超时时间内未检测到战斗结果"); - cts.cancel(); // 取消任务 + try{ cts.cancel(); } catch{} // 取消任务 throw createScriptError(ERROR_CODES.BATTLE_TIMEOUT, ERR_MESSAGES.BATTLE_TIMEOUT); }