feat: 自动战斗编队列表识别不到时,自动划回来重试

https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/4819
This commit is contained in:
MistEO
2023-05-20 13:52:02 +08:00
parent 82af28c929
commit eab91a6349
3 changed files with 39 additions and 2 deletions

View File

@@ -41,6 +41,7 @@ bool asst::BattleFormationTask::_run()
for (auto& [role, oper_groups] : m_formation) {
click_role_table(role);
bool has_error = false;
int swipe_times = 0;
while (!need_exit()) {
if (select_opers_in_cur_page(oper_groups)) {
has_error = false;
@@ -48,17 +49,21 @@ bool asst::BattleFormationTask::_run()
break;
}
swipe_page();
++swipe_times;
}
else if (has_error) {
swipe_to_the_left(swipe_times);
// reset page
click_role_table(role == battle::Role::Unknown ? battle::Role::Pioneer : battle::Role::Unknown);
click_role_table(role);
swipe_to_the_left(swipe_times);
swipe_times = 0;
has_error = false;
}
else {
has_error = true;
// swipe and retry again
swipe_page();
swipe_to_the_left(swipe_times);
swipe_times = 0;
}
}
}
@@ -179,6 +184,13 @@ bool asst::BattleFormationTask::select_opers_in_cur_page(std::vector<OperGroup>&
Task.get("BattleQuickFormationSkill3")->specific_rect,
};
if (opers_result.empty() || m_last_oper_name == opers_result.back().text) {
Log.info("last oper name is same as current, skip");
return false;
}
m_last_oper_name = opers_result.back().text;
int delay = Task.get("BattleQuickFormationOCR")->post_delay;
int skill = 1;
@@ -223,6 +235,13 @@ void asst::BattleFormationTask::swipe_page()
ProcessTask(*this, { "BattleFormationOperListSlowlySwipeToTheRight" }).run();
}
void asst::BattleFormationTask::swipe_to_the_left(int times)
{
for (int i = 0; i < times; ++i) {
ProcessTask(*this, { "BattleFormationOperListSwipeToTheLeft" }).run();
}
}
bool asst::BattleFormationTask::confirm_selection()
{
return ProcessTask(*this, { "BattleQuickFormationConfirm" }).run();

View File

@@ -43,6 +43,7 @@ namespace asst
bool enter_selection_page();
bool select_opers_in_cur_page(std::vector<OperGroup>& groups);
void swipe_page();
void swipe_to_the_left(int times = 2);
bool confirm_selection();
bool click_role_table(battle::Role role);
bool parse_formation();
@@ -56,5 +57,7 @@ namespace asst
std::string m_support_unit_name;
DataResource m_data_resource = DataResource::Copilot;
std::vector<AdditionalFormation> m_additional;
std::string m_last_oper_name;
};
}