From 448e2a0a644040baa5bb5de26aeee8a08fdf96e1 Mon Sep 17 00:00:00 2001 From: MistEO Date: Mon, 23 Jan 2023 23:56:39 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=B8=BA=E4=BF=A1=E7=94=A8=E5=95=86?= =?UTF-8?q?=E5=BA=97=E7=9A=84=E8=B4=AD=E7=89=A9=E6=B7=BB=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/3385 --- .../Task/Miscellaneous/CreditShoppingTask.cpp | 2 +- .../Miscellaneous/CreditShopImageAnalyzer.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/MaaCore/Task/Miscellaneous/CreditShoppingTask.cpp b/src/MaaCore/Task/Miscellaneous/CreditShoppingTask.cpp index 5ddd7a1d8e..3f99e1a911 100644 --- a/src/MaaCore/Task/Miscellaneous/CreditShoppingTask.cpp +++ b/src/MaaCore/Task/Miscellaneous/CreditShoppingTask.cpp @@ -80,7 +80,7 @@ bool asst::CreditShoppingTask::credit_shopping(bool white_list_enabled, bool cre ProcessTask(*this, { "CreditShop-BuyIt" }).run(); - if (ProcessTask(*this, { "CreditShop-NoMoney" }).set_retry_times(0).run()) { + if (ProcessTask(*this, { "CreditShop-NoMoney" }).set_task_delay(0).set_retry_times(0).run()) { break; } if (need_exit()) { diff --git a/src/MaaCore/Vision/Miscellaneous/CreditShopImageAnalyzer.cpp b/src/MaaCore/Vision/Miscellaneous/CreditShopImageAnalyzer.cpp index 6b465ff04b..68edebe045 100644 --- a/src/MaaCore/Vision/Miscellaneous/CreditShopImageAnalyzer.cpp +++ b/src/MaaCore/Vision/Miscellaneous/CreditShopImageAnalyzer.cpp @@ -8,15 +8,20 @@ #include "Vision/MatchImageAnalyzer.h" #include "Vision/MultiMatchImageAnalyzer.h" #include "Vision/OcrImageAnalyzer.h" +#include "Utils/Logger.hpp" void asst::CreditShopImageAnalyzer::set_black_list(std::vector black_list) { + Log.info(__FUNCTION__, black_list); + m_shopping_list = std::move(black_list); m_is_white_list = false; } void asst::CreditShopImageAnalyzer::set_white_list(std::vector black_list) { + Log.info(__FUNCTION__, black_list); + m_shopping_list = std::move(black_list); m_is_white_list = true; } @@ -61,6 +66,8 @@ bool asst::CreditShopImageAnalyzer::commodities_analyze() bool asst::CreditShopImageAnalyzer::whether_to_buy_analyze() { + Log.info(__FUNCTION__, m_shopping_list, "mode", m_is_white_list); + const auto product_name_task_ptr = Task.get("CreditShop-ProductName"); for (const Rect& commodity : m_commodities) { @@ -87,15 +94,16 @@ bool asst::CreditShopImageAnalyzer::whether_to_buy_analyze() #ifdef ASST_DEBUG cv::rectangle(m_image_draw, make_rect(commodity), cv::Scalar(0, 0, 255), 2); #endif - m_need_to_buy.emplace_back( - commodity, ocr_analyzer.get_result().empty() ? std::string() : ocr_analyzer.get_result().front().text); + const std::string& name = ocr_analyzer.get_result().front().text; + Log.info("need to buy", name); + m_need_to_buy.emplace_back(commodity, name); } if (m_is_white_list) { ranges::sort(m_need_to_buy, std::less {}, [&](const auto& pair) { return ranges::find(m_shopping_list, pair.second); }); } - + return !m_need_to_buy.empty(); }