feat: 增加 控制中枢 支持干员编组配置,以及编组选择输出

This commit is contained in:
status102
2023-09-07 08:44:38 +08:00
parent 273cbc2332
commit d224b047bf
16 changed files with 106 additions and 40 deletions

View File

@@ -47,7 +47,7 @@ icon: material-symbols:view-quilt-rounded
"rule": "all", // 使用规则,保留字段,目前无作用。以后可能拿来支持插拔等操作
"order": "pre" // 在换干员前使用还是在换完才用,可选,取值范围 "pre" / "post",默认 "pre"
},
"groups":[ // 对于制造站和贸易站,可以设置干员编组
"groups":[ // 对于 "control" / "manufacture" / "trading",可以设置干员编组
{
"name":"古+银",
"operators":[

View File

@@ -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":[

View File

@@ -37,7 +37,7 @@
"rule": "all", // ルール、予約フィールド、未実装. 後で使用する可能性がある。
"order": "pre" // オペレーターの交換前後の使用設定、オプション、引数 "pre" / "post", デフォルト "pre" (テキーラなど)
},
"groups":[ // 製造ステーションと取引ステーションでは、オペレータグループを設定できます
"groups":[ // "control" / "manufacture" / "trading" の場合、オペレータグループを設定できます
{
"name":"A",
"operators":[

View File

@@ -47,7 +47,7 @@ icon: material-symbols:view-quilt-rounded
"rule": "all", // 使用規則,保留欄位,目前無作用。以後可能拿來支援插拔等操作
"order": "pre" // 在換幹員前使用還是在換完才用,可選,取值範圍 "pre" / "post",預設 "pre"
},
"groups":[ // 對於製造站和貿易站,可以設置幹員編組
"groups":[ // 對於 "control" / "manufacture" / "trading",可以設置幹員編組
{
"name":"古+银",
"operators":[

View File

@@ -129,7 +129,7 @@ namespace asst::infrast
// 是否使用干员编组
bool use_operator_groups = false;
// 干员编组列表
std::vector<std::vector<std::string>> operator_groups;
std::unordered_map<std::string, std::vector<std::string>> operator_groups;
// 自定干员
std::vector<std::string> names;
bool autofill = false;

View File

@@ -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<std::string> oper_list;
std::vector<std::string> 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<std::string> names;
ranges::for_each(
current_room_config().operator_groups,
[&names](std::pair<const std::string, std::vector<std::string>>& 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;

View File

@@ -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<std::string>& partial_result);
// 扫描满足心情条件的所有干员

View File

@@ -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;

View File

@@ -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<std::string> oper_list;
std::vector<std::string> 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) {

View File

@@ -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<std::string, std::vector<std::string>> 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);
}
});
}

View File

@@ -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;
/* 生息演算 */

View File

@@ -540,6 +540,9 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla
<system:String x:Key="Drop" xml:space="preserve">Drops: </system:String>
<system:String x:Key="TotalDrop" xml:space="preserve">Total Drops: </system:String>
<system:String x:Key="ThisFacility" xml:space="preserve">Current Facility: </system:String>
<system:String x:Key="RoomGroupsMatch" xml:space="preserve">Match to Group: </system:String>
<system:String x:Key="RoomGroupsMatchFailed" xml:space="preserve">Failed to match operator groups, group list: </system:String>
<system:String x:Key="RoomOperators" xml:space="preserve">preferred operators: </system:String>
<system:String x:Key="ProductIncorrect">Product does NOT match the configuration.</system:String>
<system:String x:Key="ProductUnknown">Unknown Product</system:String>
<system:String x:Key="ProductChanged">Product has changed</system:String>

View File

@@ -531,6 +531,9 @@
<system:String x:Key="Drop" xml:space="preserve">ドロップ: </system:String>
<system:String x:Key="TotalDrop" xml:space="preserve">ドロップ統計: </system:String>
<system:String x:Key="ThisFacility" xml:space="preserve">現在の施設: </system:String>
<system:String x:Key="RoomGroupsMatch" xml:space="preserve">グループに合わせる: </system:String>
<system:String x:Key="RoomGroupsMatchFailed" xml:space="preserve">オペレータ グループ、グループ リストの一致に失敗しました: </system:String>
<system:String x:Key="RoomOperators" xml:space="preserve">優先しています: </system:String>
<system:String x:Key="ProductIncorrect">製品が構成と一致しません。</system:String>
<system:String x:Key="ProductUnknown">Unknown Product</system:String>
<system:String x:Key="ProductChanged">Product has changed</system:String>

View File

@@ -543,6 +543,9 @@ OF-1을 해금하지 않았다면 선택하지 말아 주세요.</system:String>
<system:String x:Key="Drop" xml:space="preserve">드롭: </system:String>
<system:String x:Key="TotalDrop" xml:space="preserve">드롭 통계: </system:String>
<system:String x:Key="ThisFacility" xml:space="preserve">현재 시설: </system:String>
<system:String x:Key="RoomGroupsMatch" xml:space="preserve">그룹에 일치: </system:String>
<system:String x:Key="RoomGroupsMatchFailed" xml:space="preserve">운영자 그룹, 그룹 목록을 일치시키지 못했습니다: </system:String>
<system:String x:Key="RoomOperators" xml:space="preserve">선호하는 연산자: </system:String>
<system:String x:Key="ProductIncorrect">생산품이 구성과 맞지 않습니다.</system:String>
<system:String x:Key="ProductUnknown">식별할 수 없는 결과물</system:String>
<system:String x:Key="ProductChanged">결과물이 변경됨</system:String>

View File

@@ -544,6 +544,9 @@
<system:String x:Key="Drop" xml:space="preserve">本次掉落: </system:String>
<system:String x:Key="TotalDrop" xml:space="preserve">掉落统计: </system:String>
<system:String x:Key="ThisFacility" xml:space="preserve">当前设施: </system:String>
<system:String x:Key="RoomGroupsMatch" xml:space="preserve">匹配到编组: </system:String>
<system:String x:Key="RoomGroupsMatchFailed" xml:space="preserve">匹配干员编组失败,编组列表: </system:String>
<system:String x:Key="RoomOperators" xml:space="preserve">首选干员: </system:String>
<system:String x:Key="ProductIncorrect">产物与配置不相符。</system:String>
<system:String x:Key="ProductUnknown">无法识别的产物</system:String>
<system:String x:Key="ProductChanged">产物已切换</system:String>

View File

@@ -80,7 +80,7 @@
<system:String x:Key="SecondResolution">第二分辨率</system:String>
<system:String x:Key="GeneralWithoutScreencapErr">通用模式(阻擋異常輸出)</system:String>
<system:String x:Key="DormThreshold">基建工作心情閾值</system:String>
<system:String x:Key="InfrastThresholdTip">若啟用自定義換班,該欄位僅針對 autofill 的房間有效</system:String>
<system:String x:Key="InfrastThresholdTip">若啟用自定義換班,該欄位僅針對 autofill 和 幹員編組 的房間有效</system:String>
<system:String x:Key="RoguelikeStrategyExp">刷等級,盡可能穩定地打更多層數</system:String>
<system:String x:Key="RoguelikeStrategyGold">刷源石錠,到達第二層後直接退出</system:String>
<system:String x:Key="RoguelikeLastReward">燒開水,到達第三層後直接退出</system:String>
@@ -543,6 +543,9 @@
<system:String x:Key="Drop" xml:space="preserve">本次掉落: </system:String>
<system:String x:Key="TotalDrop" xml:space="preserve">掉落統計: </system:String>
<system:String x:Key="ThisFacility" xml:space="preserve">當前設施: </system:String>
<system:String x:Key="RoomGroupsMatch" xml:space="preserve">匹配到編組: </system:String>
<system:String x:Key="RoomGroupsMatchFailed" xml:space="preserve">匹配幹員編組失敗,編組列表: </system:String>
<system:String x:Key="RoomOperators" xml:space="preserve">首選幹員: </system:String>
<system:String x:Key="ProductIncorrect">產物與配置不相符。</system:String>
<system:String x:Key="ProductUnknown">無法辨識的產物</system:String>
<system:String x:Key="ProductChanged">產物已切換</system:String>