CreatureLib/src/Library/GrowthRates/GrowthRateLibrary.hpp

30 lines
1.1 KiB
C++

#ifndef CREATURELIB_GROWTHRATELIBRARY_HPP
#define CREATURELIB_GROWTHRATELIBRARY_HPP
#include <Arbutils/String/StringView.hpp>
#include <unordered_map>
#include "GrowthRate.hpp"
namespace CreatureLib::Library {
class GrowthRateLibrary {
private:
std::unordered_map<u32, std::unique_ptr<const GrowthRate>> _growthRates;
public:
GrowthRateLibrary(size_t initialCapacity = 10)
: _growthRates(std::unordered_map<u32, std::unique_ptr<const GrowthRate>>(initialCapacity)) {}
virtual ~GrowthRateLibrary() = default;
[[nodiscard]] level_int_t CalculateLevel(const ArbUt::BasicStringView& growthRate, u32 experience) const;
[[nodiscard]] level_int_t CalculateLevel(u32 hash, u32 experience) const;
[[nodiscard]] u32 CalculateExperience(const ArbUt::BasicStringView& growthRate, level_int_t level) const;
[[nodiscard]] u32 CalculateExperience(u32 hash, level_int_t level) const;
void AddGrowthRate(u32 hash, GrowthRate* rate);
void AddGrowthRate(const ArbUt::StringView& name, GrowthRate* rate);
};
}
#endif // CREATURELIB_GROWTHRATELIBRARY_HPP