Gen7Tests/src/BuildData/GrowthRatesBuilder.cpp

26 lines
787 B
C++
Raw Normal View History

2020-02-13 11:37:32 +00:00
#include "GrowthRatesBuilder.hpp"
#include <fstream>
#include <iostream>
#include "../../extern/json.hpp"
using json = nlohmann::json;
CreatureLib::Library::GrowthRateLibrary* GrowthRatesBuilder::Build(const std::string& path) {
std::ifstream fileStream(path.c_str());
if (fileStream.fail()) {
std::cout << "Failed to load Pokemon data file at '" << path << "'\n";
return nullptr;
}
auto lib = new CreatureLib::Library::GrowthRateLibrary();
json j;
fileStream >> j;
for (const auto& i : j.items()) {
const auto& name = i.key();
auto values = i.value();
2021-03-28 12:57:00 +00:00
lib->AddGrowthRate(ArbUt::StringView(name.c_str()),
2020-02-27 18:50:49 +00:00
new LookupGrowthRate(values.get<std::vector<uint32_t>>()));
2020-02-13 11:37:32 +00:00
}
return lib;
}