#include "InfrastDormTask.h" #include #include #include #include "WinMacro.h" #include "Identify.h" #include "Configer.h" using namespace asst; bool asst::InfrastDormTask::run() { if (m_controller_ptr == nullptr || m_identify_ptr == nullptr) { m_callback(AsstMsg::PtrIsNull, json::value(), m_callback_arg); return false; } // for debug //m_select_with_swipe = true; enter_station({ "Dorm", "DormMini" }, m_dorm_begin, 0.8); int dorm_index = m_dorm_begin; for (; dorm_index < DormNum; ++dorm_index) { bool to_left = false; if (dorm_index != m_dorm_begin) { enter_next_dorm(); to_left = false; } else { to_left = true; // 第一个进入的宿舍需要滑动到最左侧一下。后面的宿舍都不用了 } enter_operator_selection(); int selected = 0; if (m_select_with_swipe) { selected = select_operators_with_swipe(to_left); } else { selected = select_operators(to_left); } if (selected < MaxOperNumInDorm) { // 如果选不满5个人,说明没有更多需要休息的了,直接结束宿舍任务 break; } } m_dorm_begin = dorm_index; return true; } bool asst::InfrastDormTask::click_confirm_button() { InfrastAbstractTask::click_confirm_button(); sleep(300); // 点完确定后,如果把工作中的干员撤下来了,会再弹出来一个确认的界面,如果没撤下来则不会弹出。先识别一下再决定要不要点击 auto&& [algorithm, score, second_confirm_rect] = m_identify_ptr->find_image(m_controller_ptr->get_image(), "DormConfirm"); if (score >= Configer::TemplThresholdDefault) { m_controller_ptr->click(second_confirm_rect); } sleep(2000); return true; } bool asst::InfrastDormTask::enter_next_dorm() { static const Rect swipe_down_begin( // 向下滑动起点 Configer::WindowWidthDefault * 0.3, Configer::WindowHeightDefault * 0.8, Configer::WindowWidthDefault * 0.2, Configer::WindowWidthDefault * 0.1); static const Rect swipe_down_end( // 向下滑动终点 Configer::WindowWidthDefault * 0.3, Configer::WindowHeightDefault * 0.2, Configer::WindowWidthDefault * 0.2, Configer::WindowWidthDefault * 0.1); static const int swipe_dwon_duration = 1000; // 向下滑动持续时间 // 游戏bug,宿舍中如果“进驻信息”已被选中,直接进行滑动会被滑的很远 // 所以这里先检查一下,如果进驻信息被选中了,就先把它关了,再进行滑动 auto find_result = m_identify_ptr->find_image(m_controller_ptr->get_image(), "StationInfoSelected"); if (find_result.score >= 0.75) { m_controller_ptr->click(find_result.rect); } m_controller_ptr->swipe(swipe_down_begin, swipe_down_end, swipe_dwon_duration); static const Rect double_click_rect( Configer::WindowWidthDefault * 0.4, Configer::WindowHeightDefault * 0.4, Configer::WindowWidthDefault * 0.2, Configer::WindowWidthDefault * 0.2 ); // 游戏中的宿舍里,双击可以让当前设施回到正确的位置 m_controller_ptr->click(double_click_rect); m_controller_ptr->click(double_click_rect); return true; } bool asst::InfrastDormTask::enter_operator_selection() { // 有这些文字之一就说明“进驻信息”这个按钮已经点开了 constexpr static std::array info_opened_flags = { "当前房间入住信息","进驻人数","清空" }; std::vector