From bc13dc995891c04d417c65f9923786a766741514 Mon Sep 17 00:00:00 2001 From: ftnfurina Date: Mon, 16 Jun 2025 18:07:47 +0800 Subject: [PATCH] =?UTF-8?q?JS=20=E8=84=9A=E6=9C=AC:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=8A=A0=E5=85=A5=E5=92=8C=E5=A5=BD=E5=8F=8B?= =?UTF-8?q?=E5=9C=A8=E5=BF=99=E7=AD=89=E6=83=85=E5=86=B5=E4=B8=8B=E4=BC=9A?= =?UTF-8?q?=E7=AD=89=E5=BE=85=E8=B6=85=E6=97=B6=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#1116)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repo/js/JoinFriendsWorld/index.js | 27 ++++++++++++++------------ repo/js/JoinFriendsWorld/manifest.json | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/repo/js/JoinFriendsWorld/index.js b/repo/js/JoinFriendsWorld/index.js index 52d7f6b1..e459f253 100644 --- a/repo/js/JoinFriendsWorld/index.js +++ b/repo/js/JoinFriendsWorld/index.js @@ -14,26 +14,23 @@ function createTimer(timeout) { } }); } +async function isCoOpMode() { + await genshin.returnMainUi(); + const gameRegion = captureGameRegion(); + const ocrRegion = gameRegion.find(autoZoomOcr(343, 22, 45, 45)); + const ocrText = ocrRegion.text.trim().toLocaleLowerCase(); + return ocrText.includes("p") || ocrText !== ""; +} // 等待好友确认超时时间 25s const WAIT_FRIEND_CONFIRM_TIMEOUT = 25 * 1000; -/** - * 是否在多人游戏中 - */ -function inMultiplayerGame() { - const gameRegion = captureGameRegion(); - const playerCountRegin = gameRegion.find(autoZoomOcr(340, 18, 53, 53)); - const playerCountText = playerCountRegin.text.trim().toLocaleLowerCase(); - return playerCountText.includes('p'); -} (async () => { try { const uid = settings.uid?.trim(); if (!uid) { throw new Error('UID 不能为空'); } - await genshin.returnMainUi(); - if (inMultiplayerGame()) { + if (await isCoOpMode()) { throw new Error('正在多人游戏中,无法加入好友世界'); } log.info(`尝试加入好友世界(UID: ${uid})`); @@ -81,7 +78,13 @@ function inMultiplayerGame() { if (requestText.endsWith('拒绝了多人游戏申请')) { throw new Error('好友拒绝了多人游戏'); } - if (inMultiplayerGame()) { + else if (requestText.startsWith('无法进入')) { + throw new Error('无法进入好友世界'); + } + else if (requestText.startsWith('世界主人暂忙')) { + throw new Error('好友正在忙,无法加入'); + } + if (await isCoOpMode()) { log.info('成功加入好友世界'); break; } diff --git a/repo/js/JoinFriendsWorld/manifest.json b/repo/js/JoinFriendsWorld/manifest.json index 9b3ee2d9..6d75b0ed 100644 --- a/repo/js/JoinFriendsWorld/manifest.json +++ b/repo/js/JoinFriendsWorld/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 1, "name": "加入好友的世界", "description": "快让我访问!", - "version": "0.0.2", + "version": "0.0.3", "main": "index.js", "settings_ui": "settings.json", "authors": [