diff --git a/src/Library/BaseLibrary.hpp b/src/Library/BaseLibrary.hpp index 7a66aac..0a635d3 100644 --- a/src/Library/BaseLibrary.hpp +++ b/src/Library/BaseLibrary.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,17 @@ namespace CreatureLib::Library { } [[nodiscard]] size_t GetCount() const { return _values.Count(); } + + inline const T* GetRandomValue(Arbutils::Random rand = Arbutils::Random()) const { + auto i = rand.Get(_values.Count()); + auto& map = _values.GetStdMap(); + return std::next(std::begin(map), i)->first; + } + inline const T* GetRandomValue(Arbutils::Random* rand) const { + auto i = rand->Get(_values.Count()); + auto& map = _values.GetStdMap(); + return std::next(std::begin(map), i)->first; + } }; }