From e0bcaff4c3070259881085c31bda955c50a09f4c Mon Sep 17 00:00:00 2001 From: NaraLan0502 <129516870+NaraLan0502@users.noreply.github.com> Date: Sat, 14 Jun 2025 20:56:06 +0800 Subject: [PATCH] =?UTF-8?q?[js]=E8=81=94=E6=9C=BA=E5=90=83=E9=87=91?= =?UTF-8?q?=E5=B8=81=E6=B4=BB=E5=8A=A8=EF=BC=9A=E5=B0=86=E8=81=94=E6=9C=BA?= =?UTF-8?q?=E8=A2=AB=E6=8B=92=E7=BB=9D=E6=97=B6=E7=9A=84=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E8=B6=85=E6=97=B6=E6=A3=80=E6=B5=8B=20(#1097?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add files via upload * Update main.js --- repo/js/AutoEatCoinPVPEvent/main.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/repo/js/AutoEatCoinPVPEvent/main.js b/repo/js/AutoEatCoinPVPEvent/main.js index 766f00c3..0b6654cd 100644 --- a/repo/js/AutoEatCoinPVPEvent/main.js +++ b/repo/js/AutoEatCoinPVPEvent/main.js @@ -123,7 +123,9 @@ await sleep(1000); // 7. 等待并确认匹配 - let matchFound = false,matchFound_1st = false; + let matchFound = false,matchFound_1st = false; //matchFound_1st:确认按钮是否点击过 + let matchTimeout = 0; //联机确认按钮超时等待(单位:秒) + let beRefusedCount = 0; //被拒绝次数 for (let i = 0; i < 60; i++) { // 最多等待60秒 const confirmRegion = captureGameRegion().deriveCrop( 1037, @@ -139,10 +141,10 @@ /*处理联机确认按钮 执行逻辑:(如有报错,自己改 或者 反馈naralan0502@gmail.com) 如果OCR识别结果数量等于0,判断是否已经点击过确认按钮(通过变量matchFound_1st确认) - 是:设置matchFound为true,跳出循环 + 是:超时等待时长matchTimeout++,若超时等待时长==13,设置matchFound为true,跳出循环 否:继续循环 如果OCR识别结果数量大于0,遍历所有识别结果 - 如果存在确认按钮,设置变量matchFound_1st = true + 如果存在确认按钮,设置变量matchFound_1st = true,超时等待t=0 */ if(confirmResults.count){ // 遍历所有识别结果 @@ -153,22 +155,22 @@ if (region.text.includes("接受")) { click(1182, 737); // 点击确认按钮 + if(matchFound_1st && (++beRefusedCount >= 3)) log.info("兄啊有点点背,被拒绝了{count}次诶", beRefusedCount); matchFound_1st = true; + log.info("匹配成功, 点击接受"); + matchTimeout = 0; break; } } } else{ - if(matchFound_1st) { + if(matchFound_1st && (++matchTimeout == 13)) { //超时等待13s(游戏内联机确认超时时长10s+冷却CD3s) matchFound = true; + log.info("点击确认成功"); break; } } - if (matchFound) { - log.info("匹配成功, 点击接受"); - break; - } await sleep(1000); }