mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 17:57:01 +08:00
feat: 单步任务支持设置关卡名
This commit is contained in:
@@ -18,7 +18,10 @@ bool asst::SingleStepTask::set_params(const json::value& params)
|
||||
auto details_opt = params.find("details");
|
||||
|
||||
if (type == "copilot") {
|
||||
if (subtype == "start") {
|
||||
if (subtype == "stage" && details_opt) {
|
||||
return set_copilot_stage(*details_opt);
|
||||
}
|
||||
else if (subtype == "start") {
|
||||
return append_copllot_start();
|
||||
}
|
||||
else if (subtype == "action" && details_opt) {
|
||||
@@ -28,6 +31,11 @@ bool asst::SingleStepTask::set_params(const json::value& params)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool asst::SingleStepTask::set_copilot_stage(const json::value& details)
|
||||
{
|
||||
return SingleStepBattleProcessTask::set_stage_name_cache(details.get("stage_name", ""));
|
||||
}
|
||||
|
||||
bool asst::SingleStepTask::append_copllot_start()
|
||||
{
|
||||
LogTraceFunction;
|
||||
@@ -45,9 +53,6 @@ bool asst::SingleStepTask::append_copilot_action(const json::value& details)
|
||||
|
||||
auto task = std::make_shared<SingleStepBattleProcessTask>(m_callback, m_inst, TaskType);
|
||||
|
||||
// for debug
|
||||
task->set_stage_name("OF-1");
|
||||
|
||||
try {
|
||||
// 请参考自动战斗协议
|
||||
auto actions = CopilotConfig::parse_actions(details);
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace asst
|
||||
virtual bool set_params(const json::value& params) override;
|
||||
|
||||
private:
|
||||
bool set_copilot_stage(const json::value& details);
|
||||
bool append_copllot_start();
|
||||
bool append_copilot_action(const json::value& details);
|
||||
};
|
||||
|
||||
@@ -4,6 +4,18 @@
|
||||
#include "Task/ProcessTask.h"
|
||||
#include "Utils/Logger.hpp"
|
||||
|
||||
bool asst::SingleStepBattleProcessTask::set_stage_name_cache(const std::string& stage_name)
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
if (!Tile.contains(stage_name)) {
|
||||
Log.error("get stage info failed", stage_name);
|
||||
return false;
|
||||
}
|
||||
m_stage_name_cache = stage_name;
|
||||
return true;
|
||||
}
|
||||
|
||||
void asst::SingleStepBattleProcessTask::set_actions(Actions actions)
|
||||
{
|
||||
m_actions = std::move(actions);
|
||||
@@ -13,8 +25,8 @@ bool asst::SingleStepBattleProcessTask::_run()
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
if (!calc_tiles_info(m_stage_name)) {
|
||||
Log.error("get stage info failed");
|
||||
if (!calc_tiles_info(m_stage_name_cache)) {
|
||||
Log.error("get stage info failed", m_stage_name_cache);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace asst
|
||||
virtual ~SingleStepBattleProcessTask() override = default;
|
||||
|
||||
using BattleProcessTask::clear;
|
||||
using BattleProcessTask::set_stage_name;
|
||||
|
||||
static bool set_stage_name_cache(const std::string& stage_name);
|
||||
void set_actions(Actions actions);
|
||||
|
||||
protected:
|
||||
@@ -23,5 +23,8 @@ namespace asst
|
||||
|
||||
private:
|
||||
Actions m_actions;
|
||||
|
||||
// for debug
|
||||
inline static std::string m_stage_name_cache;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user