mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 18:47:55 +08:00
perf: Optimize some minor issues of recruitment
This commit is contained in:
@@ -359,7 +359,7 @@ asst::AutoRecruitTask::calc_task_result_type asst::AutoRecruitTask::recruit_calc
|
||||
json::value info = basic_info();
|
||||
std::vector<std::string> tag_name_vector;
|
||||
ranges::transform(tags, std::back_inserter(tag_name_vector), std::mem_fn(&TextRect::text));
|
||||
info["details"]["tags"] = json::array(get_tags_name(tag_name_vector));
|
||||
info["details"]["tags"] = json::array(get_tag_names(tag_name_vector));
|
||||
|
||||
// tags result
|
||||
{
|
||||
@@ -436,7 +436,7 @@ asst::AutoRecruitTask::calc_task_result_type asst::AutoRecruitTask::recruit_calc
|
||||
std::vector<json::value> result_json_vector;
|
||||
for (const auto& comb : result_vec) {
|
||||
json::value comb_json;
|
||||
comb_json["tags"] = json::array(get_tags_name(comb.tags));
|
||||
comb_json["tags"] = json::array(get_tag_names(comb.tags));
|
||||
|
||||
std::vector<json::value> opers_json_vector;
|
||||
for (const RecruitOperInfo& oper_info : ranges::reverse_view(comb.opers)) { // print reversely
|
||||
@@ -568,7 +568,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_tags_name(final_combination.tags)) } };
|
||||
cb_info["details"] = json::object { { "tags", json::array(get_tag_names(final_combination.tags)) } };
|
||||
callback(AsstMsg::SubTaskExtraInfo, cb_info);
|
||||
}
|
||||
|
||||
@@ -677,9 +677,9 @@ bool asst::AutoRecruitTask::hire_all()
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::string> asst::AutoRecruitTask::get_tags_name(std::vector<std::string> ids)
|
||||
std::vector<std::string> asst::AutoRecruitTask::get_tag_names(const std::vector<RecruitConfiger::TagId>& ids) const
|
||||
{
|
||||
std::vector<std::string> names;
|
||||
std::vector<RecruitConfiger::TagId> names;
|
||||
for (const std::string& id : ids) {
|
||||
names.emplace_back(RecruitData.get_tag_name(id));
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#pragma once
|
||||
#include "AbstractTask.h"
|
||||
|
||||
#include "AsstTypes.h"
|
||||
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "AsstTypes.h"
|
||||
#include "RecruitConfiger.h"
|
||||
|
||||
namespace asst
|
||||
{
|
||||
class ReportDataTask;
|
||||
@@ -45,7 +46,7 @@ namespace asst
|
||||
bool hire_all(const cv::Mat&);
|
||||
bool hire_all();
|
||||
bool initialize_dirty_slot_info(const cv::Mat&);
|
||||
std::vector<std::string> get_tags_name(std::vector<std::string> ids);
|
||||
std::vector<std::string> get_tag_names(const std::vector<RecruitConfiger::TagId>& ids) const;
|
||||
static std::vector<TextRect> start_recruit_analyze(const cv::Mat& image);
|
||||
|
||||
void upload_result(const json::value& details);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "Logger.hpp"
|
||||
|
||||
std::string asst::RecruitConfiger::get_tag_name(const std::string& id) const noexcept
|
||||
std::string asst::RecruitConfiger::get_tag_name(const TagId& id) const noexcept
|
||||
{
|
||||
auto iter = m_all_tags_name.find(id);
|
||||
if (iter == m_all_tags_name.cend()) {
|
||||
|
||||
@@ -81,13 +81,15 @@ namespace asst
|
||||
|
||||
class RecruitConfiger final : public SingletonHolder<RecruitConfiger>, public AbstractConfiger
|
||||
{
|
||||
public:
|
||||
using TagId = std::string;
|
||||
public:
|
||||
virtual ~RecruitConfiger() override = default;
|
||||
static constexpr int CorrectNumberOfTags = 5;
|
||||
|
||||
const std::unordered_set<std::string>& get_all_tags() const noexcept { return m_all_tags; }
|
||||
const std::vector<RecruitOperInfo>& get_all_opers() const noexcept { return m_all_opers; }
|
||||
std::string get_tag_name(const std::string& id) const noexcept;
|
||||
std::string get_tag_name(const TagId& id) const noexcept;
|
||||
|
||||
protected:
|
||||
virtual bool parse(const json::value& json) override;
|
||||
@@ -96,7 +98,7 @@ namespace asst
|
||||
|
||||
std::unordered_set<std::string> m_all_tags;
|
||||
std::vector<RecruitOperInfo> m_all_opers;
|
||||
std::unordered_map<std::string, std::string> m_all_tags_name;
|
||||
std::unordered_map<TagId, std::string> m_all_tags_name;
|
||||
};
|
||||
inline static auto& RecruitData = RecruitConfiger::get_instance();
|
||||
} // namespace asst
|
||||
|
||||
Reference in New Issue
Block a user