From ef70f00c6c1145fbf46dad13df7f21c6cbf2edda Mon Sep 17 00:00:00 2001 From: MistEO Date: Mon, 26 Sep 2022 19:01:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=9F=BA=E5=BB=BA=E6=97=A0=E4=BA=BA=E6=9C=BA=E5=92=8C?= =?UTF-8?q?=20Fia=20=E7=9A=84=20enable=20=E5=AD=97=E6=AE=B5=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E8=A7=A3=E6=9E=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/3.6-基建排班协议.md | 4 ++- src/MeoAssistant/InfrastTask.cpp | 43 +++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/docs/3.6-基建排班协议.md b/docs/3.6-基建排班协议.md index 5a02d2ee93..1273cc881b 100644 --- a/docs/3.6-基建排班协议.md +++ b/docs/3.6-基建排班协议.md @@ -26,10 +26,12 @@ ], "duration": 360, // 工作持续时长(分钟),保留字段,目前无作用。以后可能到时间了弹窗提醒该换班了,或者直接自动换了 "Fiammetta": { // “菲亚梅塔” 为哪位干员使用,可选,不填写则不使用 - "target": "巫恋", // 目标干员 + "enable": true, // 是否使用“菲亚梅塔”,可选,默认 true + "target": "巫恋", // 目标干员,使用 OCR 进行,需要传入对应客户端语言的干员名 "order": "pre", // 在整个换班前使用,还是换完班才用,可选,取值范围 "pre" / "post",默认 "pre" }, "drones": { // 无人机使用,可选,不填写则不使用无人机 + "enable": true, // 是否使用无人机,可选,默认 true "room": "trading", // 为哪个类型房间使用,取值范围 "trading" / "manufacture" "index": 1, // 为第几个该类型房间使用,对应左边 tab 栏序号,取值范围 [1, 5] "rule": "all", // 使用规则,保留字段,目前无作用。以后可能拿来支持插拔等操作 diff --git a/src/MeoAssistant/InfrastTask.cpp b/src/MeoAssistant/InfrastTask.cpp index d05f7bbaf0..db5d1c6066 100644 --- a/src/MeoAssistant/InfrastTask.cpp +++ b/src/MeoAssistant/InfrastTask.cpp @@ -210,14 +210,22 @@ bool asst::InfrastTask::parse_and_set_custom_config(const std::filesystem::path& } } - if (auto Fia_opt = cur_plan.find("Fiammetta")) { - const auto& Fia_json = Fia_opt.value(); - auto target_opt = Fia_json.find("target"); - if (!target_opt) { - Log.error("Fiammetta target not setted"); - return false; + do { + auto Fia_opt = cur_plan.find("Fiammetta"); + if (!Fia_opt) { + break; } - const std::string& target = target_opt.value(); + const auto& Fia_json = Fia_opt.value(); + bool enable = Fia_json.get("enable", true); + if (!enable) { + break; + } + std::string target = Fia_json.get("target", std::string()); + if (target.empty()) { + Log.warn("Fiammetta's target is unsetted or empty"); + break; + } + Log.trace("Fiammetta's target:", target); infrast::CustomFacilityConfig facility_config(1); auto& room_config = facility_config.front(); room_config.names = { target, "菲亚梅塔" }; @@ -234,17 +242,28 @@ bool asst::InfrastTask::parse_and_set_custom_config(const std::filesystem::path& m_subtasks.emplace_back(std::move(Fia_task_ptr)); m_subtasks.emplace_back(m_infrast_begin_task_ptr); } - } + } while (false); - if (auto drones_opt = cur_plan.find("drones")) { + do { + auto drones_opt = cur_plan.find("drones"); + if (!drones_opt) { + break; + } const auto& drones_json = drones_opt.value(); - + bool enable = drones_json.get("enable", true); + if (!enable) { + break; + } infrast::CustomDronesConfig drones_config; drones_config.index = drones_json.get("index", 1) - 1; drones_config.order = drones_json.get("order", "pre") == "post" ? infrast::CustomDronesConfig::Order::Post : infrast::CustomDronesConfig::Order::Pre; std::string room = drones_json.get("room", std::string()); - if (room == "trading") { + if (room.empty()) { + Log.warn("drones room is unsetted or empty"); + break; + } + else if (room == "trading") { m_trade_task_ptr->set_custom_drones_config(std::move(drones_config)); } else if (room == "manufacture") { @@ -254,7 +273,7 @@ bool asst::InfrastTask::parse_and_set_custom_config(const std::filesystem::path& Log.error("error drones config, unknown room", room); return false; } - } + } while (false); return true; }