mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 02:23:01 +08:00
feat: 新增自定义基建无人机和 Fia 的 enable 字段,优化部分解析逻辑
This commit is contained in:
@@ -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", // 使用规则,保留字段,目前无作用。以后可能拿来支持插拔等操作
|
||||
|
||||
@@ -210,14 +210,22 @@ bool asst::InfrastTask::parse_and_set_custom_config(const std::filesystem::path&
|
||||
}
|
||||
}
|
||||
|
||||
if (auto Fia_opt = cur_plan.find<json::object>("Fiammetta")) {
|
||||
const auto& Fia_json = Fia_opt.value();
|
||||
auto target_opt = Fia_json.find<std::string>("target");
|
||||
if (!target_opt) {
|
||||
Log.error("Fiammetta target not setted");
|
||||
return false;
|
||||
do {
|
||||
auto Fia_opt = cur_plan.find<json::object>("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<json::object>("drones")) {
|
||||
do {
|
||||
auto drones_opt = cur_plan.find<json::object>("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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user