perf: 自动战斗编队固定优先编入所有干员, 且按照作业顺序

This commit is contained in:
status102
2025-06-06 13:24:55 +08:00
parent 5a235f92d0
commit 75f4c8d01e
3 changed files with 25 additions and 17 deletions

View File

@@ -182,7 +182,8 @@ using RoleCounts = std::unordered_map<Role, int>;
namespace copilot
{
using OperUsageGroups = std::unordered_map<std::string, std::vector<OperUsage>>;
using OperUsageGroup = std::pair<std::string, std::vector<OperUsage>>;
using OperUsageGroups = std::vector<OperUsageGroup>;
enum class ActionType
{

View File

@@ -80,6 +80,20 @@ asst::battle::copilot::OperUsageGroups asst::CopilotConfig::parse_groups(const j
battle::copilot::OperUsageGroups groups;
if (auto opt = json.find<json::array>("opers")) {
for (const auto& oper_info : opt.value()) {
OperUsage oper;
oper.name = oper_info.at("name").as_string();
oper.skill = oper_info.get("skill", 1);
oper.skill_usage = static_cast<battle::SkillUsage>(oper_info.get("skill_usage", 0));
oper.skill_times = oper_info.get("skill_times", 1); // 使用技能的次数,默认为 1兼容曾经的作业
// 单个干员的,干员名直接作为组名
std::string group_name = oper.name;
groups.emplace_back(OperUsageGroup { std::move(group_name), std::vector { std::move(oper) } });
}
}
if (auto opt = json.find<json::array>("groups")) {
for (const auto& group_info : opt.value()) {
std::string group_name = group_info.at("name").as_string();
@@ -92,21 +106,7 @@ asst::battle::copilot::OperUsageGroups asst::CopilotConfig::parse_groups(const j
oper.skill_times = oper_info.get("skill_times", 1); // 使用技能的次数,默认为 1兼容曾经的作业
oper_vec.emplace_back(std::move(oper));
}
groups.emplace(std::move(group_name), std::move(oper_vec));
}
}
if (auto opt = json.find<json::array>("opers")) {
for (const auto& oper_info : opt.value()) {
OperUsage oper;
oper.name = oper_info.at("name").as_string();
oper.skill = oper_info.get("skill", 1);
oper.skill_usage = static_cast<battle::SkillUsage>(oper_info.get("skill_usage", 0));
oper.skill_times = oper_info.get("skill_times", 1); // 使用技能的次数,默认为 1兼容曾经的作业
// 单个干员的,干员名直接作为组名
std::string group_name = oper.name;
groups.emplace(std::move(group_name), std::vector { std::move(oper) });
groups.emplace_back(OperUsageGroup { std::move(group_name), std::move(oper_vec) });
}
}

View File

@@ -154,7 +154,14 @@ bool asst::BattleProcessTask::to_group()
}
for (const auto& [group_name, oper_name] : m_oper_in_group) {
auto& this_group = get_combat_data().groups[group_name];
const auto& group_it = ranges::find_if(get_combat_data().groups, [&](const OperUsageGroup& pair) {
return pair.first == group_name;
});
if (group_it == get_combat_data().groups.end()) {
Log.warn(__FUNCTION__, "Group not found in combat data: ", group_name);
continue;
}
const auto& this_group = group_it->second;
// there is a build error on macOS
// https://github.com/MaaAssistantArknights/MaaAssistantArknights/actions/runs/3779762713/jobs/6425284487
const std::string& oper_name_for_lambda = oper_name;