feat: 在CopilotTask中添加参数support_unit_name

This commit is contained in:
Hydrogina
2022-11-24 17:28:47 +08:00
parent 5af2011055
commit b3c209a235
7 changed files with 13 additions and 15 deletions

View File

@@ -43,10 +43,5 @@
],
"opers": [],
"stage_name": "activities/act3d0/level_act3d0_01",
"difficulty": 3,
"support_unit": {
"name": "_RANDOM_",
"skill": 1,
"skill_usage": 1
}
"difficulty": 3
}

View File

@@ -14,8 +14,6 @@ bool asst::CopilotConfiger::parse(const json::value& json)
battle_actions.details = json.get("doc", "details", std::string());
battle_actions.details_color = json.get("doc", "details_color", std::string());
battle_actions.support_unit_name = json.get("support_unit", "name", std::string());
if (auto opt = json.find<json::array>("groups")) {
for (const auto& group_info : opt.value()) {
std::string group_name = group_info.at("name").as_string();

View File

@@ -45,6 +45,8 @@ bool asst::CopilotTask::set_params(const json::value& params)
bool with_formation = params.get("formation", false);
m_formation_task_ptr->set_enable(with_formation);
std::string support_unit_name = params.get("support_unit_name", "");
m_formation_task_ptr->set_support_unit_name(support_unit_name);
const std::string& filename = filename_opt.value();
return Copilot.load(utils::path(filename));

View File

@@ -25,19 +25,20 @@ asst::CreditFightTask::CreditFightTask(AsstCallback callback, void* callback_arg
stage_navigation_task_ptr->set_enable(false).set_ignore_error(false);
const std::string stage = "OF-1";
//开始
// 开始
start_up_task_ptr->set_tasks({ "StageBegin" }).set_times_limit("GoLastBattle", 0);
//关卡导航
// 关卡导航
stage_navigation_task_ptr->set_stage_name(stage);
stage_navigation_task_ptr->set_enable(true);
//自动战斗
// 自动战斗
json::value copilotparams;
copilotparams["stage_name"] = "activities/act3d0/level_act3d0_01"; // OF-1
std::string copilot_path = utils::path_to_utf8_string(ResDir.get()) + "\\resource\\credit_fight_copilot.json";
copilotparams["filename"] = copilot_path;
copilotparams["formation"] = true;
copilotparams["support_unit_name"] = "_RANDOM_";
copilot_task_ptr->set_params(copilotparams);
// 战斗结束后

View File

@@ -53,14 +53,13 @@ bool asst::BattleFormationTask::_run()
}
confirm_selection();
//借一个随机助战
if (Copilot.get_actions(m_stage_name).support_unit_name=="_RANDOM_") {
// 借一个随机助战
if (m_support_unit_name == "_RANDOM_") {
if (!select_random_support_unit()) {
return false;
}
}
return true;
}

View File

@@ -12,6 +12,8 @@ namespace asst
void set_stage_name(std::string name);
void set_support_unit_name(std::string name) { m_support_unit_name = name; }
protected:
using OperGroup = std::vector<BattleDeployOper>;
virtual bool _run() override;
@@ -27,5 +29,7 @@ namespace asst
std::string m_stage_name;
std::unordered_map<BattleRole, std::vector<OperGroup>> m_formation;
std::string m_the_right_name;
std::string m_support_unit_name = "";
};
}

View File

@@ -79,7 +79,6 @@ namespace asst
std::string details;
std::string details_color;
std::unordered_map<std::string, std::vector<BattleDeployOper>> groups;
std::string support_unit_name;
std::vector<BattleAction> actions;
};