From a97c77cd5c8af5b82e6dbedee30964a781f403f3 Mon Sep 17 00:00:00 2001 From: MistEO Date: Sun, 31 Jul 2022 20:16:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AE=80=E5=8D=95=E5=8A=A0=E4=B8=AA?= =?UTF-8?q?=E8=82=89=E9=B8=BD=E5=95=86=E5=BA=97=E6=98=AF=E5=90=A6=E4=B9=B0?= =?UTF-8?q?=E4=B8=AA=E6=99=8B=E5=8D=87=E7=B1=BB=E7=89=A9=E5=93=81=E7=9A=84?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RoguelikeShoppingTaskPlugin.cpp | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/MeoAssistant/RoguelikeShoppingTaskPlugin.cpp b/src/MeoAssistant/RoguelikeShoppingTaskPlugin.cpp index 3252992bbf..0bf7b8238e 100644 --- a/src/MeoAssistant/RoguelikeShoppingTaskPlugin.cpp +++ b/src/MeoAssistant/RoguelikeShoppingTaskPlugin.cpp @@ -44,6 +44,8 @@ bool asst::RoguelikeShoppingTaskPlugin::_run() json::value json_chars_info = json::parse(str_chars_info).value_or(json::value()); std::unordered_map map_roles_count; + std::unordered_map map_wait_promotion; + size_t total_wait_promotion = 0; std::unordered_set chars_list; for (auto& [name, json_info] : json_chars_info.as_object()) { int elite = static_cast(json_info.get("elite", 0)); @@ -51,7 +53,7 @@ bool asst::RoguelikeShoppingTaskPlugin::_run() Log.info(name, elite, level); // 等级太低的干员没必要为他专门买收藏品什么的 - if (elite * 1000 + level < 1070) { + if (level < 70) { continue; } @@ -60,10 +62,20 @@ bool asst::RoguelikeShoppingTaskPlugin::_run() if (name == "阿米娅") { map_roles_count[BattleRole::Caster] += 1; map_roles_count[BattleRole::Warrior] += 1; + if (elite == 1 && level == 70) { + total_wait_promotion += 1; + map_wait_promotion[BattleRole::Caster] += 1; + map_wait_promotion[BattleRole::Warrior] += 1; + } } else { BattleRole role = Resrc.battle_data().get_role(name); map_roles_count[role] += 1; + // TODO 这里应该判断一下星级,4星是60级,5星是70,6星是80,先偷个懒,有空再弄 + if (elite == 1 && level >= 60) { + total_wait_promotion += 1; + map_wait_promotion[role] += 1; + } } } @@ -101,6 +113,27 @@ bool asst::RoguelikeShoppingTaskPlugin::_run() continue; } } + if (goods.promotion != 0) { + if (total_wait_promotion == 0) { + Log.trace("Ready to buy", goods.name, + ", but there is no one waiting for promotion, skip"); + continue; + } + if (!goods.roles.empty()) { + bool role_mathced = false; + for (const auto& role : goods.roles) { + if (map_wait_promotion[role] != 0) { + role_mathced = true; + break; + } + } + if (!role_mathced) { + Log.trace("Ready to buy", goods.name, + ", but there is no one waiting for promotion, skip"); + continue; + } + } + } if (!goods.chars.empty()) { auto iter = std::find_first_of(chars_list.cbegin(), chars_list.cend(),