mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
perf.为滑动选择干员增加容错操作
This commit is contained in:
@@ -905,7 +905,7 @@
|
||||
300
|
||||
],
|
||||
"preDelay": 1000,
|
||||
"rearDelay": 1000,
|
||||
"rearDelay": 300,
|
||||
"Doc": "这里的preDelay作为滑动duration使用,rearDelay作为滑动额外延时使用"
|
||||
},
|
||||
"InfrastOperListSwipeEnd": {
|
||||
|
||||
@@ -18,26 +18,32 @@ bool asst::InfrastOfficeTask::run()
|
||||
|
||||
swipe_to_the_right_of_main_ui();
|
||||
enter_facility(FacilityName, 0);
|
||||
|
||||
click_bottomleft_tab();
|
||||
swipe_to_the_left_of_operlist();
|
||||
|
||||
opers_detect_with_swipe();
|
||||
swipe_to_the_left_of_operlist();
|
||||
constexpr int retry_times = 1;
|
||||
for (int i = 0; i <= retry_times; ++i) {
|
||||
swipe_to_the_left_of_operlist();
|
||||
opers_detect_with_swipe();
|
||||
swipe_to_the_left_of_operlist();
|
||||
|
||||
auto find_iter = std::find_if(m_all_available_opers.begin(), m_all_available_opers.end(),
|
||||
[&](const InfrastOperSkillInfo& info) -> bool {
|
||||
return info.selected;
|
||||
});
|
||||
// 如果之前有干员在,那就不换人,直接退出办公室
|
||||
if (find_iter != m_all_available_opers.end()) {
|
||||
m_all_available_opers.erase(find_iter);
|
||||
auto find_iter = std::find_if(m_all_available_opers.begin(), m_all_available_opers.end(),
|
||||
[&](const InfrastOperSkillInfo& info) -> bool {
|
||||
return info.selected;
|
||||
});
|
||||
// 如果之前有干员在,那就不换人,直接退出办公室
|
||||
if (find_iter != m_all_available_opers.end()) {
|
||||
m_all_available_opers.erase(find_iter);
|
||||
}
|
||||
else {
|
||||
optimal_calc();
|
||||
bool ret = opers_choose();
|
||||
if (!ret) {
|
||||
m_all_available_opers.clear();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
optimal_calc();
|
||||
opers_choose();
|
||||
}
|
||||
|
||||
click_confirm_button();
|
||||
click_return_button();
|
||||
|
||||
|
||||
@@ -24,29 +24,36 @@ bool asst::InfrastPowerTask::run()
|
||||
if (!enter_oper_list_page()) {
|
||||
return false;
|
||||
}
|
||||
swipe_to_the_left_of_operlist();
|
||||
|
||||
if (m_all_available_opers.empty()) {
|
||||
opers_detect_with_swipe();
|
||||
constexpr int retry_times = 1;
|
||||
for (int i = 0; i <= retry_times; ++i) {
|
||||
swipe_to_the_left_of_operlist();
|
||||
}
|
||||
else {
|
||||
opers_detect();
|
||||
}
|
||||
|
||||
auto find_iter = std::find_if(m_all_available_opers.begin(), m_all_available_opers.end(),
|
||||
[&](const InfrastOperSkillInfo& info) -> bool {
|
||||
return info.selected;
|
||||
});
|
||||
// 如果之前有干员在,那就不换人,直接退出当前发电站
|
||||
if (find_iter != m_all_available_opers.end()) {
|
||||
m_all_available_opers.erase(find_iter);
|
||||
}
|
||||
else {
|
||||
optimal_calc();
|
||||
opers_choose();
|
||||
}
|
||||
if (m_all_available_opers.empty()) {
|
||||
opers_detect_with_swipe();
|
||||
swipe_to_the_left_of_operlist();
|
||||
}
|
||||
else {
|
||||
opers_detect();
|
||||
}
|
||||
|
||||
auto find_iter = std::find_if(m_all_available_opers.begin(), m_all_available_opers.end(),
|
||||
[&](const InfrastOperSkillInfo& info) -> bool {
|
||||
return info.selected;
|
||||
});
|
||||
// 如果之前有干员在,那就不换人,直接退出当前发电站
|
||||
if (find_iter != m_all_available_opers.end()) {
|
||||
m_all_available_opers.erase(find_iter);
|
||||
}
|
||||
else {
|
||||
optimal_calc();
|
||||
bool ret = opers_choose();
|
||||
if (!ret) {
|
||||
m_all_available_opers.clear();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
click_confirm_button();
|
||||
click_return_button();
|
||||
}
|
||||
|
||||
@@ -74,18 +74,27 @@ bool asst::InfrastProductionTask::shift_facility_list()
|
||||
/* 进入干员选择页面 */
|
||||
ctrler.click(add_button);
|
||||
sleep(add_task_ptr->rear_delay);
|
||||
click_clear_button();
|
||||
swipe_to_the_left_of_operlist();
|
||||
|
||||
if (m_all_available_opers.empty()) {
|
||||
opers_detect_with_swipe();
|
||||
constexpr int retry_times = 1;
|
||||
for (int i = 0; i <= retry_times; ++i) {
|
||||
click_clear_button();
|
||||
swipe_to_the_left_of_operlist();
|
||||
|
||||
if (m_all_available_opers.empty()) {
|
||||
opers_detect_with_swipe();
|
||||
swipe_to_the_left_of_operlist();
|
||||
}
|
||||
else {
|
||||
opers_detect();
|
||||
}
|
||||
optimal_calc();
|
||||
bool ret = opers_choose();
|
||||
if (!ret) {
|
||||
m_all_available_opers.clear();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
opers_detect();
|
||||
}
|
||||
optimal_calc();
|
||||
opers_choose();
|
||||
click_confirm_button();
|
||||
}
|
||||
return true;
|
||||
@@ -313,6 +322,7 @@ bool asst::InfrastProductionTask::optimal_calc()
|
||||
|
||||
bool asst::InfrastProductionTask::opers_choose()
|
||||
{
|
||||
bool has_error = false;
|
||||
while (true) {
|
||||
const auto& image = ctrler.get_image();
|
||||
|
||||
@@ -326,6 +336,20 @@ bool asst::InfrastProductionTask::opers_choose()
|
||||
|
||||
auto cur_all_info = skills_analyzer.get_result();
|
||||
|
||||
// 这个情况一般是滑动/识别出错了,把所有的干员都滑过去了
|
||||
if (cur_all_info.empty()) {
|
||||
if (!has_error) {
|
||||
has_error = true;
|
||||
// 倒回去再来一遍
|
||||
swipe_to_the_left_of_operlist();
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
// 如果已经出过一次错了,那就可能不是opers_choose出错,而是之前的opers_detect出错了
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> selected_hash;
|
||||
for (auto opt_iter = m_optimal_opers.begin(); opt_iter != m_optimal_opers.end();) {
|
||||
auto find_iter = std::find_if(cur_all_info.cbegin(), cur_all_info.cend(),
|
||||
|
||||
@@ -151,17 +151,23 @@ bool asst::InfrastReceptionTask::shift()
|
||||
ctrler.click(add_analyzer.get_result().rect);
|
||||
sleep(add_task_ptr->rear_delay);
|
||||
|
||||
swipe_to_the_left_of_operlist();
|
||||
click_clear_button();
|
||||
constexpr int retry_times = 1;
|
||||
for (int i = 0; i <= retry_times; ++i) {
|
||||
swipe_to_the_left_of_operlist();
|
||||
click_clear_button();
|
||||
|
||||
opers_detect_with_swipe();
|
||||
swipe_to_the_left_of_operlist();
|
||||
|
||||
optimal_calc();
|
||||
opers_choose();
|
||||
opers_detect_with_swipe();
|
||||
swipe_to_the_left_of_operlist();
|
||||
|
||||
optimal_calc();
|
||||
bool ret = opers_choose();
|
||||
if (!ret) {
|
||||
m_all_available_opers.clear();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
click_confirm_button();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user