mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 02:23:01 +08:00
fix: 自动战斗编队时重复选中同一干员
This commit is contained in:
@@ -347,13 +347,13 @@ void asst::BattleFormationTask::report_missing_operators(std::vector<OperGroup>&
|
||||
callback(AsstMsg::SubTaskError, info);
|
||||
}
|
||||
|
||||
std::vector<asst::TemplDetOCRer::Result> asst::BattleFormationTask::analyzer_opers()
|
||||
std::vector<asst::BattleFormationTask::QuickFormationOper> asst::BattleFormationTask::analyzer_opers()
|
||||
{
|
||||
auto formation_task_ptr = Task.get("BattleQuickFormationOCR");
|
||||
auto image = ctrler()->get_image();
|
||||
const auto& ocr_replace = Task.get<OcrTaskInfo>("CharsNameOcrReplace");
|
||||
std::vector<TemplDetOCRer::Result> opers_result;
|
||||
|
||||
std::vector<QuickFormationOper> opers_result;
|
||||
cv::Mat select;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
std::string task_name = "BattleQuickFormation-OperNameFlag" + std::to_string(i);
|
||||
|
||||
@@ -378,7 +378,11 @@ std::vector<asst::TemplDetOCRer::Result> asst::BattleFormationTask::analyzer_ope
|
||||
if (find_it != opers_result.end() || res.text.empty()) {
|
||||
continue;
|
||||
}
|
||||
opers_result.emplace_back(std::move(res));
|
||||
QuickFormationOper oper(res);
|
||||
select = make_roi(image, res.flag_rect.move({ 0, -10, 5, 4 }));
|
||||
cv::inRange(select, cv::Scalar(200, 140, 0), cv::Scalar(255, 180, 100), select);
|
||||
oper.is_selected = cv::hasNonZero(select);
|
||||
opers_result.emplace_back(std::move(oper));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,7 +421,8 @@ bool asst::BattleFormationTask::select_opers_in_cur_page(std::vector<OperGroup>&
|
||||
|
||||
int delay = Task.get("BattleQuickFormationOCR")->post_delay;
|
||||
int skill = 0;
|
||||
for (const auto& res : opers_result) {
|
||||
for (const auto& res :
|
||||
opers_result | views::filter([](const QuickFormationOper& oper) { return !oper.is_selected; })) {
|
||||
const std::string& name = res.text;
|
||||
bool found = false;
|
||||
auto iter = groups.begin();
|
||||
|
||||
@@ -29,6 +29,11 @@ public:
|
||||
battle::RoleCounts role_counts;
|
||||
};
|
||||
|
||||
struct QuickFormationOper : public asst::TemplDetOCRer::Result
|
||||
{
|
||||
bool is_selected = false; // 是否选中
|
||||
};
|
||||
|
||||
void append_additional_formation(AdditionalFormation formation) { m_additional.emplace_back(std::move(formation)); }
|
||||
|
||||
// 设置追加自定干员列表
|
||||
@@ -98,7 +103,7 @@ protected:
|
||||
bool select_random_support_unit();
|
||||
void report_missing_operators(std::vector<OperGroup>& groups);
|
||||
|
||||
std::vector<asst::TemplDetOCRer::Result> analyzer_opers();
|
||||
std::vector<QuickFormationOper> analyzer_opers();
|
||||
|
||||
std::string m_stage_name;
|
||||
std::unordered_map<battle::Role, std::vector<OperGroup>> m_formation;
|
||||
|
||||
Reference in New Issue
Block a user