fix: 肉鸽重新编队应在首页执行 (#10465)

#9510
正常来说 cur_page 变量都是正确的,可以作为判断依据,既不用每次都划几下也不用识别左侧是否还有干员。
This commit is contained in:
uye
2024-09-30 20:40:43 +08:00
committed by GitHub
2 changed files with 34 additions and 16 deletions

View File

@@ -95,16 +95,13 @@ void asst::RoguelikeFormationTaskPlugin::clear_and_reselect()
// 清空并退出游戏会自动按等级重新排序
ProcessTask(*this, { "RoguelikeQuickFormationClearAndReselect" }).run();
m_last_detected_oper_names.clear();
oper_list.clear();
cur_page = 1;
while (analyze()) { // 返回true说明新增了干员可能还有下一页
ProcessTask(*this, { "RoguelikeRecruitOperListSlowlySwipeToTheRight" }).run();
cur_page++;
scan_oper();
// 如果新识别出的干员页数没有之前的多,说明没在最左侧开始识别
if (max_page > cur_page) {
cur_page = max_page;
swipe_to_first_page();
scan_oper();
}
cur_page--; // 最后多划了一下,退回最后一页的页码
max_page = cur_page;
// 将oper_list的每个干员重置为未选择
@@ -199,11 +196,7 @@ bool asst::RoguelikeFormationTaskPlugin::select(RoguelikeFormationImageAnalyzer:
Log.info(__FUNCTION__, "swipe from page", cur_page, "to page", oper.page);
// 在最大页码时(当总页数>=2从右往左划可能会有对不齐的问题直接划动到底
if ((cur_page > oper.page && max_page >= 2 && cur_page == max_page) || max_page == 1) {
for (; cur_page > 0; --cur_page) { // 多划一次到不存在的第0页
ProcessTask(*this, { "RoguelikeRecruitOperListSwipeToTheLeft" }).run();
}
ProcessTask(*this, { "SleepAfterOperListQuickSwipe" }).run();
cur_page = 1;
swipe_to_first_page();
}
// 中间页面划动姑且当成是相对准确的
while (cur_page > oper.page) {
@@ -219,3 +212,26 @@ bool asst::RoguelikeFormationTaskPlugin::select(RoguelikeFormationImageAnalyzer:
ctrler()->click(oper.rect);
return true;
}
void asst::RoguelikeFormationTaskPlugin::swipe_to_first_page()
{
for (; cur_page > 0; --cur_page) { // 多划一次到不存在的第0页
ProcessTask(*this, { "RoguelikeRecruitOperListSwipeToTheLeft" }).run();
}
ProcessTask(*this, { "SleepAfterOperListQuickSwipe" }).run();
cur_page = 1;
}
void asst::RoguelikeFormationTaskPlugin::scan_oper()
{
m_last_detected_oper_names.clear();
oper_list.clear();
cur_page = 1;
while (analyze()) { // 返回true说明新增了干员可能还有下一页
ProcessTask(*this, { "RoguelikeRecruitOperListSlowlySwipeToTheRight" }).run();
cur_page++;
}
cur_page--; // 最后多划了一下,退回最后一页的页码
}

View File

@@ -23,10 +23,12 @@ namespace asst
void clear_and_reselect();
bool analyze();
bool select(RoguelikeFormationImageAnalyzer::FormationOper oper);
void swipe_to_first_page();
void scan_oper();
private:
int cur_page = 0;
int max_page = 0;
int cur_page = 1;
int max_page = 1;
std::vector<RoguelikeFormationImageAnalyzer::FormationOper> oper_list;
std::vector<std::string> m_last_detected_oper_names; // 上一页识别到的干员
};