diff --git a/.gitignore b/.gitignore index 637e844201..8a54dca5e2 100644 --- a/.gitignore +++ b/.gitignore @@ -425,3 +425,5 @@ FodyWeavers.xsd # JetBrains Rider .idea/ *.sln.iml + +screen.png diff --git a/MeoAssistance/Assistance.cpp b/MeoAssistance/Assistance.cpp index 2d118b8e5c..66415819b5 100644 --- a/MeoAssistance/Assistance.cpp +++ b/MeoAssistance/Assistance.cpp @@ -290,8 +290,13 @@ bool asst::Assistance::start_infrast() */ constexpr static const char* InfrastTaskCahin = "Infrast"; + // 1. 从任意界面进入基建,使用ProcessTask + // 2. 一键收获贸易站、制造站、干员信赖,使用ProcessTask + append_match_task(InfrastTaskCahin, { "InfrastBegin" }); + + // TODO,这里需要根据用户设置,是先制造站还是先贸易站,或者是别的设施 // 从进入制造站,到进入干员选择界面清空选择 - append_match_task(InfrastTaskCahin, { "Manufacturing" }); + append_match_task(InfrastTaskCahin, { "Manufacturing", "ManufacturingMini" }); // 识别并选择最优解干员组合 auto task_ptr = std::make_shared(task_callback, (void*)this); diff --git a/MeoAssistance/Identify.cpp b/MeoAssistance/Identify.cpp index 278ab56052..8766242a9e 100644 --- a/MeoAssistance/Identify.cpp +++ b/MeoAssistance/Identify.cpp @@ -86,7 +86,7 @@ std::pair, cv::Mat> asst::Identify::surf_detect(const constexpr int min_hessian = 400; // SURF特征点检测 - static cv::Ptr detector = SIFT::create(min_hessian); + static cv::Ptr detector = SURF::create(min_hessian); std::vector keypoints; cv::Mat mat_vector; // 找到特征点并计算特征描述子(向量) diff --git a/MeoAssistance/InfrastStationTask.cpp b/MeoAssistance/InfrastStationTask.cpp index 36295d6b65..7918d28906 100644 --- a/MeoAssistance/InfrastStationTask.cpp +++ b/MeoAssistance/InfrastStationTask.cpp @@ -34,7 +34,7 @@ bool asst::InfrastStationTask::run() } auto&& [width, height] = m_view_ptr->getAdbDisplaySize(); m_swipe_begin = Rect(width * 0.9, height * 0.5, 0, 0); - m_swipe_end = Rect(width * 0.4, height * 0.5, 0, 0); + m_swipe_end = Rect(width * 0.5, height * 0.5, 0, 0); auto detect_ret = swipe_and_detect(); if (!detect_ret) { diff --git a/MeoAssistance/ProcessTask.cpp b/MeoAssistance/ProcessTask.cpp index dd97205d4f..66cf1f241c 100644 --- a/MeoAssistance/ProcessTask.cpp +++ b/MeoAssistance/ProcessTask.cpp @@ -140,7 +140,7 @@ std::shared_ptr ProcessTask::match_image(Rect* matched_rect) // 逐个匹配当前可能的任务 for (const std::string& task_name : m_cur_tasks_name) { std::shared_ptr task_info_ptr = Configer::get_instance().m_all_tasks_info[task_name]; - if (task_info_ptr == nullptr) { + if (task_info_ptr == nullptr) { // 说明配置文件里没这个任务 m_callback(AsstMsg::PtrIsNull, json::value(), m_callback_arg); continue; } diff --git a/MeoAssistance/WinMacro.cpp b/MeoAssistance/WinMacro.cpp index 7d4196f38d..7975fcd28a 100644 --- a/MeoAssistance/WinMacro.cpp +++ b/MeoAssistance/WinMacro.cpp @@ -16,6 +16,8 @@ using namespace asst; +bool WinMacro::m_is_adb_connect = false; + WinMacro::WinMacro(const EmulatorInfo& info, HandleType type) : m_emulator_info(info), m_handle_type(type), @@ -99,14 +101,17 @@ bool WinMacro::findHandle() adb_dir = adb_dir.substr(0, pos); adb_dir = '"' + StringReplaceAll(m_emulator_info.adb.path, "[EmulatorPath]", adb_dir) + '"'; - if (m_handle_type == HandleType::Control) - { + if (!m_is_adb_connect) { std::string connect_cmd = StringReplaceAll(m_emulator_info.adb.connect, "[Adb]", adb_dir); if (!callCmd(connect_cmd)) { DebugTraceError("Connect Adb Error", connect_cmd); return false; } + m_is_adb_connect = true; + } + if (m_handle_type == HandleType::Control) + { m_click_cmd = StringReplaceAll(m_emulator_info.adb.click, "[Adb]", adb_dir); m_swipe_cmd = StringReplaceAll(m_emulator_info.adb.swipe, "[Adb]", adb_dir); } diff --git a/MeoAssistance/WinMacro.h b/MeoAssistance/WinMacro.h index 2462ab683e..9de6e9f233 100644 --- a/MeoAssistance/WinMacro.h +++ b/MeoAssistance/WinMacro.h @@ -46,6 +46,7 @@ namespace asst { const HandleType m_handle_type; HWND m_handle = NULL; bool m_is_adb = false; + static bool m_is_adb_connect; std::string m_click_cmd; // adb点击命令,不是adb的句柄用不到这个 std::string m_swipe_cmd; // adb滑动命令,不是adb的句柄用不到这个 std::string m_screencap_cmd; // adb截图命令,不是adb的句柄用不到这个 diff --git a/resource/config.json b/resource/config.json index e943ec7b0f..b5abb8acb2 100644 --- a/resource/config.json +++ b/resource/config.json @@ -297,6 +297,7 @@ "template": "Return.png", "templThreshold": 0.85, "histThreshold": 0.85, + "rearDelay": 1000, "type": "clickSelf", "next": [ "Friends", @@ -359,6 +360,7 @@ ] }, "ReturnToMall": { + "rearDelay": 1000, "template": "Return.png", "type": "clickSelf", "next": [ @@ -446,8 +448,57 @@ "Stop" ] }, + "InfrastBegin": { + "algorithm": "justreturn", + "type": "doNothing", + "next": [ + "EnterInfrast", + "InfrastNotification", + "ReturnToInfrast" + ] + }, + "ReturnToInfrast": { + "template": "Return.png", + "templThreshold": 0.85, + "histThreshold": 0.85, + "rearDelay": 1000, + "type": "clickSelf", + "next": [ + "EnterInfrast", + "ReturnToInfrast" + ] + }, + "EnterInfrast": { + "template": "EnterInfrast.png", + "templThreshold": 0.85, + "histThreshold": 0.85, + "rareDelay": 3000, + "type": "clickSelf", + "next": [ + "InfrastEnteredFlag" + ] + }, + "InfrastEnteredFlag": { + "template": "InfrastEnteredFlag.png", + "type": "doNothing", + "next": [ + "InfrastNotification", + "Stop" + ] + }, "Manufacturing": { "template": "Manufacturing.png", + "templThreshold": 0.8, + "cache": false, + "type": "clickSelf", + "rearDelay": 1000, + "next": [ + "ManufacturingLeftBottom" + ] + }, + "ManufacturingMini": { + "template": "ManufacturingMini.png", + "templThreshold": 0.8, "cache": false, "type": "clickSelf", "rearDelay": 1000, @@ -483,6 +534,38 @@ "next": [ "Stop" ] + }, + "InfrastNotification": { + "template": "InfrastNotification.png", + "type": "clickSelf", + "next": [ + "InfrastReward", + "InfrastExitReward" + ] + }, + "InfrastReward": { + "algorithm": "OcrDetect", + "text": [ "鍙敹鑾", "璁㈠崟浜や粯" ], + "rearDelay": 1000, + "type": "clickSelf", + "next": [ + "InfrastReward", + "InfrastExitReward" + ] + }, + "InfrastExitReward": { + "Doc": "骞插憳鐤插姵銆佺嚎绱㈡敹闆 鏄笉鑳戒竴閿敹鑾风殑锛屾墍浠ヨ鍏堥鍑轰竴閿敹鑾风殑鐣岄潰锛岃繖閲岀偣鍑荤殑鏄帶鍒朵腑鏋㈠乏渚ч偅涓鐗囩┖鐧界殑鍖哄煙", + "algorithm": "justreturn", + "type": "clickRect", + "specificArea": [ + 250, + 100, + 380, + 140 + ], + "next": [ + "Stop" + ] } } } diff --git a/resource/operators/screen.png b/resource/operators/screen.png deleted file mode 100644 index 974d1dd1d6..0000000000 Binary files a/resource/operators/screen.png and /dev/null differ diff --git a/resource/template/EnterInfrast.png b/resource/template/EnterInfrast.png new file mode 100644 index 0000000000..2a3c03aa7a Binary files /dev/null and b/resource/template/EnterInfrast.png differ diff --git a/resource/template/InfrastEnteredFlag.png b/resource/template/InfrastEnteredFlag.png new file mode 100644 index 0000000000..692f4901e9 Binary files /dev/null and b/resource/template/InfrastEnteredFlag.png differ diff --git a/resource/template/InfrastNotification.png b/resource/template/InfrastNotification.png new file mode 100644 index 0000000000..9e6ad429f3 Binary files /dev/null and b/resource/template/InfrastNotification.png differ diff --git a/resource/template/ManufacturingMini.png b/resource/template/ManufacturingMini.png new file mode 100644 index 0000000000..0e062736b9 Binary files /dev/null and b/resource/template/ManufacturingMini.png differ diff --git a/resource/operators/screen.bat b/screen.bat similarity index 100% rename from resource/operators/screen.bat rename to screen.bat