From d224b047bfb6b8a7216b2db7d1017e65023eaee6 Mon Sep 17 00:00:00 2001 From: status102 Date: Thu, 7 Sep 2023 08:44:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E4=B8=AD=E6=9E=A2=20=E6=94=AF=E6=8C=81=E5=B9=B2=E5=91=98?= =?UTF-8?q?=E7=BC=96=E7=BB=84=E9=85=8D=E7=BD=AE=EF=BC=8C=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E7=BC=96=E7=BB=84=E9=80=89=E6=8B=A9=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/3.6-基建排班协议.md | 2 +- .../3.6-INFRASTRUCTURE_SCHEDULING_SCHEMA.md | 2 +- docs/ja-jp/3.6-インフラスケジュール設定.md | 2 +- docs/zh-tw/3.6-基建排班協議.md | 2 +- src/MaaCore/Common/AsstInfrastDef.h | 2 +- .../Task/Infrast/InfrastAbstractTask.cpp | 67 +++++++++++++++++++ .../Task/Infrast/InfrastAbstractTask.h | 1 + .../Task/Infrast/InfrastControlTask.cpp | 5 ++ .../Task/Infrast/InfrastProductionTask.cpp | 33 +-------- src/MaaCore/Task/Interface/InfrastTask.cpp | 2 +- src/MaaWpfGui/Main/AsstProxy.cs | 11 ++- src/MaaWpfGui/Res/Localizations/en-us.xaml | 3 + src/MaaWpfGui/Res/Localizations/ja-jp.xaml | 3 + src/MaaWpfGui/Res/Localizations/ko-kr.xaml | 3 + src/MaaWpfGui/Res/Localizations/zh-cn.xaml | 3 + src/MaaWpfGui/Res/Localizations/zh-tw.xaml | 5 +- 16 files changed, 106 insertions(+), 40 deletions(-) diff --git a/docs/3.6-基建排班协议.md b/docs/3.6-基建排班协议.md index b6e2889082..0d8b45158b 100644 --- a/docs/3.6-基建排班协议.md +++ b/docs/3.6-基建排班协议.md @@ -47,7 +47,7 @@ icon: material-symbols:view-quilt-rounded "rule": "all", // 使用规则,保留字段,目前无作用。以后可能拿来支持插拔等操作 "order": "pre" // 在换干员前使用还是在换完才用,可选,取值范围 "pre" / "post",默认 "pre" }, - "groups":[ // 对于制造站和贸易站,可以设置干员编组 + "groups":[ // 对于 "control" / "manufacture" / "trading",可以设置干员编组 { "name":"古+银", "operators":[ diff --git a/docs/en-us/3.6-INFRASTRUCTURE_SCHEDULING_SCHEMA.md b/docs/en-us/3.6-INFRASTRUCTURE_SCHEDULING_SCHEMA.md index e6134a6d77..056927a8ac 100644 --- a/docs/en-us/3.6-INFRASTRUCTURE_SCHEDULING_SCHEMA.md +++ b/docs/en-us/3.6-INFRASTRUCTURE_SCHEDULING_SCHEMA.md @@ -44,7 +44,7 @@ Usage and Field Description for `resource/custom_infrast/*.json` files "rule": "all", // Usage rules. Reserved field. Currently unused, but may be used in the future to support plug-ins and other operations. "order": "pre" // Whether to use drones before or after changing operators. Optional. Possible values: "pre" / "post". Default is "pre". }, - "groups":[ // For manufacturing stations and trading stations, operator groups can be set + "groups":[ // For "control" / "manufacture" / "trading", operator groups can be set { "name":"A", "operators":[ diff --git a/docs/ja-jp/3.6-インフラスケジュール設定.md b/docs/ja-jp/3.6-インフラスケジュール設定.md index ec3783ae74..56051509a4 100644 --- a/docs/ja-jp/3.6-インフラスケジュール設定.md +++ b/docs/ja-jp/3.6-インフラスケジュール設定.md @@ -37,7 +37,7 @@ "rule": "all", // ルール、予約フィールド、未実装. 後で使用する可能性がある。 "order": "pre" // オペレーターの交換前後の使用設定、オプション、引数 "pre" / "post", デフォルト "pre" (テキーラなど) }, - "groups":[ // 製造ステーションと取引ステーションでは、オペレータグループを設定できます + "groups":[ // "control" / "manufacture" / "trading" の場合、オペレーターグループを設定できます { "name":"A", "operators":[ diff --git a/docs/zh-tw/3.6-基建排班協議.md b/docs/zh-tw/3.6-基建排班協議.md index 1548188632..5f62b994a2 100644 --- a/docs/zh-tw/3.6-基建排班協議.md +++ b/docs/zh-tw/3.6-基建排班協議.md @@ -47,7 +47,7 @@ icon: material-symbols:view-quilt-rounded "rule": "all", // 使用規則,保留欄位,目前無作用。以後可能拿來支援插拔等操作 "order": "pre" // 在換幹員前使用還是在換完才用,可選,取值範圍 "pre" / "post",預設 "pre" }, - "groups":[ // 對於製造站和貿易站,可以設置幹員編組 + "groups":[ // 對於 "control" / "manufacture" / "trading",可以設置幹員編組 { "name":"古+银", "operators":[ diff --git a/src/MaaCore/Common/AsstInfrastDef.h b/src/MaaCore/Common/AsstInfrastDef.h index be0e4477fc..775641b224 100644 --- a/src/MaaCore/Common/AsstInfrastDef.h +++ b/src/MaaCore/Common/AsstInfrastDef.h @@ -129,7 +129,7 @@ namespace asst::infrast // 是否使用干员编组 bool use_operator_groups = false; // 干员编组列表 - std::vector> operator_groups; + std::unordered_map> operator_groups; // 自定干员 std::vector names; bool autofill = false; diff --git a/src/MaaCore/Task/Infrast/InfrastAbstractTask.cpp b/src/MaaCore/Task/Infrast/InfrastAbstractTask.cpp index 451bae5f26..af1d240ec4 100644 --- a/src/MaaCore/Task/Infrast/InfrastAbstractTask.cpp +++ b/src/MaaCore/Task/Infrast/InfrastAbstractTask.cpp @@ -85,6 +85,73 @@ asst::infrast::CustomRoomConfig& asst::InfrastAbstractTask::current_room_config( } } +bool asst::InfrastAbstractTask::match_operator_groups() +{ + current_room_config().names.clear(); + int swipe_times = 0; + bool pre_result_no_changes = false, retried = false; + + std::set oper_list; + std::vector temp, pre_temp; + while (true) { + if (need_exit()) { + return false; + } + temp.clear(); + if (!get_opers(temp, m_mood_threshold)) { + return false; + } + if (pre_temp == temp) { + if (pre_result_no_changes) { + Log.warn("partial result is not changed, reset the page"); + if (retried) { + Log.error("already retring"); + break; + } + swipe_to_the_left_of_operlist(swipe_times + 1); + swipe_times = 0; + retried = true; + } + else { + pre_result_no_changes = true; + } + } + else { + pre_result_no_changes = false; + } + oper_list.insert(temp.begin(), temp.end()); + pre_temp = temp; + swipe_of_operlist(); + swipe_times++; + } + swipe_to_the_left_of_operlist(swipe_times + 1); + swipe_times = 0; + // 筛选第一个满足要求的干员组 + for (auto it = current_room_config().operator_groups.begin(); it != current_room_config().operator_groups.end(); + ++it) { + if (ranges::all_of(it->second, [oper_list](std::string& oper) { return oper_list.contains(oper); })) { + current_room_config().names.insert(current_room_config().names.end(), it->second.begin(), it->second.end()); + + json::value sanity_info = basic_info_with_what("CustomInfrastRoomGroupsMatch"); + sanity_info["details"]["group"] = it->first; + callback(AsstMsg::SubTaskExtraInfo, sanity_info); + break; + } + } + // 匹配失败,无分组可用 + if (current_room_config().names.empty() && !current_room_config().operator_groups.empty()) { + json::value info = basic_info_with_what("CustomInfrastRoomGroupsMatchFailed"); + std::vector names; + ranges::for_each( + current_room_config().operator_groups, + [&names](std::pair>& pair) { names.emplace_back(pair.first); }); + info["details"]["groups"] = json::array(std::move(names)); + callback(AsstMsg::SubTaskExtraInfo, info); + return false; + } + return true; +} + bool asst::InfrastAbstractTask::on_run_fails() { LogTraceFunction; diff --git a/src/MaaCore/Task/Infrast/InfrastAbstractTask.h b/src/MaaCore/Task/Infrast/InfrastAbstractTask.h index 826da1ce11..181eb2f2f0 100644 --- a/src/MaaCore/Task/Infrast/InfrastAbstractTask.h +++ b/src/MaaCore/Task/Infrast/InfrastAbstractTask.h @@ -41,6 +41,7 @@ namespace asst void swipe_of_operlist(); bool is_use_custom_opers(); infrast::CustomRoomConfig& current_room_config(); + bool match_operator_groups(); bool swipe_and_select_custom_opers(bool is_dorm_order = false); bool select_custom_opers(std::vector& partial_result); // 扫描满足心情条件的所有干员 diff --git a/src/MaaCore/Task/Infrast/InfrastControlTask.cpp b/src/MaaCore/Task/Infrast/InfrastControlTask.cpp index 76c485e491..5f8b61fb2c 100644 --- a/src/MaaCore/Task/Infrast/InfrastControlTask.cpp +++ b/src/MaaCore/Task/Infrast/InfrastControlTask.cpp @@ -19,6 +19,11 @@ bool asst::InfrastControlTask::_run() return false; } + // 如果是使用了编队组来排班 + if (current_room_config().use_operator_groups) { + match_operator_groups(); + } + for (int i = 0; i <= OperSelectRetryTimes; ++i) { if (need_exit()) { return false; diff --git a/src/MaaCore/Task/Infrast/InfrastProductionTask.cpp b/src/MaaCore/Task/Infrast/InfrastProductionTask.cpp index b0fe536ff8..d4d5269f82 100644 --- a/src/MaaCore/Task/Infrast/InfrastProductionTask.cpp +++ b/src/MaaCore/Task/Infrast/InfrastProductionTask.cpp @@ -215,38 +215,7 @@ bool asst::InfrastProductionTask::shift_facility_list() // 如果是使用了编队组来排班 if (current_room_config().use_operator_groups) { - current_room_config().names.clear(); - int swipe_times = 0; - - std::set oper_list; - std::vector temp, pre_temp; - while (true) { - if (need_exit()) { - return false; - } - temp.clear(); - if (!get_opers(temp, m_mood_threshold)) { - return false; - } - if (pre_temp == temp) { - break; - } - oper_list.insert(temp.begin(), temp.end()); - pre_temp = temp; - swipe_of_operlist(); - swipe_times++; - } - swipe_to_the_left_of_operlist(swipe_times + 1); - swipe_times = 0; - // 筛选第一个满足要求的干员组 - for (auto it = current_room_config().operator_groups.begin(); - it != current_room_config().operator_groups.end(); it++) { - - if (ranges::all_of(*it, [oper_list](std::string& oper) { return oper_list.contains(oper); })) { - current_room_config().names.insert(current_room_config().names.end(), it->begin(), it->end()); - break; - } - } + match_operator_groups(); } for (int i = 0; i <= OperSelectRetryTimes; ++i) { diff --git a/src/MaaCore/Task/Interface/InfrastTask.cpp b/src/MaaCore/Task/Interface/InfrastTask.cpp index d3c976abe0..30ce8c31a8 100644 --- a/src/MaaCore/Task/Interface/InfrastTask.cpp +++ b/src/MaaCore/Task/Interface/InfrastTask.cpp @@ -229,7 +229,7 @@ bool asst::InfrastTask::parse_and_set_custom_config(const std::filesystem::path& ranges::for_each(ori_operator_groups, [name_set, &room_config](std::pair> pair) { if (name_set.contains(pair.first)) { - room_config.operator_groups.emplace_back(pair.second); + room_config.operator_groups[pair.first] = std::move(pair.second); } }); } diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 1bc09d0ac9..cca722968e 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -1071,6 +1071,15 @@ namespace MaaWpfGui.Main Instances.CopilotViewModel.AddLog(LocalizationHelper.GetString("UnsupportedLevel"), UiLogColor.Error); break; + case "CustomInfrastRoomGroupsMatch": + // 选用xxx组编组 + Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("RoomGroupsMatch") + subTaskDetails["group"]); + break; + case "CustomInfrastRoomGroupsMatchFailed": + // 干员编组匹配失败 + JArray groups = (JArray)subTaskDetails["groups"]; + Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("RoomGroupsMatchFailed") + string.Join(", ", groups)); + break; case "CustomInfrastRoomOperators": string nameStr = string.Empty; foreach (var name in subTaskDetails["names"]) @@ -1083,7 +1092,7 @@ namespace MaaWpfGui.Main nameStr = nameStr.Remove(nameStr.Length - 2); } - Instances.TaskQueueViewModel.AddLog(nameStr.ToString()); + Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("RoomOperators") + nameStr.ToString()); break; /* 生息演算 */ diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index e2960f5d30..25d6cddaa0 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -540,6 +540,9 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla Drops: Total Drops: Current Facility: + Match to Group: + Failed to match operator groups, group list: + preferred operators: Product does NOT match the configuration. Unknown Product Product has changed diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index ed74812f28..966ea6aa73 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -531,6 +531,9 @@ ドロップ: ドロップ統計: 現在の施設: + グループに合わせる: + オペレータ グループ、グループ リストの一致に失敗しました: + 優先しています: 製品が構成と一致しません。 Unknown Product Product has changed diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index 9da0827039..b7fb72bfd0 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -543,6 +543,9 @@ OF-1을 해금하지 않았다면 선택하지 말아 주세요. 드롭: 드롭 통계: 현재 시설: + 그룹에 일치: + 운영자 그룹, 그룹 목록을 일치시키지 못했습니다: + 선호하는 연산자: 생산품이 구성과 맞지 않습니다. 식별할 수 없는 결과물 결과물이 변경됨 diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index 8b933e3075..46cb3244f1 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -544,6 +544,9 @@ 本次掉落: 掉落统计: 当前设施: + 匹配到编组: + 匹配干员编组失败,编组列表: + 首选干员: 产物与配置不相符。 无法识别的产物 产物已切换 diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index 14d861340d..3d08923d82 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -80,7 +80,7 @@ 第二分辨率 通用模式(阻擋異常輸出) 基建工作心情閾值 - 若啟用自定義換班,該欄位僅針對 autofill 的房間有效 + 若啟用自定義換班,該欄位僅針對 autofill 和 幹員編組 的房間有效 刷等級,盡可能穩定地打更多層數 刷源石錠,到達第二層後直接退出 燒開水,到達第三層後直接退出 @@ -543,6 +543,9 @@ 本次掉落: 掉落統計: 當前設施: + 匹配到編組: + 匹配幹員編組失敗,編組列表: + 首選幹員: 產物與配置不相符。 無法辨識的產物 產物已切換