From 2a7f0db5e8e505ff06cdf62567e8d35d5743ed4e Mon Sep 17 00:00:00 2001 From: SmilingPie <86896922+KevinT3Hu@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:50:20 +0800 Subject: [PATCH] feat: stop and log when missing operators during formarion (#8051) * feat: stop and log when missing operators during formarion * format: update format * style: remove tab --- .../Miscellaneous/BattleFormationTask.cpp | 34 +++++++++++++++++-- .../Task/Miscellaneous/BattleFormationTask.h | 2 ++ src/MaaWpfGui/Main/AsstProxy.cs | 12 +++++++ src/MaaWpfGui/Res/Localizations/en-us.xaml | 1 + src/MaaWpfGui/Res/Localizations/ja-jp.xaml | 1 + src/MaaWpfGui/Res/Localizations/ko-kr.xaml | 1 + src/MaaWpfGui/Res/Localizations/zh-cn.xaml | 1 + src/MaaWpfGui/Res/Localizations/zh-tw.xaml | 1 + 8 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/MaaCore/Task/Miscellaneous/BattleFormationTask.cpp b/src/MaaCore/Task/Miscellaneous/BattleFormationTask.cpp index 7a113a4ea7..7231050b02 100644 --- a/src/MaaCore/Task/Miscellaneous/BattleFormationTask.cpp +++ b/src/MaaCore/Task/Miscellaneous/BattleFormationTask.cpp @@ -58,15 +58,19 @@ bool asst::BattleFormationTask::_run() if (m_select_formation_index > 0 && !select_formation(m_select_formation_index)) { return false; } - + if (!enter_selection_page()) { save_img(utils::path("debug") / utils::path("other")); return false; } - + for (auto& [role, oper_groups] : m_formation) { - add_formation(role, oper_groups); + if (!add_formation(role,oper_groups)) { + report_missing_operators(oper_groups); + return false; + } } + if (m_add_user_additional) { for (const auto& [name, skill] : m_user_additional) { if (m_operators_in_formation.contains(name)) { @@ -109,6 +113,7 @@ bool asst::BattleFormationTask::add_formation(battle::Role role, std::vector& groups) { + auto info = basic_info(); + + std::vector oper_names; + for (auto& group : groups) { + for (auto& oper : group) { + oper_names.push_back(oper.name); + } + } + + info["why"] = "OperatorMissing"; + + info["details"] = json::object { { "opers", json::array(oper_names) } }; + callback(AsstMsg::SubTaskError, info); +} + std::vector asst::BattleFormationTask::analyzer_opers() { auto formation_task_ptr = Task.get("BattleQuickFormationOCR"); diff --git a/src/MaaCore/Task/Miscellaneous/BattleFormationTask.h b/src/MaaCore/Task/Miscellaneous/BattleFormationTask.h index bb70d74220..d14e0ab2bd 100644 --- a/src/MaaCore/Task/Miscellaneous/BattleFormationTask.h +++ b/src/MaaCore/Task/Miscellaneous/BattleFormationTask.h @@ -62,6 +62,7 @@ namespace asst bool parse_formation(); bool select_formation(int select_index); bool select_random_support_unit(); + void report_missing_operators(std::vector& groups); std::vector analyzer_opers(); @@ -78,5 +79,6 @@ namespace asst std::vector m_additional; std::string m_last_oper_name; int m_select_formation_index = 0; + int m_missing_retry_times = 2; }; } // namespace asst diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index be6ed3358b..8507b78d2a 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -827,6 +827,18 @@ namespace MaaWpfGui.Main case "CheckStageValid": Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("TheEx"), UiLogColor.Error); break; + + case "BattleFormationTask": + { + var why = details.TryGetValue("why", out var whyObj) ? whyObj.ToString() : string.Empty; + if (why == "OperatorMissing") + { + var missingOpers = details["details"]["opers"].ToObject>(); + Instances.CopilotViewModel.AddLog(LocalizationHelper.GetString("MissingOperators") + string.Join(", ", missingOpers), UiLogColor.Error); + } + + break; + } } } diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index c14e5cb548..723a535b86 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -602,6 +602,7 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla Drops recognition error Abort upload to Penguin Statistics No bonus stage, stopped + One or more of the following operators are missing: Stage Queue: Unable to use PRTS Mission started diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index 50f602a266..649f9ac1c8 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -602,6 +602,7 @@ Bilibili: ログイン インターフェイスに表示されるアカウント ドロップ認識エラー Penguin-Statsへのアップロードをあきらめました ステージ報酬がないため停止します + 次のオペレーターは1つ以上欠落しています: レベルキュー: 自動指揮利用不可 行動開始しました diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index 2c1ec8ee9e..d96bd20bc3 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -602,6 +602,7 @@ Bilibili: 로그인 인터페이스에 표시되는 계정 이름(예: 장산) 드롭 인식 오류 펭귄 물류에 업로드 불가 EX 스테이지가 없어 중단되었습니다 + 다음 연산자 중 하나 이상이 누락되었습니다. 레벨 대기열: 프록시 명령을 사용할 수 없습니다 행동 개시 diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index 95eddc821d..ad98e6c571 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -602,6 +602,7 @@ 掉落识别错误 放弃上传企鹅物流 无奖励关卡,已停止 + 缺少以下干员中的一个或多个: 关卡队列: 无法使用代理指挥 已开始行动 diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index 317c763b34..e1b3699b2a 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -600,6 +600,7 @@ 掉落辨識錯誤 放棄上傳企鵝物流 無獎勵關卡,已停止 + 缺少以下一個或多個幹員: 關卡隊列: 無法使用代理指揮 已開始行動