diff --git a/docs/3.1-集成文档.md b/docs/3.1-集成文档.md index 6dd914397b..ed963a8f70 100644 --- a/docs/3.1-集成文档.md +++ b/docs/3.1-集成文档.md @@ -229,6 +229,16 @@ AsstTaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const cha } ``` +- `ReclamationAlgorithm` + + 生息演算 + +```jsonc +{ + "enable": bool +} +``` + ### `AsstSetTaskParams` #### 接口原型 diff --git a/docs/en-us/3.1-INTEGRATION.md b/docs/en-us/3.1-INTEGRATION.md index 0340e875d7..bb855219a9 100644 --- a/docs/en-us/3.1-INTEGRATION.md +++ b/docs/en-us/3.1-INTEGRATION.md @@ -217,6 +217,16 @@ For more details about auto-copilot JSON, please refer to [Copilot Schema](3.3-C } ``` +- `ReclamationAlgorithm` + + ReclamationAlgorithm + +```jsonc +{ + "enable": bool +} +``` + ### `AsstSetTaskParams` #### Prototype diff --git a/docs/ja-jp/3.1-統合ドキュメント.md b/docs/ja-jp/3.1-統合ドキュメント.md index b898f9ae33..423d7f4e66 100644 --- a/docs/ja-jp/3.1-統合ドキュメント.md +++ b/docs/ja-jp/3.1-統合ドキュメント.md @@ -216,6 +216,14 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p } ``` +- `ReclamationAlgorithm` + +```jsonc +{ + "enable": bool +} +``` + ### `AsstSetTaskParams` #### Prototype diff --git a/docs/zh-tw/3.1-集成文件.md b/docs/zh-tw/3.1-集成文件.md index 945e3775ae..b55827a57f 100644 --- a/docs/zh-tw/3.1-集成文件.md +++ b/docs/zh-tw/3.1-集成文件.md @@ -216,6 +216,15 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p } ``` +- `ReclamationAlgorithm` + 生息演算 + +```jsonc +{ + "enable": bool +} +``` + ### `AsstSetTaskParams` #### 介面原型 diff --git a/resource/tasks.json b/resource/tasks.json index b5f8cce6d8..2ceb51c136 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -9896,11 +9896,62 @@ "action": "ClickSelf", "postDelay": 500, "next": [ + "Reclamation@EmptyInitUnits", "Reclamation@InitSupplyAll", "Reclamation@ClickChooseInitUnits", "Reclamation@ReturnTo" ] }, + "Reclamation@EmptyInitUnits":{ + "algorithm": "OcrDetect", + "roi": [ + 592, 595, 336, 125 + ], + "text": [ + "请选择", "参加", "演算" + ], + "next": [ + "Reclamation@QuickFormation", + "Reclamation@QuickFormationSelectOneUnit" + ] + }, + "Reclamation@QuickFormation":{ + "roi": [ + 958, 0, 175, 144 + ], + "action": "ClickSelf", + "next": [ + "Reclamation@QuickFormationSelectOneUnit", + "Reclamation@QuickFormation" + ] + }, + "Reclamation@FormationConfirmBase":{ + "template": "Reclamation@FormationConfirm.png", + "roi": [ + 862, 604, 358, 116 + ] + }, + "Reclamation@QuickFormationSelectOneUnit":{ + "baseTask": "Reclamation@FormationConfirmBase", + "template": "Reclamation@FormationConfirm.png", + "action": "ClickRect", + "specificRect": [ + 506, 116, 186, 57 + ], + "next": [ + "Reclamation@QuickFormationConfirm" + ] + }, + "Reclamation@QuickFormationConfirm":{ + "baseTask": "Reclamation@FormationConfirmBase", + "template": "Reclamation@FormationConfirm.png", + "action": "ClickSelf", + "next": [ + "Reclamation@EmptyInitUnits", + "Reclamation@InitSupplyAll", + "Reclamation@ConfirmStart" + ] + }, "Reclamation@InitSupplyAll": { "roi": [ 862, diff --git a/resource/template/Reclamation@FormationConfirm.png b/resource/template/Reclamation@FormationConfirm.png new file mode 100644 index 0000000000..a8a5eecec5 Binary files /dev/null and b/resource/template/Reclamation@FormationConfirm.png differ diff --git a/resource/template/Reclamation@QuickFormation.png b/resource/template/Reclamation@QuickFormation.png new file mode 100644 index 0000000000..9a918919f2 Binary files /dev/null and b/resource/template/Reclamation@QuickFormation.png differ 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));