29 lines
1.0 KiB
C++
29 lines
1.0 KiB
C++
#include "CreatureSpecies.hpp"
|
|
|
|
#include <utility>
|
|
using namespace CreatureLib::Library;
|
|
|
|
CreatureSpecies::CreatureSpecies(uint16_t id, std::string name, const SpeciesVariant* defaultVariant,
|
|
float genderRatio, std::string growthRate, uint8_t captureRate, uint8_t baseHappiness)
|
|
:
|
|
__Id(id),
|
|
__Name(std::move(name)),
|
|
__GenderRate(genderRatio),
|
|
__GrowthRate(std::move(growthRate)),
|
|
__CaptureRate(captureRate),
|
|
__BaseHappiness(baseHappiness),
|
|
_variants({{"default", defaultVariant}})
|
|
{}
|
|
|
|
const SpeciesVariant *CreatureSpecies::GetVariant(const std::string& key) const {
|
|
return _variants.at(key);
|
|
}
|
|
|
|
Gender CreatureSpecies::GetRandomGender(CreatureLib::Core::Random &rand) const {
|
|
// TODO: Genderless creatures
|
|
auto val = rand.GetDouble();
|
|
if (val >= this->__GenderRate) return Gender ::Female;
|
|
return Gender ::Male;
|
|
}
|
|
|