From bbb2eda626eae2400da9f2a32f712f6698fb74ab Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Tue, 4 Oct 2022 02:07:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20tasks.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. StartUp 任务在 EndOfAction 界面不再直接停止,而是一直点击返回直到主界面 2. 把 StartUp 相关的 task 放到一起 3. `set_times_limit("A")` 对 `B@A`、`B@...@A` 任务也生效 --- resource/tasks.json | 561 +++++++++++----------- src/MeoAssistant/Task/StartUpTask.cpp | 3 - src/MeoAssistant/Task/Sub/ProcessTask.cpp | 18 +- 3 files changed, 305 insertions(+), 277 deletions(-) diff --git a/resource/tasks.json b/resource/tasks.json index 8374a62bbd..011a6bc9fb 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -1934,18 +1934,18 @@ "algorithm": "JustReturn", "action": "DoNothing", "next": [ - "GameStart", - "StartToWakeUp", - "StartUpConnectingFlag", - "StartLoginBServer", - "BServerPrivacyPolicy", - "Terminal@Main", - "Terminal@CloseAnno", - "Terminal@TodaysSupplies", - "Terminal@ReturnTo", - "OfflineConfirm", - "EndOfAction", - "StageSNFlag" + "StartUp@GameStart", + "StartUp@StartToWakeUp", + "StartUp@StartUpConnectingFlag", + "StartUp@StartLoginBServer", + "StartUp@BServerPrivacyPolicy", + "StartUp@Main", + "StartUp@CloseAnno", + "StartUp@TodaysSupplies", + "StartUp@ReturnTo", + "StartUp@OfflineConfirm", + "StartUp@EndOfAction", + "StartUp@FromStageSN" ] }, "BServerPrivacyPolicy": { @@ -1963,52 +1963,11 @@ "StartUpConnectingFlag", "StartLoginBServer", "BServerPrivacyPolicy", - "Terminal@Main", - "Terminal@CloseAnno", - "OfflineConfirm", - "Terminal@TodaysSupplies" - ] - }, - "Annihilation": { - "doc": "剿灭作战,一般本周的满了也不会有人再刷的,所以只识别右上角ToDoList里的剿灭就可以了", - "template": "StageAnnihilation.png", - "templThreshold": 0.6, - "cache": false, - "action": "ClickSelf", - "roi": [ - 900, - 70, - 380, - 400 - ], - "maskRange": [ - 1, - 255 - ] - }, - "StageBegin": { - "algorithm": "JustReturn", - "action": "DoNothing", - "next": [ - "Terminal@ReturnTo", - "Terminal@Main", - "Terminal@CloseAnno", - "Terminal@FromStageSN", - "Terminal@TodaysSupplies" - ] - }, - "FightBegin": { - "algorithm": "JustReturn", - "action": "DoNothing", - "next": [ - "UsePrts-Annihilation", - "UsePrts", - "UsePrts-StageSN", - "StartButton1", - "PRTS3", - "PRTS", - "PRTS2", - "EndOfAction" + "Main", + "CloseAnno", + "TodaysSupplies", + "ReturnTo", + "OfflineConfirm" ] }, "GameStart": { @@ -2036,10 +1995,47 @@ "StartUpConnectingFlag", "StartLoginBServer", "BServerPrivacyPolicy", - "Terminal@Main", - "Terminal@CloseAnno", + "Main", + "CloseAnno", "OfflineConfirm", - "Terminal@TodaysSupplies" + "TodaysSupplies" + ] + }, + "StartToWakeUp": { + "action": "ClickSelf", + "roi": [ + 520, + 460, + 240, + 100 + ], + "next": [ + "StartToWakeUp", + "StartUpConnectingFlag", + "StartLoginBServer", + "BServerPrivacyPolicy", + "Main", + "CloseAnno", + "OfflineConfirm", + "TodaysSupplies" + ] + }, + "StartLoginBServer": { + "action": "ClickSelf", + "roi": [ + 400, + 350, + 500, + 150 + ], + "next": [ + "StartUpConnectingFlag", + "StartLoginBServer", + "BServerPrivacyPolicy", + "Main", + "CloseAnno", + "OfflineConfirm", + "TodaysSupplies" ] }, "StartUpConnectingFlag": { @@ -2055,28 +2051,61 @@ "StartLoginBServer", "BServerPrivacyPolicy", "StartUpConnectingFlag", - "Terminal@Main", - "Terminal@CloseAnno", + "Main", + "CloseAnno", "OfflineConfirm", - "Terminal@TodaysSupplies" + "TodaysSupplies" ] }, - "StartLoginBServer": { - "action": "ClickSelf", + "StartUp@Main": { + "template": "Terminal.png", + "action": "Stop", + "roi": [ + 880, + 100, + 180, + 120 + ] + }, + "CloseAnno": { + "Doc": "base_task", + "action": "ClickSelf", + "cache": false, + "roi": [ + 1100, + 0, + 180, + 200 + ], + "next": [ + "Main", + "CloseAnno", + "ReturnTo", + "FromStageSN", + "TodaysSupplies" + ] + }, + "TodaysSupplies": { + "algorithm": "OcrDetect", + "text": [ + "今日配给" + ], + "action": "ClickRect", + "specificRect": [ + 1000, + 1, + 270, + 340 + ], "roi": [ - 400, - 350, 500, + 50, + 300, 150 ], "next": [ - "StartUpConnectingFlag", - "StartLoginBServer", - "BServerPrivacyPolicy", - "Terminal@Main", - "Terminal@CloseAnno", - "OfflineConfirm", - "Terminal@TodaysSupplies" + "CloseAnno", + "Main" ] }, "ReturnTo": { @@ -2116,6 +2145,150 @@ "ReturnToConfirm" ] }, + "OfflineConfirm": { + "action": "DoNothing", + "roi": [ + 310, + 409, + 648, + 165 + ], + "reduceOtherTimes": [ + "StartButton1", + "StartButton2" + ], + "next": [ + "OfflineConfirmImpl" + ] + }, + "OfflineConfirmImpl": { + "Doc": "防止 reduceOtherTimes 两次", + "template": "OfflineConfirm.png", + "action": "ClickSelf", + "roi": [ + 310, + 409, + 648, + 165 + ], + "maskRange": [ + 100, + 255 + ], + "next": [ + "CloseAnno", + "StartToWakeUp", + "StartUpConnectingFlag", + "StartLoginBServer", + "BServerPrivacyPolicy", + "OfflineConfirmImpl", + "TodaysSupplies" + ] + }, + "StartUp@AfterEndOfAction": { + "ClickCorner_Doc": "点击屏幕右边,不会点到掉落物品,且不会关掉关卡选择的一块区域", + "algorithm": "JustReturn", + "action": "ClickRect", + "specificRect": [ + 1000, + 120, + 270, + 10 + ], + "next": [ + "StartUp@ReturnTo", + "StartUp@Main", + "StartUp@CloseAnno", + "StartUp@FromStageSN", + "StartUp@TodaysSupplies", + "StartUp@OfflineConfirm" + ], + "onErrorNext": [ + "StartUp@RestartGameAndContinue" + ] + }, + "FromStageSN": { + "template": "StageSNReturnFlag.png", + "action": "ClickRect", + "cache": false, + "roi": [ + 284, + 509, + 242, + 141 + ], + "specificRect": [ + 20, + 20, + 135, + 35 + ], + "next": [ + "ReturnTo" + ] + }, + "Annihilation": { + "doc": "剿灭作战,一般本周的满了也不会有人再刷的,所以只识别右上角ToDoList里的剿灭就可以了", + "template": "StageAnnihilation.png", + "templThreshold": 0.6, + "cache": false, + "action": "ClickSelf", + "roi": [ + 900, + 70, + 380, + 400 + ], + "maskRange": [ + 1, + 255 + ] + }, + "StageBegin": { + "algorithm": "JustReturn", + "action": "DoNothing", + "next": [ + "Fight@ReturnTo", + "Fight@Main", + "Fight@CloseAnno", + "Fight@FromStageSN", + "Fight@TodaysSupplies" + ] + }, + "FightBegin": { + "Docs": "Fight@前缀保证各种任务的Main可以自动寻到Fight@Main", + "algorithm": "JustReturn", + "action": "DoNothing", + "next": [ + "Fight@UsePrts-Annihilation", + "Fight@UsePrts", + "Fight@UsePrts-StageSN", + "Fight@StartButton1", + "Fight@PRTS3", + "Fight@PRTS", + "Fight@PRTS2", + "Fight@EndOfAction" + ] + }, + "LastOrCurBattleBegin": { + "algorithm": "JustReturn", + "action": "DoNothing", + "next": [ + "Fight@GoLastBattle", + "Fight@StartButton1", + "Fight@UsePrts", + "Fight@UsePrts-StageSN", + "Fight@ReturnTo", + "Fight@Main", + "Fight@CloseAnno", + "Fight@FromStageSN", + "Fight@TodaysSupplies", + "Fight@PRTS3", + "Fight@PRTS", + "Fight@PRTS2", + "Fight@EndOfAction" + ] + }, "UsePrts": { "action": "ClickSelf", "roi": [ @@ -2227,46 +2400,6 @@ "Stop" ] }, - "Visit@FromStageSN": { - "template": "StageSNReturnFlag.png", - "action": "ClickRect", - "cache": false, - "roi": [ - 284, - 509, - 242, - 141 - ], - "specificRect": [ - 20, - 20, - 135, - 35 - ], - "next": [ - "Visit@ReturnTo" - ] - }, - "FromStageSN": { - "template": "StageSNReturnFlag.png", - "action": "ClickRect", - "cache": false, - "roi": [ - 284, - 509, - 242, - 141 - ], - "specificRect": [ - 20, - 20, - 135, - 35 - ], - "next": [ - "ReturnTo" - ] - }, "StartButton2": { "action": "ClickSelf", "rearDelay": 40000, @@ -2420,7 +2553,7 @@ "OfflineConfirm" ], "onErrorNext": [ - "RestartGameAndContinueFighting" + "RestartGameAndContinue" ] }, "EndOfAction": { @@ -2436,7 +2569,7 @@ "FightMissionFailed" ], "next": [ - "ClickCorner" + "AfterEndOfAction" ] }, "EndOfActionAnnihilation": { @@ -2453,14 +2586,14 @@ ], "action": "DoNothing", "next": [ - "ClickCorner" + "AfterEndOfAction" ] }, "StageDrops": { "algorithm": "JustReturn", "preDelay": 5000 }, - "ClickCorner": { + "AfterEndOfAction": { "ClickCorner_Doc": "点击屏幕右边,不会点到掉落物品,且不会关掉关卡选择的一块区域", "algorithm": "JustReturn", "action": "ClickRect", @@ -2479,23 +2612,7 @@ "EndOfAction" ], "onErrorNext": [ - "RestartGameAndContinueFighting" - ] - }, - "RestartGameAndContinueFighting": { - "algorithm": "JustReturn", - "action": "DoNothing", - "rearDelay": 5000, - "next": [ - "GameStart", - "StartToWakeUp", - "StartUpConnectingFlag", - "StartLoginBServer", - "BServerPrivacyPolicy", - "Terminal@Main", - "Terminal@CloseAnno", - "Terminal@TodaysSupplies", - "OfflineConfirm" + "RestartGameAndContinue" ] }, "UseMedicine": { @@ -2617,6 +2734,28 @@ "OfflineConfirmAfterBattle" ] }, + "OfflineConfirmAfterBattle": { + "template": "PopupConfirm.png", + "action": "ClickSelf", + "roi": [ + 630, + 400, + 650, + 160 + ], + "next": [ + "PRTS3", + "PRTS", + "PRTS2", + "PrtsErrorConfirm", + "OfflineConfirm", + "StartToWakeUp", + "StartUpConnectingFlag", + "StartLoginBServer", + "BServerPrivacyPolicy", + "OfflineConfirmAfterBattle" + ] + }, "AbandonAction": { "action": "ClickSelf", "reduceOtherTimes": [ @@ -2683,101 +2822,23 @@ 269 ] }, - "OfflineConfirmAfterBattle": { - "template": "PopupConfirm.png", - "action": "ClickSelf", - "roi": [ - 630, - 400, - 650, - 160 - ], - "next": [ - "PRTS3", - "PRTS", - "PRTS2", - "PrtsErrorConfirm", - "OfflineConfirm", - "StartToWakeUp", - "StartUpConnectingFlag", - "StartLoginBServer", - "BServerPrivacyPolicy", - "OfflineConfirmAfterBattle" - ] - }, - "OfflineConfirm": { + "RestartGameAndContinue": { + "Doc": "base_task", + "algorithm": "JustReturn", "action": "DoNothing", - "roi": [ - 310, - 409, - 648, - 165 - ], - "reduceOtherTimes": [ - "StartButton1", - "StartButton2" - ], + "rearDelay": 5000, "next": [ - "OfflineConfirmImpl" - ] - }, - "OfflineConfirmImpl": { - "template": "OfflineConfirm.png", - "action": "ClickSelf", - "roi": [ - 310, - 409, - 648, - 165 - ], - "maskRange": [ - 100, - 255 - ], - "next": [ - "Terminal@CloseAnno", + "GameStart", "StartToWakeUp", "StartUpConnectingFlag", "StartLoginBServer", "BServerPrivacyPolicy", - "OfflineConfirmImpl", - "Terminal@TodaysSupplies" - ] - }, - "StartToWakeUp": { - "action": "ClickSelf", - "roi": [ - 520, - 460, - 240, - 100 - ], - "next": [ - "StartToWakeUp", - "StartUpConnectingFlag", - "StartLoginBServer", - "BServerPrivacyPolicy", - "Terminal@Main", - "Terminal@CloseAnno", - "OfflineConfirm", - "Terminal@TodaysSupplies" - ] - }, - "CloseAnno": { - "action": "ClickSelf", - "cache": false, - "roi": [ - 1100, - 0, - 180, - 200 - ], - "next": [ + "ReturnTo", "Main", "CloseAnno", - "ReturnTo", "FromStageSN", - "TodaysSupplies" + "TodaysSupplies", + "OfflineConfirm" ] }, "Main": { @@ -2785,7 +2846,7 @@ "algorithm": "JustReturn", "action": "DoNothing" }, - "Terminal@Main": { + "Fight@Main": { "template": "Terminal.png", "action": "ClickSelf", "roi": [ @@ -2795,61 +2856,19 @@ 120 ], "exceededNext": [ - "Terminal@TodaysSupplies", - "Terminal@CloseAnno", + "Fight@TodaysSupplies", + "Fight@CloseAnno", "Stop" ], "next": [ - "GoLastBattle", - "Terminal@Main", - "Terminal@CloseAnno", - "Terminal@TodaysSupplies", + "Fight@GoLastBattle", + "Fight@Main", + "Fight@CloseAnno", + "Fight@TodaysSupplies", "Stop" ], "rearDelay": 3000 }, - "TodaysSupplies": { - "algorithm": "OcrDetect", - "text": [ - "今日配给" - ], - "action": "ClickRect", - "specificRect": [ - 1000, - 1, - 270, - 340 - ], - "roi": [ - 500, - 50, - 300, - 150 - ], - "next": [ - "CloseAnno", - "Main" - ] - }, - "LastOrCurBattleBegin": { - "algorithm": "JustReturn", - "action": "DoNothing", - "next": [ - "GoLastBattle", - "StartButton1", - "UsePrts", - "UsePrts-StageSN", - "Terminal@ReturnTo", - "Terminal@Main", - "Terminal@CloseAnno", - "Terminal@FromStageSN", - "Terminal@TodaysSupplies", - "PRTS3", - "PRTS", - "PRTS2", - "EndOfAction" - ] - }, "GoLastBattle": { "algorithm": "OcrDetect", "text": [ diff --git a/src/MeoAssistant/Task/StartUpTask.cpp b/src/MeoAssistant/Task/StartUpTask.cpp index 7ebc31b543..77bac122fc 100644 --- a/src/MeoAssistant/Task/StartUpTask.cpp +++ b/src/MeoAssistant/Task/StartUpTask.cpp @@ -10,9 +10,6 @@ asst::StartUpTask::StartUpTask(AsstCallback callback, void* callback_arg) m_start_up_task_ptr(std::make_shared(m_callback, m_callback_arg, TaskType)) { m_start_up_task_ptr->set_tasks({ "StartUp" }) - .set_times_limit("Terminal@ReturnTo", 0) - .set_times_limit("Terminal@Main", 0) - .set_times_limit("EndOfAction", 0) .set_task_delay(1000) .set_retry_times(30); m_subtasks.emplace_back(m_start_game_task_ptr); diff --git a/src/MeoAssistant/Task/Sub/ProcessTask.cpp b/src/MeoAssistant/Task/Sub/ProcessTask.cpp index a05a78cf4c..608443e144 100644 --- a/src/MeoAssistant/Task/Sub/ProcessTask.cpp +++ b/src/MeoAssistant/Task/Sub/ProcessTask.cpp @@ -137,9 +137,21 @@ bool ProcessTask::_run() int max_times = m_cur_task_ptr->max_times; TimesLimitType limit_type = TimesLimitType::Pre; - if (auto iter = m_times_limit.find(cur_name); iter != m_times_limit.cend()) { - max_times = iter->second.times; - limit_type = iter->second.type; + { + std::string_view cur_base_name = cur_name; + while (true) { + if (auto iter = m_times_limit.find(cur_base_name.data()); iter != m_times_limit.cend()) { + max_times = iter->second.times; + limit_type = iter->second.type; + break; + } + if (size_t at_pos = cur_base_name.find('@'); at_pos == std::string::npos) { + break; + } + else { + cur_base_name = cur_base_name.substr(at_pos + 1); + } + } } if (limit_type == TimesLimitType::Pre && exec_times >= max_times) {