From a3fa80a5f94e9c04fb32e18dc3a01e3cb345bc5e Mon Sep 17 00:00:00 2001 From: wangli <342970955@qq.com> Date: Fri, 3 Feb 2023 15:55:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=9F=E6=81=AF=E6=BC=94=E7=AE=97=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BD=91=E7=BB=9C=E4=B8=8D=E4=BD=B3=E6=97=B6?= =?UTF-8?q?=E9=80=80=E5=87=BA=E8=A1=8C=E5=8A=A8=E6=85=A2=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reclamation/ReclamationBattlePlugin.cpp | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/MaaCore/Task/Reclamation/ReclamationBattlePlugin.cpp b/src/MaaCore/Task/Reclamation/ReclamationBattlePlugin.cpp index 0b1714674a..0114458002 100644 --- a/src/MaaCore/Task/Reclamation/ReclamationBattlePlugin.cpp +++ b/src/MaaCore/Task/Reclamation/ReclamationBattlePlugin.cpp @@ -38,23 +38,37 @@ bool asst::ReclamationBattlePlugin::_run() wait_until_start(false); while (!need_exit()) { + int retry = 0; while (!need_exit()) { - bool stage1 = ProcessTask(*this, { "Reclamation@ClickExitLevel" }).run(); - bool stage2 = ProcessTask(*this, { "Reclamation@ExitLevelConfirm" }).run(); + bool stage1 = ProcessTask(*this, { "Reclamation@ClickExitLevel" }).set_retry_times(0).run(); + bool stage2 = ProcessTask(*this, { "Reclamation@ExitLevelConfirm" }).set_retry_times(3).run(); + Log.info(__FUNCTION__, "| click exit level perform ", stage1, stage2); if (stage2) break; - if (!stage1 && !stage2) { - Log.info(__FUNCTION__, "| fail to operate"); + retry++; // stage1==true&&stage2==false,应该是手动按了确定或是没按到退出 + if ((!stage1 && !stage2) || retry > 5) { + // 已经到了结算界面,或是用户手动操作了 + Log.error(__FUNCTION__, "| fail to operate"); return ProcessTask(*this, { "Reclamation@Begin" }).run(); } } sleep(Task.get("Reclamation@BattleStart")->special_params.front()); + const auto img = ctrler()->get_image(); - bool check1 = check_in_battle(img, false); + bool check1 = check_in_battle(img, false); + OcrImageAnalyzer confirmAnalyzer(img); confirmAnalyzer.set_task_info("Reclamation@ExitLevelConfirm"); bool check2 = confirmAnalyzer.analyze(); - if (!check1 && !check2) break; + + // 出现Loading转一会儿就结算了,没结算还有error_next + OcrImageAnalyzer loadingAnalyzer(img); + loadingAnalyzer.set_task_info("Loading"); + bool check3 = loadingAnalyzer.analyze(); + + Log.info(__FUNCTION__, "| click exit level check ", check1, check2, check3); + + if ((!check1 && !check2) || check3) break; } sleep(Task.get("Reclamation@BattleStart")->special_params.at(1));