diff --git a/README_ja-JP.md b/README_ja-JP.md index e66f64d147..f517cbd619 100644 --- a/README_ja-JP.md +++ b/README_ja-JP.md @@ -67,8 +67,8 @@ MAAは、MAA Assistant Arknightsです。 ### 基本設定 -1. この[サポートされているエミュレーター(英語)](docs/en/EMULATOR_SUPPORTS.md)を参照して、対応する操作に進んでください。 -2. エミュレーター解像度を`16:9`、`1280 * 720`以上に変更してください。それより大きい解像度も大丈夫です。 +1. この[サポートされているエミュレータ(英語)](docs/en/EMULATOR_SUPPORTS.md)を参照して、対応する操作に進んでください。 +2. エミュレータ解像度を`16:9`、`1280 * 720`以上に変更してください。それより大きい解像度も大丈夫です。 3. ゲームスタート! 詳しいマニュアルは[ユーザーマニュアル(英語)](docs/en/USER_MANUAL.md)を参照してください。 diff --git a/src/MeoAssistant/AutoRecruitTask.cpp b/src/MeoAssistant/AutoRecruitTask.cpp index 47aa89eb9d..96745f2362 100644 --- a/src/MeoAssistant/AutoRecruitTask.cpp +++ b/src/MeoAssistant/AutoRecruitTask.cpp @@ -127,21 +127,12 @@ bool asst::AutoRecruitTask::_run() if (!recruit_begin()) return false; - if (!check_recruit_home_page()) { - return false; - } + static constexpr int slot_retry_limit = 3; - if (!m_use_expedited) { // analyze once only - if (!analyze_start_buttons()) return true; - } - - static constexpr size_t slot_retry_limit = 3; - - // m_cur_times means how many times has the confirm button been pressed, NOT expedited plan used - while ((m_use_expedited || !m_pending_recruit_slot.empty()) && m_cur_times != m_max_times) { + // m_cur_times means how many times has the confirm button been pressed, NOT expedited plans used + while (m_cur_times != m_max_times) { if (m_force_discard_flag) { return false; } if (m_slot_fail >= slot_retry_limit) { return false; } - if (!check_recruit_home_page()) { return false; } if (m_use_expedited) { Log.info("ready to use expedited"); if (need_exit()) return false; @@ -149,10 +140,15 @@ bool asst::AutoRecruitTask::_run() m_force_discard_flag = true; return false; } - analyze_start_buttons(); + } + auto start_rect = try_get_start_button(m_ctrler->get_image()); + if (!start_rect) { + if (!check_recruit_home_page()) return false; + Log.info("There is no available start button."); + return true; } if (need_exit()) return false; - if (!recruit_one()) + if (!recruit_one(start_rect.value())) ++m_slot_fail; else ++m_cur_times; @@ -160,25 +156,14 @@ bool asst::AutoRecruitTask::_run() return true; } -bool asst::AutoRecruitTask::analyze_start_buttons() +std::optional asst::AutoRecruitTask::try_get_start_button(const cv::Mat& image) { OcrImageAnalyzer start_analyzer; start_analyzer.set_task_info("StartRecruit"); - - auto image = m_ctrler->get_image(); start_analyzer.set_image(image); - m_pending_recruit_slot.clear(); - if (!start_analyzer.analyze()) { - Log.info("There is no start button"); - return false; - } + if (!start_analyzer.analyze()) return std::nullopt; start_analyzer.sort_result_horizontal(); - m_start_buttons = start_analyzer.get_result(); - for (size_t i = 0; i < m_start_buttons.size(); ++i) { - m_pending_recruit_slot.emplace_back(i); - } - Log.info("Recruit start button size", m_start_buttons.size()); - return true; + return start_analyzer.get_result().front().rect; } /// open a pending recruit slot, set timer and tags then confirm, or leave the slot doing nothing @@ -186,29 +171,18 @@ bool asst::AutoRecruitTask::analyze_start_buttons() /// - recognition failed /// - timer or tags corrupted /// - failed to confirm -bool asst::AutoRecruitTask::recruit_one() +bool asst::AutoRecruitTask::recruit_one(const Rect& button) { LogTraceFunction; int delay = Resrc.cfg().get_options().task_delay; - if (m_pending_recruit_slot.empty()) return false; - size_t index = m_pending_recruit_slot.front(); - if (index > m_start_buttons.size()) { - Log.info("index", index, "out of range."); - m_pending_recruit_slot.pop_front(); - return false; - } - Log.info("recruit_index", index); - Rect button = m_start_buttons.at(index).rect; m_ctrler->click(button); sleep(delay); auto calc_result = recruit_calc_task(); sleep(delay); - m_pending_recruit_slot.pop_front(); - if (!calc_result.success) { // recognition failed, perhaps open the slot again would not help { @@ -233,8 +207,7 @@ bool asst::AutoRecruitTask::recruit_one() // timer was not set to 09:00:00 properly, likely the tag selection was also corrupted // see https://github.com/MaaAssistantArknights/MaaAssistantArknights/pull/300#issuecomment-1073287984 // return and try later - Log.info("Timer of this slot has not been reduced as expected, will retry later."); - m_pending_recruit_slot.push_back(index); + Log.info("Timer of this slot has not been reduced as expected."); click_return_button(); return false; } diff --git a/src/MeoAssistant/AutoRecruitTask.h b/src/MeoAssistant/AutoRecruitTask.h index 2d28c289bb..546948327b 100644 --- a/src/MeoAssistant/AutoRecruitTask.h +++ b/src/MeoAssistant/AutoRecruitTask.h @@ -5,6 +5,7 @@ #include #include +#include namespace asst { @@ -26,8 +27,8 @@ namespace asst virtual bool _run() override; bool is_calc_only_task() { return m_max_times <= 0 || m_confirm_level.empty(); } - bool analyze_start_buttons(); - bool recruit_one(); + static std::optional try_get_start_button(const cv::Mat&); + bool recruit_one(const Rect&); bool check_recruit_home_page(); bool recruit_begin(); bool check_time_unreduced(); @@ -54,8 +55,6 @@ namespace asst bool m_skip_robot = true; bool m_set_time = true; - std::vector m_start_buttons; - std::list m_pending_recruit_slot; int m_slot_fail = 0; int m_cur_times = 0; }; diff --git a/src/MeoAssistant/RecruitConfiger.h b/src/MeoAssistant/RecruitConfiger.h index dbd326a7ba..286a1bf08e 100644 --- a/src/MeoAssistant/RecruitConfiger.h +++ b/src/MeoAssistant/RecruitConfiger.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "AsstTypes.h" @@ -44,15 +45,20 @@ namespace asst double avg_level = 0; void update_attributes() { - double sum = 0; - min_level = 7; - max_level = 0; - for (const auto& op : opers) { - sum += op.level; - min_level = (std::min)(min_level, op.level); - max_level = (std::max)(max_level, op.level); - } - avg_level = sum / static_cast(opers.size()); + min_level = std::transform_reduce( + opers.cbegin(), opers.cend(), 7, + [](int a, int b) -> int { return (std::min)(a, b); }, + std::mem_fn(&RecruitOperInfo::level)); + + max_level = std::transform_reduce( + opers.cbegin(), opers.cend(), 0, + [](int a, int b) -> int { return (std::max)(a, b); }, + std::mem_fn(&RecruitOperInfo::level)); + + avg_level = std::transform_reduce( + opers.cbegin(), opers.cend(), 0., + std::plus{}, + std::mem_fn(&RecruitOperInfo::level)) / static_cast(opers.size()); } // intersection of two recruit combs diff --git a/src/MeoAsstGui/MeoAsstGui.csproj b/src/MeoAsstGui/MeoAsstGui.csproj index ac51dc518e..df4e31a1ba 100644 --- a/src/MeoAsstGui/MeoAsstGui.csproj +++ b/src/MeoAsstGui/MeoAsstGui.csproj @@ -55,6 +55,7 @@ x64 7.3 prompt + ..\..\x64\Release\MeoAsstGui.xml ..\..\x64\RelWithDebInfo\ diff --git a/src/MeoAsstGui/Resources/Localizations/zh-tw.xaml b/src/MeoAsstGui/Resources/Localizations/zh-tw.xaml index 01ef147450..1f870f1306 100644 --- a/src/MeoAsstGui/Resources/Localizations/zh-tw.xaml +++ b/src/MeoAsstGui/Resources/Localizations/zh-tw.xaml @@ -70,7 +70,7 @@ 切換語言 語言 - 語言設定已更改,是否現在重啟 MAA 以應用語言設定? + 語言設定已變更,是否現在重啟 MAA 以套用語言設定? 好的 稍後 提示 @@ -208,20 +208,20 @@ - - 公招識別 + + 公招辨識 小提示:和主介面的自動公招是兩個獨立的功能,請手動打開遊戲公招Tags介面後使用~ 自動設定時間 自動選擇3星Tags 自動選擇4星Tags 自動選擇5星Tags 自動選擇6星Tags - 開始識別 + 開始辨識 - 正在識別…… + 正在辨識…… - + 自動戰鬥 Beta @@ -229,7 +229,7 @@ 選擇作業 作業檔可以直接用滑鼠拖進來喔 (o゚v゚)ノ 自動編隊 - 自動編隊暫時無法識別“特別關注”的幹員 + 自動編隊暫時無法辨識“特別關注”的幹員 開始 @@ -238,18 +238,18 @@ 小提示: - 1. 請將模擬器及遊戲幀率設定為 60 幀或更高; + 1. 請將模擬器及遊戲影格率設定為 60 張或更高; 2. 請在有“開始行動”按鈕的介面再使用本功能; 3. 使用好友助戰可以關閉“自動編隊”,手動選擇幹員後開始; 4. 模擬悖論需要關閉“自動編隊”,並選好技能後處於“開始模擬”按鈕的介面再開始; - 5. “自動編隊”暫時無法識別“特別關注”的幹員,如有需求請取消特別關注或手動編隊; + 5. “自動編隊”暫時無法辨識“特別關注”的幹員,如有需求請取消特別關注或手動編隊; - 讀取檔失敗! + 讀取檔案失敗! 未找到對應作業! 請求網路服務錯誤! - 解析作業檔錯誤! - 非作業檔 - 請檢查檔內容! + 解析作業檔案錯誤! + 非作業檔案 + 請檢查檔案內容! @@ -262,7 +262,7 @@ 模擬器斷開,正在嘗試重連 重連成功,繼續任務 重連失敗,連接斷開! - 識別錯誤 + 辨識錯誤 任務出錯: 戰鬥出錯: 開始任務: @@ -270,10 +270,10 @@ 開始戰鬥: 完成戰鬥: 任務已全部完成! - 打開用戶端失敗,請檢查配置檔 + 打開用戶端失敗,請檢查設定檔 出現錯誤 已返回 - 掉落識別錯誤 + 掉落辨識錯誤 放棄上傳企鵝物流 EX 關卡,已停止 已開始行動 @@ -291,7 +291,7 @@ 戰鬥失敗 投資達到上限 遊戲崩潰,重新啟動 - 遊戲掉線,重新連接 + 遊戲斷線,重新連接 關卡:詭意行商 關卡:安全的角落 關卡:不期而遇 @@ -302,19 +302,19 @@ 本次掉落: 掉落統計: 當前設施: - 公招識別結果: + 公招辨識結果: 公招提示 公招出 {0} 星了喔! 公招出小車了喔! 選擇 當前槽位已刷新 可用幹員不足 - 關卡識別錯誤 + 關卡辨識錯誤 開始編隊 選擇幹員: 當前步驟: - 不支持的關卡,請更新 MAA 軟體版本,或檢查作業檔 - 識別結果: + 不支持的關卡,請更新 MAA 軟體版本,或檢查作業檔案 + 辨識結果: 連接失敗 正在嘗試啟動模擬器 請檢查連接設定或嘗試重啟電腦 @@ -345,7 +345,7 @@ 自動確認 4 星 自動確認 5 星 自動確認 6 星 - 勾選時識別到 1 星詞條時跳過該次招募,未勾選時將忽略 1 星詞條 + 勾選時辨識到 1 星詞條時跳過該次招募,未勾選時將忽略 1 星詞條 呃......咳嗯 diff --git a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs index 6704dbb80f..b6b5a704b2 100644 --- a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs +++ b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs @@ -1257,6 +1257,9 @@ namespace MeoAsstGui private bool _notChooseLevel1 = Convert.ToBoolean(ViewStatusStorage.Get("AutoRecruit.NotChooseLevel1", bool.TrueString)); + /// + /// Gets or sets a value indicating whether not to choose level 1. + /// public bool NotChooseLevel1 { get diff --git a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs index 7aa36b4d4d..827243194d 100644 --- a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs +++ b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs @@ -865,6 +865,9 @@ namespace MeoAsstGui } } + /// + /// Closes view model. + /// public void Close() { RequestClose();