PkmnLibAI/test_runner/BuildData/GrowthRatesBuilder.hpp

34 lines
1.0 KiB
C++
Raw Normal View History

2021-04-18 11:37:14 +00:00
#ifndef GEN7TESTS_GROWTHRATESBUILDER_HPP
#define GEN7TESTS_GROWTHRATESBUILDER_HPP
#define LEVEL_U8 1
#include <CreatureLib/Library/GrowthRates/GrowthRate.hpp>
#include <CreatureLib/Library/GrowthRates/GrowthRateLibrary.hpp>
#include <utility>
#include <vector>
class LookupGrowthRate : public CreatureLib::Library::GrowthRate {
std::vector<uint32_t> _experience;
public:
LookupGrowthRate(std::vector<uint32_t> experience) : _experience(std::move(experience)) {}
[[nodiscard]] uint8_t CalculateLevel(uint32_t experience) const override {
for (size_t i = 0; i < _experience.size(); i++) {
if (_experience[i] > experience) {
return i;
}
}
return _experience[_experience.size() - 1];
}
[[nodiscard]] uint32_t CalculateExperience(uint8_t level) const override { return _experience[level - 1]; }
};
class GrowthRatesBuilder {
public:
static CreatureLib::Library::GrowthRateLibrary* Build(const std::string& file);
};
#endif // GEN7TESTS_GROWTHRATESBUILDER_HPP