mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 01:59:33 +08:00
feat: 自动战斗编队列表识别不到时,自动划回来重试
https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/4819
This commit is contained in:
@@ -7286,6 +7286,21 @@
|
||||
20
|
||||
]
|
||||
},
|
||||
"BattleFormationOperListSwipeToTheLeft": {
|
||||
"baseTask": "SwipeToTheLeft",
|
||||
"specificRect": [
|
||||
400,
|
||||
350,
|
||||
20,
|
||||
20
|
||||
],
|
||||
"rectMove": [
|
||||
1100,
|
||||
350,
|
||||
20,
|
||||
20
|
||||
]
|
||||
},
|
||||
"Roguelike@Abandon": {
|
||||
"Doc": "base_task",
|
||||
"template": "empty.png",
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user