diff --git a/MeoAssistance/InfrastDormTask.cpp b/MeoAssistance/InfrastDormTask.cpp index 0435fb43a2..dd7b3dc2b5 100644 --- a/MeoAssistance/InfrastDormTask.cpp +++ b/MeoAssistance/InfrastDormTask.cpp @@ -27,13 +27,16 @@ bool asst::InfrastDormTask::run() return false; } - enter_dorm(0); - for (int i = 0; i != 4; ++i) { - if (i != 0) { + enter_dorm(m_dorm_begin); + for (int i = m_dorm_begin; i != DormNum; ++i) { + if (i != m_dorm_begin) { enter_next_dorm(); } enter_operator_selection(); - select_operators(); + int selected = select_operators(); + if (selected < MaxOperNumInDorm) { // 如果选不满5个人,说明没有更多需要休息的了,直接结束宿舍任务 + break; + } } return true; @@ -164,7 +167,7 @@ bool asst::InfrastDormTask::enter_operator_selection() return true; } -bool asst::InfrastDormTask::select_operators() +int asst::InfrastDormTask::select_operators() { // 点击“清空选择”按钮 auto click_clear_button = [&]() { @@ -185,7 +188,7 @@ bool asst::InfrastDormTask::select_operators() auto resting_result = m_identify_ptr->find_all_images(image, "Resting", 0.8); if (resting_result.size() == MaxOperNumInDorm) { // 如果所有人都在休息,那这个宿舍不用换班,直接关了 click_confirm_button(); - return true; + return resting_result.size(); } // 识别“注意力涣散”的干员 @@ -196,7 +199,7 @@ bool asst::InfrastDormTask::select_operators() if (listless_result.size() == 0 && work_mood_result.size() == 0) { // 如果没有注意力涣散的和心情低的,也直接关了 click_confirm_button(); - return true; + return 0; } click_clear_button(); @@ -230,7 +233,7 @@ bool asst::InfrastDormTask::select_operators() } sleep(2000); - return true; + return count; } std::vector InfrastDormTask::detect_mood_status_at_work(const cv::Mat& image, double process_threshold) const diff --git a/MeoAssistance/InfrastDormTask.h b/MeoAssistance/InfrastDormTask.h index 458c9dbe8d..f2cfa8bf75 100644 --- a/MeoAssistance/InfrastDormTask.h +++ b/MeoAssistance/InfrastDormTask.h @@ -10,6 +10,13 @@ namespace asst { virtual ~InfrastDormTask() = default; virtual bool run() override; + bool set_dorm_begin(int index) { + if (index <= 0 || index >= DormNum) { + return false; + } + m_dorm_begin = index; + return true; + } protected: struct MoodStatus { @@ -20,20 +27,20 @@ namespace asst { int time_left_hour = 0.0; // 剩余工作时间(小时数) }; constexpr static int MaxOperNumInDorm = 5; // 宿舍最大干员数 + constexpr static int DormNum = 4; // 宿舍数量 // 进入宿舍,index为从上到下的编号 bool enter_dorm(int index = 0); - // 进入下一个宿舍 bool enter_next_dorm(); - // 进入当前宿舍的干员选择界面 bool enter_operator_selection(); - - // 选择干员 - bool select_operators(); - + // 选择干员,返回本次选择了几个干员 + int select_operators(); // 检测正在工作中的干员心情状态 - std::vector detect_mood_status_at_work(const cv::Mat& image, double process_threshold = 1.0) const; + std::vector detect_mood_status_at_work( + const cv::Mat& image, double process_threshold = 1.0) const; + + int m_dorm_begin = 0; // 从第几个宿舍开始 }; }