diff --git a/resource/tasks/tasks.json b/resource/tasks/tasks.json index f982770af1..1313c4caa0 100644 --- a/resource/tasks/tasks.json +++ b/resource/tasks/tasks.json @@ -1368,7 +1368,7 @@ "specificRect": [1260, 100, 10, 10], "maxTimes": 10, "postDelay": 3000, - "next": ["EndOfAction", "(ClickCorner + WaitAfterPRTS + StartUpThemes)#next ^ #self", "#self"], + "next": ["EndOfActionAnnihilation", "EndOfAction", "(ClickCorner + WaitAfterPRTS + StartUpThemes)#next ^ #self", "#self"], "exceededNext": ["RestartGameAndContinue"] }, "EndOfAction": { @@ -4022,6 +4022,11 @@ "text": [], "roi": [52, 52, 18, 18] }, + "StageDrops-AnnihilationWeeklyLimit": { + "baseTask": "NumberOcrReplace", + "roi": [530, 472, 100, 20], + "useRaw": true + }, "act24side_melding_1": { "baseTask": "StageDrops-StageCF-ItemMatch", "template": "items/act24side_melding_1.png" diff --git a/src/MaaCore/Task/Fight/StageDropsTaskPlugin.cpp b/src/MaaCore/Task/Fight/StageDropsTaskPlugin.cpp index ea89560f2b..99c3e2a98b 100644 --- a/src/MaaCore/Task/Fight/StageDropsTaskPlugin.cpp +++ b/src/MaaCore/Task/Fight/StageDropsTaskPlugin.cpp @@ -16,6 +16,7 @@ #include "Utils/Logger.hpp" #include "Vision/Matcher.h" #include "Vision/Miscellaneous/StageDropsImageAnalyzer.h" +#include "Vision/RegionOCRer.h" bool asst::StageDropsTaskPlugin::verify(AsstMsg msg, const json::value& details) const { @@ -140,7 +141,8 @@ bool asst::StageDropsTaskPlugin::recognize_drops() return false; } - StageDropsImageAnalyzer analyzer(ctrler()->get_image()); + const auto& image = ctrler()->get_image(); + StageDropsImageAnalyzer analyzer(image); bool ret = false; auto append_image = [&]() { @@ -205,6 +207,33 @@ bool asst::StageDropsTaskPlugin::recognize_drops() } if (m_is_annihilation) { + RegionOCRer ocr(image); + ocr.set_task_info("StageDrops-AnnihilationWeeklyLimit"); + if (!ocr.analyze()) { + LogError << __FUNCTION__ << "Annihilation weekly limit OCR failed"; + } + else { + const auto& result = ocr.get_result().text; + if (auto idx = result.find("/"); idx == std::string::npos) { + LogError << __FUNCTION__ << "Annihilation weekly limit OCR result format error, result:" << result; + } + else { + const std::string cur = result.substr(0, idx); + const std::string total = result.substr(idx + 1); + int cur_num = 0, total_num = 0; + if (!utils::chars_to_number(cur, cur_num) || !utils::chars_to_number(total, total_num)) { + LogError << __FUNCTION__ + << "Annihilation weekly limit OCR result number format error, result:" << result; + } + else { + LogInfo << __FUNCTION__ << "Annihilation weekly limit:" << cur_num << "/" << total_num; + if (cur_num >= total_num) { + LogInfo << __FUNCTION__ << "Annihilation weekly limit reached, stop task"; + stop_task(); + } + } + } + } return true; }