fix: 修复自定义干员不选的问题,修复临时招募的精二干员不选的问题

This commit is contained in:
MistEO
2022-07-30 00:33:59 +08:00
parent 88fc9ef6fb
commit b2cde7665a
4 changed files with 17 additions and 3 deletions

View File

@@ -126,6 +126,7 @@ namespace asst
Rect rect;
int elite = 0;
int level = 0;
bool required = false;
};
using BattleAttackRange = std::vector<Point>;

View File

@@ -213,8 +213,14 @@ void asst::OcrImageAnalyzer::sort_result_by_required()
m_req_cache.emplace(m_required.at(i), i + 1);
}
// 不在 m_required 中的将被排在最后
std::sort(get_result().begin(), get_result().end(),
[&m_req_cache](const auto& lhs, const auto& rhs) -> bool {
return m_req_cache[lhs.text] < m_req_cache[rhs.text];
size_t lvalue = m_req_cache[lhs.text];
size_t rvalue = m_req_cache[rhs.text];
if (lvalue == 0) {
return false;
}
return lvalue < rvalue;
});
}

View File

@@ -15,12 +15,12 @@ bool asst::RoguelikeRecruitImageAnalyzer::analyze()
analyzer.set_replace(
Task.get<OcrTaskInfo>("CharsNameOcrReplace")->replace_map);
analyzer.set_required(Resrc.roguelike_recruit().get_oper_order());
if (!analyzer.analyze()) {
return false;
}
const auto& order = Resrc.roguelike_recruit().get_oper_order();
analyzer.set_required(order);
analyzer.sort_result_by_required();
for (const auto& [_, rect, name] : analyzer.get_result()) {
@@ -32,6 +32,7 @@ bool asst::RoguelikeRecruitImageAnalyzer::analyze()
info.name = name;
info.elite = elite;
info.level = level;
info.required = std::find(order.cbegin(), order.cend(), name) != order.cend();
Log.info(__FUNCTION__, name, elite, level, rect.to_string());
m_result.emplace_back(std::move(info));

View File

@@ -57,6 +57,9 @@ bool asst::RoguelikeRecruitTaskPlugin::_run()
if (!recruited) {
for (const auto& info : oper_list) {
if (!info.required) {
continue;
}
// 拿个精一 50 以上的
if (info.elite == 0 ||
(info.elite == 1 && info.level < 50)) {
@@ -71,6 +74,9 @@ bool asst::RoguelikeRecruitTaskPlugin::_run()
Log.info("All are lower");
// 随便招个精一的
for (const auto& info : oper_list) {
if (!info.required) {
continue;
}
if (info.elite == 0) {
continue;
}