diff --git a/resource/tasks.json b/resource/tasks.json index 7644968428..6219422c08 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -1,4 +1,4 @@ -{ +{ "SanityBegin": { "algorithm": "justreturn", "action": "doNothing", @@ -800,7 +800,7 @@ }, "DroneConfirm": { "action": "clickSelf", - "rearDelay": 3000, + "rearDelay": 2000, "templThreshold": 0.8, "next": [ "DeliverableOrder", @@ -814,7 +814,8 @@ "next": [ "DeliverableOrder", "DroneAssist-Trade" - ] + ], + "rearDelay": 2000 }, "DroneAssist-Trade-Stop": { "Doc": "如果找到了“无人机加速”按钮,却没有找到订单交付:说明上一次无人机没有把一个订单加速完成,也说明没有更多的无人机了,所以直接stop", diff --git a/src/MeoAssistance/InfrastProductionTask.cpp b/src/MeoAssistance/InfrastProductionTask.cpp index 2220745f11..11c0d16541 100644 --- a/src/MeoAssistance/InfrastProductionTask.cpp +++ b/src/MeoAssistance/InfrastProductionTask.cpp @@ -62,9 +62,14 @@ bool asst::InfrastProductionTask::shift_facility_list() continue; } auto& rect = add_analyzer.get_result().rect; - Rect add_button = add_task_ptr->rect_move; - add_button.x += rect.x; - add_button.y += rect.y; + Rect add_button = rect; + auto& rect_move = add_task_ptr->rect_move; + if (!rect_move.empty()) { + add_button.x += rect_move.x; + add_button.y += rect_move.y; + add_button.width = rect_move.width; + add_button.height = rect_move.height; + } /* 识别当前正在造什么 */ MatchImageAnalyzer product_analyzer(image); @@ -158,37 +163,18 @@ size_t asst::InfrastProductionTask::opers_detect() max_num_of_opers_per_page = (std::max)(max_num_of_opers_per_page, cur_all_info.size()); for (const auto& cur_info : cur_all_info) { - auto find_iter = std::find_if(m_all_available_opers.cbegin(), m_all_available_opers.cend(), - [&cur_info](const InfrastOperSkillInfo& info) -> bool { - int dist = utils::hamming(cur_info.hash, info.hash); - return dist < HashDistThres; - }); + auto find_iter = std::find_if( + m_all_available_opers.cbegin(), m_all_available_opers.cend(), + [&cur_info](const InfrastOperSkillInfo& info) -> bool { + int dist = utils::hamming(cur_info.hash, info.hash); + return dist < HashDistThres; + }); // 如果两个的hash距离过小,则认为是同一个干员,不进行插入 if (find_iter != m_all_available_opers.cend()) { continue; } auto pred_info = cur_info; - // 根据正则,计算当前干员的实际效率 - for (auto&& [product, formula] : pred_info.skills_comb.efficient_regex) { - std::string cur_formula = formula; - for (size_t pos = 0; pos != std::string::npos;) { - pos = cur_formula.find('[', pos); - if (pos == std::string::npos) { - break; - } - size_t rp_pos = cur_formula.find(']', pos); - if (rp_pos == std::string::npos) { - break; - // TODO 报错! - } - std::string status_key = cur_formula.substr(pos + 1, rp_pos - pos - 1); - int status_value = std::any_cast(status.get(status_key)); - cur_formula.replace(pos, rp_pos - pos + 1, std::to_string(status_value)); - } - - int eff = calculator::eval(cur_formula); - pred_info.skills_comb.efficient[product] = eff; - } + pred_info.skills_comb = efficient_regex_calc(pred_info.skills_comb); m_all_available_opers.emplace_back(std::move(pred_info)); } return cur_all_info.size(); @@ -245,6 +231,7 @@ bool asst::InfrastProductionTask::optimal_calc() cur_opers.reserve(max_num_of_opers); double cur_efficient = 0; // 条件判断,不符合的直接过滤掉 + bool meet_condition = true; for (const auto& [cond, cond_value] : group.conditions) { if (!status.exist(cond)) { continue; @@ -252,21 +239,32 @@ bool asst::InfrastProductionTask::optimal_calc() // TODO:这里做成除了不等于,还可计算大于、小于等不同条件的 int cur_value = std::any_cast(status.get(cond)); if (cur_value != cond_value) { - continue; + meet_condition = false; + break; } } + if (!meet_condition) { + continue; + } // necessary里的技能,一个都不能少 for (const InfrastSkillsComb& nec_skills : group.necessary) { - auto find_iter = std::find_if(cur_available_opers.cbegin(), cur_available_opers.cend(), - [&](const InfrastOperSkillInfo& arg) -> bool { - return arg.skills_comb == nec_skills; - }); + auto find_iter = std::find_if( + cur_available_opers.cbegin(), cur_available_opers.cend(), + [&](const InfrastOperSkillInfo& arg) -> bool { + return arg.skills_comb == nec_skills; + }); if (find_iter == cur_available_opers.cend()) { group_unavailable = true; break; } cur_opers.emplace_back(nec_skills); - cur_efficient += nec_skills.efficient.at(m_product); + if (auto iter = nec_skills.efficient_regex.find(m_product); + iter != nec_skills.efficient_regex.cend()) { + cur_efficient += efficient_regex_calc(nec_skills).efficient.at(m_product); + } + else { + cur_efficient += nec_skills.efficient.at(m_product); + } cur_available_opers.erase(find_iter); } if (group_unavailable) { @@ -289,7 +287,13 @@ bool asst::InfrastProductionTask::optimal_calc() }); if (find_iter != cur_available_opers.cend()) { cur_opers.emplace_back(opt); - cur_efficient += opt.efficient.at(m_product); + if (auto iter = opt.efficient_regex.find(m_product); + iter != opt.efficient_regex.cend()) { + cur_efficient += efficient_regex_calc(opt).efficient.at(m_product); + } + else { + cur_efficient += opt.efficient.at(m_product); + } find_iter = cur_available_opers.erase(find_iter); } else { @@ -412,6 +416,32 @@ bool asst::InfrastProductionTask::opers_choose() return true; } +asst::InfrastSkillsComb asst::InfrastProductionTask::efficient_regex_calc(InfrastSkillsComb skills_comb) const +{ + // 根据正则,计算当前干员的实际效率 + for (auto&& [product, formula] : skills_comb.efficient_regex) { + std::string cur_formula = formula; + for (size_t pos = 0; pos != std::string::npos;) { + pos = cur_formula.find('[', pos); + if (pos == std::string::npos) { + break; + } + size_t rp_pos = cur_formula.find(']', pos); + if (rp_pos == std::string::npos) { + break; + // TODO 报错! + } + std::string status_key = cur_formula.substr(pos + 1, rp_pos - pos - 1); + int status_value = std::any_cast(status.get(status_key)); + cur_formula.replace(pos, rp_pos - pos + 1, std::to_string(status_value)); + } + + int eff = calculator::eval(cur_formula); + skills_comb.efficient[product] = eff; + } + return skills_comb; +} + bool asst::InfrastProductionTask::facility_list_detect() { LogTraceFunction; diff --git a/src/MeoAssistance/InfrastProductionTask.h b/src/MeoAssistance/InfrastProductionTask.h index 7e558bd503..cfa6d1c8bb 100644 --- a/src/MeoAssistance/InfrastProductionTask.h +++ b/src/MeoAssistance/InfrastProductionTask.h @@ -29,6 +29,7 @@ namespace asst size_t opers_detect(); // 返回当前页面的干员数 bool optimal_calc(); bool opers_choose(); + InfrastSkillsComb efficient_regex_calc(InfrastSkillsComb skill_info) const; constexpr static int HashDistThres = 25; diff --git a/src/MeoAssistance/Version.h b/src/MeoAssistance/Version.h index 0e0cdf764e..616e25dc62 100644 --- a/src/MeoAssistance/Version.h +++ b/src/MeoAssistance/Version.h @@ -1,6 +1,6 @@ -#pragma once +#pragma once namespace asst { - constexpr static const char* Version = "v1.3.0"; + constexpr static const char* Version = "v1.3.1"; }