diff --git a/MeoAssistance/AsstDef.h b/MeoAssistance/AsstDef.h index d13bd152eb..7c907abbb4 100644 --- a/MeoAssistance/AsstDef.h +++ b/MeoAssistance/AsstDef.h @@ -30,7 +30,7 @@ namespace asst { return os << _type_name.at(type); } - enum class ProcessTaskType { + enum class ProcessTaskAction { Invalid = 0, BasicClick = 0x100, ClickSelf = BasicClick | 1, // 点击模板自身位置 @@ -146,8 +146,8 @@ namespace asst { std::string name; // 任务名 AlgorithmType algorithm = // 图像算法类型 AlgorithmType::Invaild; - ProcessTaskType type = // 任务类型(要进行的操作) - ProcessTaskType::Invalid; + ProcessTaskAction action = // 要进行的操作 + ProcessTaskAction::Invalid; std::vector next; // 下一个可能的任务(列表) int exec_times = 0; // 任务已执行了多少次 int max_times = INT_MAX; // 任务最多执行多少次 diff --git a/MeoAssistance/Configer.cpp b/MeoAssistance/Configer.cpp index 70d739b006..108d4e5731 100644 --- a/MeoAssistance/Configer.cpp +++ b/MeoAssistance/Configer.cpp @@ -21,19 +21,19 @@ bool Configer::set_param(const std::string& type, const std::string& param, cons std::string type = value; std::transform(type.begin(), type.end(), type.begin(), std::tolower); if (type == "clickself") { - task_info_ptr->type = ProcessTaskType::ClickSelf; + task_info_ptr->action = ProcessTaskAction::ClickSelf; } else if (type == "clickrand") { - task_info_ptr->type = ProcessTaskType::ClickRand; + task_info_ptr->action = ProcessTaskAction::ClickRand; } else if (type == "donothing" || type.empty()) { - task_info_ptr->type = ProcessTaskType::DoNothing; + task_info_ptr->action = ProcessTaskAction::DoNothing; } else if (type == "stop") { - task_info_ptr->type = ProcessTaskType::Stop; + task_info_ptr->action = ProcessTaskAction::Stop; } else if (type == "clickrect") { - task_info_ptr->type = ProcessTaskType::ClickRect; + task_info_ptr->action = ProcessTaskAction::ClickRect; } else { DebugTraceError("Task", param, "'s type error:", type); @@ -124,22 +124,22 @@ bool asst::Configer::parse(json::value&& json) } task_info_ptr->algorithm = algorithm; task_info_ptr->name = name; - std::string type = task_json["type"].as_string(); - std::transform(type.begin(), type.end(), type.begin(), std::tolower); - if (type == "clickself") { - task_info_ptr->type = ProcessTaskType::ClickSelf; + std::string action = task_json["action"].as_string(); + std::transform(action.begin(), action.end(), action.begin(), std::tolower); + if (action == "clickself") { + task_info_ptr->action = ProcessTaskAction::ClickSelf; } - else if (type == "clickrand") { - task_info_ptr->type = ProcessTaskType::ClickRand; + else if (action == "clickrand") { + task_info_ptr->action = ProcessTaskAction::ClickRand; } - else if (type == "donothing" || type.empty()) { - task_info_ptr->type = ProcessTaskType::DoNothing; + else if (action == "donothing" || action.empty()) { + task_info_ptr->action = ProcessTaskAction::DoNothing; } - else if (type == "stop") { - task_info_ptr->type = ProcessTaskType::Stop; + else if (action == "stop") { + task_info_ptr->action = ProcessTaskAction::Stop; } - else if (type == "clickrect") { - task_info_ptr->type = ProcessTaskType::ClickRect; + else if (action == "clickrect") { + task_info_ptr->action = ProcessTaskAction::ClickRect; json::value& area_json = task_json["specificArea"]; task_info_ptr->specific_area = Rect( area_json[0].as_integer(), @@ -147,11 +147,11 @@ bool asst::Configer::parse(json::value&& json) area_json[2].as_integer(), area_json[3].as_integer()); } - else if (type == "printwindow") { - task_info_ptr->type = ProcessTaskType::PrintWindow; + else if (action == "printwindow") { + task_info_ptr->action = ProcessTaskAction::PrintWindow; } else { - DebugTraceError("Task:", name, "error:", type); + DebugTraceError("Task:", name, "error:", action); return false; } diff --git a/MeoAssistance/InfrastStationTask.cpp b/MeoAssistance/InfrastStationTask.cpp index 6dd04de77b..6fa5141105 100644 --- a/MeoAssistance/InfrastStationTask.cpp +++ b/MeoAssistance/InfrastStationTask.cpp @@ -50,12 +50,13 @@ bool asst::InfrastStationTask::run() break; } } - for (const Rect& rect : facility_number_rect) { - // 点到这个基建 - m_control_ptr->click(rect); - sleep(300); - - cv::Mat image = get_format_image(); + for (size_t i = 0; i != facility_number_rect.size(); ++i) { + if (i != 0) { + // 点到这个基建 + m_control_ptr->click(facility_number_rect[i]); + sleep(300); + image = get_format_image(); + } // 如果当前界面没有添加干员的按钮,那就不换班 Rect add_rect; auto&& [algorithm, value] = m_identify_ptr->find_image(image, "AddOperator", &add_rect); diff --git a/MeoAssistance/ProcessTask.cpp b/MeoAssistance/ProcessTask.cpp index e65ce51903..03f014a44e 100644 --- a/MeoAssistance/ProcessTask.cpp +++ b/MeoAssistance/ProcessTask.cpp @@ -46,7 +46,7 @@ bool ProcessTask::run() json::value callback_json = json::object{ { "name", task_info_ptr->name }, - { "type", static_cast(task_info_ptr->type) }, + { "type", static_cast(task_info_ptr->action) }, { "exec_times", task_info_ptr->exec_times }, { "max_times", task_info_ptr->max_times }, { "task_type", "ProcessTask"}, @@ -73,20 +73,20 @@ bool ProcessTask::run() } bool need_stop = false; - switch (task_info_ptr->type) { - case ProcessTaskType::ClickRect: + switch (task_info_ptr->action) { + case ProcessTaskAction::ClickRect: rect = task_info_ptr->specific_area; [[fallthrough]]; - case ProcessTaskType::ClickSelf: + case ProcessTaskAction::ClickSelf: exec_click_task(rect); break; - case ProcessTaskType::DoNothing: + case ProcessTaskAction::DoNothing: break; - case ProcessTaskType::Stop: + case ProcessTaskAction::Stop: m_callback(AsstMsg::TaskStop, json::object{ {"task_chain", m_task_chain} }, m_callback_arg); need_stop = true; break; - case ProcessTaskType::PrintWindow: + case ProcessTaskAction::PrintWindow: { if (!sleep(Configer::get_instance().m_options.print_window_delay)) { diff --git a/resource/config.json b/resource/config.json index 21f3d6628e..3f6bcd7a85 100644 --- a/resource/config.json +++ b/resource/config.json @@ -112,7 +112,7 @@ "tasks": { "SanityBegin": { "algorithm": "justreturn", - "type": "doNothing", + "action": "doNothing", "next": [ "UsePrts", "StartButton1", @@ -126,7 +126,7 @@ "UsePrts": { "template": "UsePrts.png", "templThreshold": 0.8, - "type": "clickSelf", + "action": "clickSelf", "next": [ "StartButton1" ] @@ -134,7 +134,7 @@ "StartButton1": { "template": "StartButton1.png", "templThreshold": 0.8, - "type": "clickSelf", + "action": "clickSelf", "next": [ "StartButton2", "UseMedicine", @@ -143,7 +143,7 @@ }, "StartButton2": { "template": "StartButton2.png", - "type": "clickSelf", + "action": "clickSelf", "rearDelay": 20000, "templThreshold": 0.95, "next": [ @@ -153,7 +153,7 @@ }, "PRTS": { "template": "PRTS.png", - "type": "doNothing", + "action": "doNothing", "rearDelay": 5000, "next": [ "PRTS", @@ -165,7 +165,7 @@ "WaitAfterPRTS": { "rearDelay": 3000, "algorithm": "justreturn", - "type": "doNothing", + "action": "doNothing", "next": [ "PRTS", "EndOfAction", @@ -175,7 +175,7 @@ "ClickCornerAfterPRTS": { "ClickCorner_Doc": "鐐瑰嚮鍙充笅瑙掞紝鏃笉浼氱偣鍒版帀钀界墿鍝侊紝鍙堣兘鐐瑰埌钃濊壊寮濮嬫寜閽紙涓轰簡瀹归敊锛夌殑涓鍧椾綅缃", "algorithm": "justreturn", - "type": "clickRect", + "action": "clickRect", "specificArea": [ 1100, 700, @@ -195,7 +195,7 @@ "EndOfAction": { "algorithm": "OcrDetect", "text": [ "琛屽姩缁撴潫" ], - "type": "printWindow", + "action": "printWindow", "next": [ "ClickCorner" ] @@ -203,7 +203,7 @@ "ClickCorner": { "ClickCorner_Doc": "鐐瑰嚮鍙充笅瑙掞紝鏃笉浼氱偣鍒版帀钀界墿鍝侊紝鍙堣兘鐐瑰埌钃濊壊寮濮嬫寜閽紙涓轰簡瀹归敊锛夌殑涓鍧椾綅缃", "algorithm": "justreturn", - "type": "clickRect", + "action": "clickRect", "specificArea": [ 1100, 700, @@ -222,21 +222,21 @@ "Loading": { "template": "Loading.png", "templThreshold": 0.8, - "type": "doNothing", + "action": "doNothing", "next": [ "StartButton1" ] }, "UseMedicine": { "template": "UseMedicine.png", - "type": "doNothing", + "action": "doNothing", "next": [ "MedicineConfirm" ] }, "MedicineConfirm": { "template": "MedicineConfirm.png", - "type": "clickSelf", + "action": "clickSelf", "reduceOtherTimes": [ "StartButton1" ], @@ -246,14 +246,14 @@ }, "UseStone": { "template": "UseStone.png", - "type": "doNothing", + "action": "doNothing", "next": [ "StoneConfirm" ] }, "StoneConfirm": { "template": "MedicineConfirm.png", - "type": "clickSelf", + "action": "clickSelf", "maxTimes": 0, "reduceOtherTimes": [ "StartButton1" @@ -264,14 +264,14 @@ }, "PrtsErrorConfirm": { "template": "PrtsErrorConfirm.png", - "type": "doNothing", + "action": "doNothing", "next": [ "AbandonAction" ] }, "AbandonAction": { "template": "AbandonAction.png", - "type": "clickSelf", + "action": "clickSelf", "reduceOtherTimes": [ "StartButton1", "StartButton2", @@ -283,7 +283,7 @@ }, "VisitBegin": { "algorithm": "justreturn", - "type": "doNothing", + "action": "doNothing", "next": [ "Friends", "FriendsList", @@ -298,7 +298,7 @@ "templThreshold": 0.85, "histThreshold": 0.85, "rearDelay": 1000, - "type": "clickSelf", + "action": "clickSelf", "next": [ "Friends", "ReturnToFriends" @@ -308,14 +308,14 @@ "template": "Friends.png", "templThreshold": 0.85, "preDelay": 1000, - "type": "clickSelf", + "action": "clickSelf", "next": [ "FriendsList" ] }, "FriendsList": { "template": "FriendsList.png", - "type": "clickSelf", + "action": "clickSelf", "next": [ "StartToVisit" ] @@ -323,7 +323,7 @@ "StartToVisit": { "template": "StartToVisit.png", "templThreshold": 0.8, - "type": "clickSelf", + "action": "clickSelf", "rearDelay": 5000, "next": [ "VisitNext" @@ -331,7 +331,7 @@ }, "VisitNext": { "template": "VisitNext.png", - "type": "clickSelf", + "action": "clickSelf", "cache": false, "rearDelay": 3000, "exceededNext": [ @@ -347,7 +347,7 @@ "VisitNextOcr": { "algorithm": "OcrDetect", "text": [ "璁块棶涓嬩綅" ], - "type": "clickSelf", + "action": "clickSelf", "rearDelay": 3000, "exceededNext": [ "ReturnToMall" @@ -362,7 +362,7 @@ "ReturnToMall": { "rearDelay": 1000, "template": "Return.png", - "type": "clickSelf", + "action": "clickSelf", "next": [ "Mall", "ReturnToMall", @@ -371,7 +371,7 @@ }, "ReturnToMallConfirm": { "template": "PopupConfirm.png", - "type": "clickSelf", + "action": "clickSelf", "rearDelay": 5000, "next": [ "ReturnToMall" @@ -379,7 +379,7 @@ }, "Mall": { "template": "Mall.png", - "type": "clickSelf", + "action": "clickSelf", "next": [ "CreditStore", "CreditStoreOcr" @@ -389,7 +389,7 @@ "template": "CreditStore.png", "templThreshold": 0.85, "rearDelay": 1000, - "type": "clickSelf", + "action": "clickSelf", "next": [ "CollectCredit", "Stop" @@ -399,7 +399,7 @@ "algorithm": "OcrDetect", "text": [ "淇$敤浜ゆ槗鎵" ], "rearDelay": 1000, - "type": "clickSelf", + "action": "clickSelf", "next": [ "CollectCredit", "Stop" @@ -407,7 +407,7 @@ }, "CollectCredit": { "template": "CollectCredit.png", - "type": "clickSelf", + "action": "clickSelf", "next": [ "Stop" ] @@ -415,27 +415,27 @@ "VisitLimited": { "algorithm": "OcrDetect", "text": [ "浠婃棩鍙備笌", "宸茶揪涓婇檺" ], - "type": "doNothing", + "action": "doNothing", "next": [ "ReturnToMall" ] }, "VisitNextBlack": { "template": "VisitNextBlack.png", - "type": "doNothing", + "action": "doNothing", "next": [ "ReturnToMall" ] }, "Stop": { "algorithm": "justreturn", - "type": "stop", + "action": "stop", "next": [] }, "RecruitTime": { "template": "RecruitTimeReduce.png", "templThreshold": 0.89, - "type": "clickRect", + "action": "clickRect", "specificArea": [ 391, 279, 129, 44 ], "next": [ "Stop" @@ -443,14 +443,14 @@ }, "Listless": { "template": "Listless.png", - "type": "clickSelf", + "action": "clickSelf", "next": [ "Stop" ] }, "InfrastBegin": { "algorithm": "justreturn", - "type": "doNothing", + "action": "doNothing", "next": [ "EnterInfrast", "InfrastNotification", @@ -462,7 +462,7 @@ "templThreshold": 0.85, "histThreshold": 0.85, "rearDelay": 1000, - "type": "clickSelf", + "action": "clickSelf", "next": [ "EnterInfrast", "InfrastNotification", @@ -474,7 +474,7 @@ "templThreshold": 0.85, "histThreshold": 0.85, "rareDelay": 3000, - "type": "clickSelf", + "action": "clickSelf", "next": [ "InfrastEnteredFlag" ] @@ -482,7 +482,7 @@ "InfrastEnteredFlag": { "template": "InfrastEnteredFlag.png", "templThreshold": 0.8, - "type": "doNothing", + "action": "doNothing", "next": [ "InfrastNotification", "Stop" @@ -492,7 +492,7 @@ "template": "Manufacturing.png", "templThreshold": 0.8, "cache": false, - "type": "clickSelf", + "action": "clickSelf", "rearDelay": 1000, "next": [ "ManufacturingLeftBottom" @@ -502,7 +502,7 @@ "template": "ManufacturingMini.png", "templThreshold": 0.8, "cache": false, - "type": "clickSelf", + "action": "clickSelf", "rearDelay": 1000, "next": [ "ManufacturingLeftBottom" @@ -511,7 +511,7 @@ "ManufacturingLeftBottom": { "Doc": "鍒堕犵珯鐐硅繘鍘讳箣鍚庯紝宸︿笅瑙掗偅涓滀腑绾т綔鎴樿褰 鍒堕犱腑鈥", "algorithm": "justreturn", - "type": "clickRect", + "action": "clickRect", "specificArea": [ 1, 535, @@ -525,7 +525,7 @@ "Manufacturing1st": { "Doc": "璁炬柦鍒楄〃閲岀涓涓紙绗竴涓埗閫犵珯鎴栬呰锤鏄撶珯锛", "algorithm": "justreturn", - "type": "clickRect", + "action": "clickRect", "specificArea": [ 1, 183, @@ -539,7 +539,7 @@ "InfrastNotification": { "template": "InfrastNotification.png", "templThreshold": 0.8, - "type": "clickSelf", + "action": "clickSelf", "next": [ "InfrastReward", "InfrastExitReward" @@ -547,9 +547,9 @@ }, "InfrastReward": { "algorithm": "OcrDetect", - "text": [ "鍙敹鑾", "璁㈠崟浜や粯" ], + "text": [ "鍙敹鑾", "璁㈠崟浜や粯", "骞插憳淇¤禆" ], "rearDelay": 1000, - "type": "clickSelf", + "action": "clickSelf", "next": [ "InfrastReward", "InfrastExitReward" @@ -558,7 +558,7 @@ "InfrastExitReward": { "Doc": "骞插憳鐤插姵銆佺嚎绱㈡敹闆 鏄笉鑳戒竴閿敹鑾风殑锛屾墍浠ヨ鍏堥鍑轰竴閿敹鑾风殑鐣岄潰锛岃繖閲岀偣鍑荤殑鏄帶鍒朵腑鏋㈠乏渚ч偅涓鐗囩┖鐧界殑鍖哄煙", "algorithm": "justreturn", - "type": "clickRect", + "action": "clickRect", "specificArea": [ 250, 100,