46 lines
2.0 KiB
C++
46 lines
2.0 KiB
C++
#include "GrowthRateLibrary.hpp"
|
|
#include "../Exceptions/CreatureException.hpp"
|
|
|
|
uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const ArbUt::BasicStringView& growthRate,
|
|
uint32_t experience) const {
|
|
auto find = _growthRates.find(growthRate);
|
|
if (find == _growthRates.end()) {
|
|
throw CreatureException("Invalid growth rate was requested.");
|
|
}
|
|
return find->second->CalculateLevel(experience);
|
|
}
|
|
|
|
uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(uint32_t hash, uint32_t experience) const {
|
|
auto find = _growthRates.find(hash);
|
|
if (find == _growthRates.end()) {
|
|
throw CreatureException("Invalid growth rate was requested.");
|
|
}
|
|
return find->second->CalculateLevel(experience);
|
|
}
|
|
|
|
uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(const ArbUt::BasicStringView& growthRate,
|
|
uint8_t level) const {
|
|
auto find = _growthRates.find(growthRate);
|
|
if (find == _growthRates.end()) {
|
|
throw CreatureException("Invalid growth rate was requested.");
|
|
}
|
|
return find->second->CalculateExperience(level);
|
|
}
|
|
|
|
uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(uint32_t hash, uint8_t level) const {
|
|
auto find = _growthRates.find(hash);
|
|
if (find == _growthRates.end()) {
|
|
throw CreatureException("Invalid growth rate was requested.");
|
|
}
|
|
return find->second->CalculateExperience(level);
|
|
}
|
|
|
|
void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(const ArbUt::StringView& name,
|
|
CreatureLib::Library::GrowthRate* rate) {
|
|
_growthRates.insert({name, std::unique_ptr<const GrowthRate>(rate)});
|
|
}
|
|
|
|
void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(uint32_t hash, CreatureLib::Library::GrowthRate* rate) {
|
|
_growthRates.insert({hash, std::unique_ptr<const GrowthRate>(rate)});
|
|
}
|