#include "UpgradeTemplate.h" using namespace nejlika; nejlika::UpgradeTemplate::UpgradeTemplate(const nlohmann::json& json) { Load(json); } nlohmann::json nejlika::UpgradeTemplate::ToJson() const { nlohmann::json json; json["name"] = name; json["lot"] = lot; json["max-level"] = maxLevel; nlohmann::json passivesJson = nlohmann::json::array(); for (const auto& passive : passives) { passivesJson.push_back(passive.ToJson()); } json["passives"] = passivesJson; return json; } void nejlika::UpgradeTemplate::Load(const nlohmann::json& json) { name = json["name"].get(); lot = json["lot"].get(); maxLevel = json["max-level"].contains("max-level") ? json["max-level"].get() : 1; passives.clear(); for (const auto& passive : json["passives"]) { UpgradeEffect effect(passive); passives.push_back(effect); } } std::vector nejlika::UpgradeTemplate::Trigger(int32_t level, UpgradeTriggerType triggerType, LWOOBJID origin) const { level = std::min(level, maxLevel); return UpgradeEffect::Trigger(passives, level, triggerType, origin); }