mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 17:57:01 +08:00
perf: 简化RoguelikeTask set_params
[skip changelog]
This commit is contained in:
@@ -155,17 +155,6 @@ bool asst::RoguelikeTask::set_params(const json::value& params)
|
||||
|
||||
m_invest_ptr->set_control_plugin_ptr(m_control_ptr);
|
||||
|
||||
const auto& ptr = m_custom_ptr;
|
||||
ptr->set_custom(RoguelikeCustomType::Squad, params.get("squad", "")); // 开局分队
|
||||
ptr->set_custom(RoguelikeCustomType::Roles, params.get("roles", "")); // 开局职业组
|
||||
ptr->set_custom(RoguelikeCustomType::CoreChar, params.get("core_char", "")); // 开局干员名
|
||||
ptr->set_custom(
|
||||
RoguelikeCustomType::UseSupport,
|
||||
params.get("use_support", false) ? "1" : "0"); // 开局干员是否为助战干员
|
||||
ptr->set_custom(
|
||||
RoguelikeCustomType::UseNonfriendSupport,
|
||||
params.get("use_nonfriend_support", false) ? "1" : "0"); // 是否可以是非好友助战干员
|
||||
|
||||
for (const auto& plugin : m_roguelike_task_ptr->get_plugins()) {
|
||||
if (const auto& p_ptr = std::dynamic_pointer_cast<AbstractRoguelikeTaskPlugin>(plugin); p_ptr != nullptr) {
|
||||
p_ptr->set_enable(p_ptr->load_params(params));
|
||||
|
||||
@@ -45,6 +45,19 @@ bool asst::RoguelikeCustomStartTaskPlugin::verify(AsstMsg msg, const json::value
|
||||
return true;
|
||||
}
|
||||
|
||||
bool asst::RoguelikeCustomStartTaskPlugin::load_params(const json::value& params)
|
||||
{
|
||||
set_custom(RoguelikeCustomType::Squad, params.get("squad", "")); // 开局分队
|
||||
set_custom(RoguelikeCustomType::Roles, params.get("roles", "")); // 开局职业组
|
||||
set_custom(RoguelikeCustomType::CoreChar, params.get("core_char", "")); // 开局干员名
|
||||
set_custom(RoguelikeCustomType::UseSupport, params.get("use_support", false) ? "1" : "0"); // 开局干员是否为助战干员
|
||||
set_custom(
|
||||
RoguelikeCustomType::UseNonfriendSupport,
|
||||
params.get("use_nonfriend_support", false) ? "1" : "0"); // 是否可以是非好友助战干员
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void asst::RoguelikeCustomStartTaskPlugin::set_custom(RoguelikeCustomType type, std::string custom)
|
||||
{
|
||||
m_customs.insert_or_assign(type, std::move(custom));
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace asst
|
||||
|
||||
public:
|
||||
virtual bool verify(AsstMsg msg, const json::value& details) const override;
|
||||
virtual bool load_params([[maybe_unused]] const json::value& params) override;
|
||||
void set_custom(RoguelikeCustomType type, std::string custom);
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user