mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
chore: 移动arkplanner的默认模板到配置文件中,并简单修改了一下输出json格式
This commit is contained in:
@@ -442,3 +442,34 @@ Todo
|
||||
"id": string
|
||||
}
|
||||
```
|
||||
|
||||
- `DepotInfo`
|
||||
仓库识别结果
|
||||
|
||||
```jsonc
|
||||
// 对应的 details 字段举例
|
||||
// 目前只支持 ArkPlanner 的格式,以后可能会兼容更多网站
|
||||
"arkplanner": {
|
||||
"object": {
|
||||
"items": [
|
||||
{
|
||||
"id": "2004",
|
||||
"have": 4,
|
||||
"name": "高级作战记录"
|
||||
},
|
||||
{
|
||||
"id": "mod_unlock_token",
|
||||
"have": 25,
|
||||
"name": "模组数据块"
|
||||
},
|
||||
{
|
||||
"id": "2003",
|
||||
"have": 20,
|
||||
"name": "中级作战记录"
|
||||
}
|
||||
],
|
||||
"@type": "@penguin-statistics/depot"
|
||||
},
|
||||
"data": "{\"@type\":\"@penguin-statistics/depot\",\"items\":[{\"id\":\"2004\",\"have\":4,\"name\":\"高级作战记录\"},{\"id\":\"mod_unlock_token\",\"have\":25,\"name\":\"模组数据块\"},{\"id\":\"2003\",\"have\":20,\"name\":\"中级作战记录\"}]}"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
"Doc": "企鹅数据汇报: https://penguin-stats.cn/",
|
||||
"cmdFormat": "curl -H \"Content-Type: application/json\" -s -i -d \"[body]\" \"https://penguin-stats.cn/PenguinStats/api/v2/report\" [extra]",
|
||||
"cmdFormat_Doc": "命令格式,想打印详细信息可以尝试添加 -v -i"
|
||||
},
|
||||
"depotExportTemplate": {
|
||||
"Doc": "仓库识别导出结果模板",
|
||||
"arkPlanner": "{\"@type\": \"@penguin-statistics/depot\",\"items\": []}",
|
||||
"arkPlanner_Doc": "https://penguin-stats.cn/planner"
|
||||
}
|
||||
},
|
||||
"intent": {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Controller.h"
|
||||
#include "TaskData.h"
|
||||
#include "DepotImageAnalyzer.h"
|
||||
#include "Resource.h"
|
||||
|
||||
bool asst::DepotTask::run()
|
||||
{
|
||||
@@ -37,27 +38,27 @@ bool asst::DepotTask::run()
|
||||
future.wait();
|
||||
}
|
||||
|
||||
auto& templ = Resrc.cfg().get_options().depot_export_template;
|
||||
json::value info = basic_info_with_what("DepotInfo");
|
||||
auto& details = info["details"];
|
||||
|
||||
// TODO: move it to config file
|
||||
auto arkplanner_template_opt = json::parse(R"(
|
||||
{
|
||||
"@type": "@penguin-statistics/depot",
|
||||
"items": []
|
||||
}
|
||||
)");
|
||||
auto& arkplanner_data = info["details"]["data"]["arkplanner"];
|
||||
arkplanner_data = arkplanner_template_opt.value_or(json::value());
|
||||
auto& arkplanner_data_imtes = arkplanner_data["items"];
|
||||
auto arkplanner_template_opt = json::parse(templ.ark_planner);
|
||||
if (arkplanner_template_opt) {
|
||||
auto& arkplanner = details["arkplanner"];
|
||||
auto& arkplanner_obj = arkplanner["object"];
|
||||
arkplanner_obj = arkplanner_template_opt.value();
|
||||
auto& arkplanner_data_items = arkplanner_obj["items"];
|
||||
|
||||
for (const auto& [item_id, item_info] : all_items) {
|
||||
arkplanner_data_imtes.array_emplace(
|
||||
json::object({
|
||||
{ "id", item_id },
|
||||
{ "have", item_info.quantity },
|
||||
{ "name", item_info.item_name }
|
||||
})
|
||||
);
|
||||
for (const auto& [item_id, item_info] : all_items) {
|
||||
arkplanner_data_items.array_emplace(
|
||||
json::object({
|
||||
{ "id", item_id },
|
||||
{ "have", item_info.quantity },
|
||||
{ "name", item_info.item_name }
|
||||
})
|
||||
);
|
||||
}
|
||||
arkplanner["data"] = arkplanner_obj.to_string();
|
||||
}
|
||||
callback(AsstMsg::SubTaskExtraInfo, info);
|
||||
|
||||
|
||||
@@ -17,9 +17,7 @@ bool asst::GeneralConfiger::parse(const json::value& json)
|
||||
//m_options.print_window = options_json.at("printWindow").as_boolean();
|
||||
m_options.adb_extra_swipe_dist = options_json.get("adbExtraSwipeDist", 100);
|
||||
m_options.adb_extra_swipe_duration = options_json.get("adbExtraSwipeDuration", -1);
|
||||
|
||||
auto& penguin_report = options_json.at("penguinReport");
|
||||
m_options.penguin_report.cmd_format = penguin_report.get("cmdFormat", std::string());
|
||||
m_options.penguin_report.cmd_format = options_json.get("penguinReport", "cmdFormat", std::string());
|
||||
|
||||
if (options_json.contains("aipOcr")) {
|
||||
auto& aip_ocr = options_json.at("aipOcr");
|
||||
@@ -28,6 +26,7 @@ bool asst::GeneralConfiger::parse(const json::value& json)
|
||||
m_options.aip_ocr.client_id = aip_ocr.get("clientId", std::string());
|
||||
m_options.aip_ocr.client_secret = aip_ocr.get("clientSerect", std::string());
|
||||
}
|
||||
m_options.depot_export_template.ark_planner = options_json.get("depotExportTemplate", "arkPlanner", std::string());
|
||||
}
|
||||
|
||||
for (const auto& [client_type, intent_name] : json.at("intent").as_object()) {
|
||||
|
||||
@@ -24,6 +24,11 @@ namespace asst
|
||||
std::string cmd_format; // 命令格式
|
||||
};
|
||||
|
||||
struct DepotExportTemplate
|
||||
{
|
||||
std::string ark_planner;
|
||||
};
|
||||
|
||||
struct Options
|
||||
{
|
||||
int task_delay = 0; // 任务间延时:越快操作越快,但会增加CPU消耗
|
||||
@@ -34,6 +39,7 @@ namespace asst
|
||||
int adb_extra_swipe_duration = -1; // 额外的滑动持续时间:adb有bug,同样的参数,偶尔会划得非常远。额外做一个短程滑动,把之前的停下来。若小于0,则关闭额外滑动功能
|
||||
PenguinReportCfg penguin_report; // 企鹅数据汇报:每次到结算界面,汇报掉落数据至企鹅数据 https://penguin-stats.cn/
|
||||
AipOcrCfg aip_ocr; // 百度 OCR API 的配置
|
||||
DepotExportTemplate depot_export_template; // 仓库识别结果导出模板
|
||||
};
|
||||
|
||||
struct AdbCfg
|
||||
|
||||
Reference in New Issue
Block a user