/* * SpellSchoolHandler.cpp, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * * License: GNU General Public License v2.0 or later * Full text of license available in license.txt file, in main folder * */ #include "StdInc.h" #include "SpellSchoolHandler.h" #include "../json/JsonNode.h" VCMI_LIB_NAMESPACE_BEGIN std::vector SpellSchoolHandler::loadLegacyData() { objects.resize(4); return std::vector(4, JsonNode(JsonMap())); } std::shared_ptr SpellSchoolHandler::loadObjectImpl(std::string scope, std::string name, const JsonNode & data, size_t index) { auto ret = std::make_shared(); ret->id = SpellSchool(index); ret->jsonName = name; ret->spellBordersPath = AnimationPath::fromJson(data["schoolBorders"]); return ret; } /// loads single object into game. Scope is namespace of this object, same as name of source mod void SpellSchoolHandler::loadObject(std::string scope, std::string name, const JsonNode & data) { objects.push_back(loadObjectImpl(scope, name, data, objects.size())); registerObject(scope, "spellSchool", name, objects.back()->getIndex()); } void SpellSchoolHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) { assert(objects[index] == nullptr); // ensure that this id was not loaded before objects[index] = loadObjectImpl(scope, name, data, index); registerObject(scope, "spellSchool", name, objects[index]->getIndex()); } std::vector SpellSchoolHandler::getAllObjects() const { std::vector result; for (const auto & school : objects) result.push_back(school->id); return result; } VCMI_LIB_NAMESPACE_END