From da3d2e14641c3cd80bb815913648c0029fbfb0a7 Mon Sep 17 00:00:00 2001 From: MistEO Date: Tue, 22 Nov 2022 23:21:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=88=98=E6=96=97=E8=87=AA=E5=8A=A8=E7=BC=96=E9=98=9F=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E9=94=99=E8=AF=AF=E6=97=B6=E7=9A=84=E9=87=8D=E8=AF=95?= =?UTF-8?q?=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Task/Sub/BattleFormationTask.cpp | 27 +++++++++++++++---- .../Task/Sub/BattleFormationTask.h | 1 + 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/MeoAssistant/Task/Sub/BattleFormationTask.cpp b/src/MeoAssistant/Task/Sub/BattleFormationTask.cpp index 72a4f37930..ca821e2dbf 100644 --- a/src/MeoAssistant/Task/Sub/BattleFormationTask.cpp +++ b/src/MeoAssistant/Task/Sub/BattleFormationTask.cpp @@ -29,13 +29,26 @@ bool asst::BattleFormationTask::_run() for (auto& [role, oper_groups] : m_formation) { click_role_table(role); - // TODO: 需要加一个滑到头了的检测 + bool has_error = false; while (!need_exit()) { - select_opers_in_cur_page(oper_groups); - if (oper_groups.empty()) { - break; + if (select_opers_in_cur_page(oper_groups)) { + has_error = false; + if (oper_groups.empty()) { + break; + } + swipe_page(); + } + else if (has_error) { + // reset page + click_role_table(role == BattleRole::Unknown ? BattleRole::Pioneer : BattleRole::Unknown); + click_role_table(role); + has_error = false; + } + else { + has_error = true; + // swipe and retry again + swipe_page(); } - swipe_page(); } } confirm_selection(); @@ -80,6 +93,10 @@ bool asst::BattleFormationTask::select_opers_in_cur_page(std::vector& return lhs.rect.y < rhs.rect.y; } }); + if (m_the_right_name == opers_result.back().text) { + return false; + } + m_the_right_name = opers_result.back().text; static const std::array SkillRectArray = { Task.get("BattleQuickFormationSkill1")->specific_rect, diff --git a/src/MeoAssistant/Task/Sub/BattleFormationTask.h b/src/MeoAssistant/Task/Sub/BattleFormationTask.h index ae92f96de8..affeb930dc 100644 --- a/src/MeoAssistant/Task/Sub/BattleFormationTask.h +++ b/src/MeoAssistant/Task/Sub/BattleFormationTask.h @@ -25,5 +25,6 @@ namespace asst std::string m_stage_name; std::unordered_map> m_formation; + std::string m_the_right_name; }; }