diff --git a/docs/集成文档.md b/docs/集成文档.md index 89e336a22b..5b854630f0 100644 --- a/docs/集成文档.md +++ b/docs/集成文档.md @@ -37,9 +37,10 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p ```jsonc // 对应的任务参数 { + "enable": bool, // 是否启用本任务,可选,默认为 true "client_type": string, // 客户端版本,可选,默认为空 // 选项:"Official" | "Bilibili" - "start_game_enable": bool // 是否自动启动客户端,可选,默认不启动 + "start_game_enabled": bool // 是否自动启动客户端,可选,默认不启动 } ``` @@ -49,6 +50,7 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p ```jsonc // 对应的任务参数 { + "enable": bool, // 是否启用本任务,可选,默认为 true "stage": string, // 关卡名,可选,默认“当前关卡”。不支持运行中设置 "medicine": int, // 最大使用理智药数量,可选,默认 0 "stone": int, // 最大吃石头数量,可选,默认 0 @@ -74,6 +76,7 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p ```jsonc // 对应的任务参数 { + "enable": bool, // 是否启用本任务,可选,默认为 true "refresh": bool, // 是否刷新三星 Tags, 可选,默认 false "select": [ // 会去点击标签的 Tag 等级,必选 int, @@ -97,6 +100,7 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p ```jsonc { + "enable": bool, // 是否启用本任务,可选,默认为 true "mode": int, // 换班工作模式,保留接口,暂时可以不传。不支持运行中设置 "facility": [ // 要换班的设施(有序),必选。不支持运行中设置 string, // 设施名,"Mfg" | "Trade" | "Power" | "Control" | "Reception" | "Office" | "Dorm" @@ -110,8 +114,14 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p ``` - `Visit` - 访问好友 - 不支持设置参数 + 访问好友 + +```jsonc +// 对应的任务参数 +{ + "enable": bool // 是否启用本任务,可选,默认为 true +} +``` - `Mall` 领取信用及商店购物。 @@ -120,6 +130,7 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p ```jsonc // 对应的任务参数 { + "enable": bool, // 是否启用本任务,可选,默认为 true "shopping": bool, // 是否购物,可选,默认 false。不支持运行中设置 "buy_first": [ // 优先购买列表,可选。不支持运行中设置 string, // 商品名,如 "招聘许可"、"龙门币" 等 @@ -133,14 +144,21 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p ``` - `Award` - 领取日常奖励 - 不支持设置参数 + 领取日常奖励 + +```jsonc +// 对应的任务参数 +{ + "enable": bool // 是否启用本任务,可选,默认为 true +} +``` - `Roguelike` 无限刷肉鸽 ```jsonc { + "enable": bool, // 是否启用本任务,可选,默认为 true "mode": int // 模式,可选项。默认 0 // 0 - 尽可能一直往后打 // 1 - 第一层投资完源石锭就退出 @@ -153,6 +171,7 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p ```jsonc { + "enable": bool, // 是否启用本任务,可选,默认为 true "stage_name": string, // 关卡名,需要与作业 JSON 中的 stage_name 字段相同。不支持运行期设置 "filename": string, // 作业 JSON 的文件路径,绝对、相对路径均可。不支持运行期设置 "formation": bool // 是否进行 “快捷编队”,可选,默认否。不支持运行期设置 diff --git a/src/MeoAssistant/Assistant.cpp b/src/MeoAssistant/Assistant.cpp index 054a389bfa..89d03ce20e 100644 --- a/src/MeoAssistant/Assistant.cpp +++ b/src/MeoAssistant/Assistant.cpp @@ -107,7 +107,10 @@ else if (type == TASK::TaskType) { ptr = std::make_shared(task_callback, s #undef ASST_ASSISTANT_APPEND_TASK_FROM_STRING_IF_BRANCH - bool params_ret = ptr->set_params(ret.value()); + auto& json = ret.value(); + bool enable = json.get("enable", true); + ptr->set_enable(enable); + bool params_ret = ptr->set_params(json); if (!params_ret) { return 0; } @@ -132,14 +135,18 @@ bool asst::Assistant::set_task_params(TaskId task_id, const std::string& params) if (!ret) { return false; } + auto& json = ret.value(); bool setted = false; std::unique_lock lock(m_mutex); for (auto&& [id, ptr] : m_tasks_list) { - if (id == task_id) { - setted = ptr->set_params(ret.value()); - break; + if (id != task_id) { + continue; } + bool enable = json.get("enable", true); + ptr->set_enable(enable); + setted = ptr->set_params(json); + break; } return setted; diff --git a/src/MeoAssistant/StartUpTask.cpp b/src/MeoAssistant/StartUpTask.cpp index d4696b960b..190130db26 100644 --- a/src/MeoAssistant/StartUpTask.cpp +++ b/src/MeoAssistant/StartUpTask.cpp @@ -20,6 +20,6 @@ asst::StartUpTask::StartUpTask(AsstCallback callback, void* callback_arg) bool asst::StartUpTask::set_params(const json::value& params) { m_start_game_task_ptr->set_client_type(params.get("client_type", "")) - .set_enable(params.get("start_game_enable", false)); + .set_enable(params.get("start_game_enabled", false)); return true; } diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index 203b7a37ad..48225bf8c2 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -855,7 +855,7 @@ namespace MeoAsstGui { var task_params = new JObject(); task_params["client_type"] = client_type; - task_params["start_game_enable"] = enable; + task_params["start_game_enabled"] = enable; TaskId id = AsstAppendTaskWithEncoding("StartUp", task_params); _latestTaskId[TaskType.StartUp] = id; return id != 0; diff --git a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs index fe2c7fe29d..c1cee1b6d5 100644 --- a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs +++ b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs @@ -467,7 +467,15 @@ namespace MeoAsstGui } var asstProxy = _container.Get(); - asstProxy.AsstSetFightTaskParams(Stage, medicine, stone, times, DropsItemId, drops_quantity); + bool setted = asstProxy.AsstSetFightTaskParams(Stage, medicine, stone, times, DropsItemId, drops_quantity); + if (setted) + { + AddLog("设置成功", "Black"); + } + else + { + AddLog("设置失败", "Black"); + } } private bool appendInfrast()