47 lines
1.9 KiB
C++
47 lines
1.9 KiB
C++
#include "GrowthRateLibrary.hpp"
|
|
#include <Arbutils/Exception.hpp>
|
|
#include "../Exceptions/CreatureException.hpp"
|
|
|
|
u8 CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const ArbUt::BasicStringView& growthRate,
|
|
u32 experience) const {
|
|
auto find = _growthRates.find(growthRate);
|
|
if (find == _growthRates.end()) {
|
|
THROW("Invalid growth rate was requested.");
|
|
}
|
|
return find->second->CalculateLevel(experience);
|
|
}
|
|
|
|
u8 CreatureLib::Library::GrowthRateLibrary::CalculateLevel(u32 hash, u32 experience) const {
|
|
auto find = _growthRates.find(hash);
|
|
if (find == _growthRates.end()) {
|
|
THROW("Invalid growth rate was requested.");
|
|
}
|
|
return find->second->CalculateLevel(experience);
|
|
}
|
|
|
|
u32 CreatureLib::Library::GrowthRateLibrary::CalculateExperience(const ArbUt::BasicStringView& growthRate,
|
|
level_int_t level) const {
|
|
auto find = _growthRates.find(growthRate);
|
|
if (find == _growthRates.end()) {
|
|
THROW("Invalid growth rate was requested.");
|
|
}
|
|
return find->second->CalculateExperience(level);
|
|
}
|
|
|
|
u32 CreatureLib::Library::GrowthRateLibrary::CalculateExperience(u32 hash, level_int_t level) const {
|
|
auto find = _growthRates.find(hash);
|
|
if (find == _growthRates.end()) {
|
|
THROW("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(u32 hash, CreatureLib::Library::GrowthRate* rate) {
|
|
_growthRates.insert({hash, std::unique_ptr<const GrowthRate>(rate)});
|
|
}
|