mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 02:10:21 +08:00
pref: 将代码段拆进函数
This commit is contained in:
@@ -574,20 +574,7 @@ asst::AutoRecruitTask::calc_task_result_type asst::AutoRecruitTask::recruit_calc
|
||||
return result;
|
||||
}
|
||||
|
||||
std::unordered_set<std::string> final_select;
|
||||
while (final_select.size() < 3) {
|
||||
bool flag = false;
|
||||
for (const asst::RecruitCombs& comb : result_vec) {
|
||||
for (const std::string& tag : comb.tags) {
|
||||
final_select.insert(tag);
|
||||
if (final_select.size() == 3) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag) break;
|
||||
}
|
||||
}
|
||||
auto final_select = get_select_tags(result_vec);
|
||||
|
||||
// select tags
|
||||
for (const std::string& final_tag_name : final_select) {
|
||||
@@ -600,7 +587,7 @@ asst::AutoRecruitTask::calc_task_result_type asst::AutoRecruitTask::recruit_calc
|
||||
{
|
||||
json::value cb_info = basic_info();
|
||||
cb_info["what"] = "RecruitTagsSelected";
|
||||
cb_info["details"] = json::object { { "tags", json::array(get_tag_names(final_combination.tags)) } };
|
||||
cb_info["details"] = json::object { { "tags", json::array(get_tag_names(final_select)) } };
|
||||
callback(AsstMsg::SubTaskExtraInfo, cb_info);
|
||||
}
|
||||
|
||||
@@ -716,6 +703,25 @@ std::vector<std::string> asst::AutoRecruitTask::get_tag_names(const std::vector<
|
||||
return names;
|
||||
}
|
||||
|
||||
std::vector<std::string> asst::AutoRecruitTask::get_select_tags(const std::vector<RecruitCombs>& conbinations)
|
||||
{
|
||||
LogTraceFunction;
|
||||
std::unordered_set<std::string> unique_tags;
|
||||
std::vector<std::string> select;
|
||||
|
||||
while (select.size() < 3) {
|
||||
for (const asst::RecruitCombs& comb : conbinations)
|
||||
for (const std::string& tag : comb.tags) {
|
||||
if (unique_tags.find(tag) == unique_tags.cend()) {
|
||||
unique_tags.insert(tag);
|
||||
select.emplace_back(tag);
|
||||
if (select.size() == 3) return select;
|
||||
}
|
||||
}
|
||||
}
|
||||
return select;
|
||||
}
|
||||
|
||||
template <typename Rng>
|
||||
void asst::AutoRecruitTask::upload_result(const Rng& tag_ids, const json::value& yituliu_details)
|
||||
{
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace asst
|
||||
bool hire_all();
|
||||
bool initialize_dirty_slot_info(const cv::Mat&);
|
||||
std::vector<std::string> get_tag_names(const std::vector<RecruitConfig::TagId>& ids) const;
|
||||
std::vector<std::string> get_select_tags(const std::vector<RecruitCombs>& combinations);
|
||||
static std::vector<TextRect> start_recruit_analyze(const cv::Mat& image);
|
||||
|
||||
template <typename Rng>
|
||||
|
||||
Reference in New Issue
Block a user