Files
CreatureLib/src/Library/CreatureData/SpeciesVariant.hpp
Deukhoofd 899e432271
Some checks failed
continuous-integration/drone/push Build is failing
Added lots of security using asserts.
2020-03-22 13:42:26 +01:00

65 lines
2.7 KiB
C++

#ifndef CREATURELIB_SPECIESVARIANT_HPP
#define CREATURELIB_SPECIESVARIANT_HPP
#include <Arbutils/Random.hpp>
#include <string>
#include <vector>
#include "../StatisticSet.hpp"
#include "CreatureMoves.hpp"
#include "LearnableAttacks.hpp"
#include "TalentIndex.hpp"
using ConstString = Arbutils::CaseInsensitiveConstString;
namespace CreatureLib::Library {
/*!
\brief A single species can have more than one variant. This class holds the data for those variants.
*/
class SpeciesVariant {
protected:
ConstString _name;
float _height;
float _weight;
uint32_t _baseExperience;
private:
std::vector<uint8_t> _types;
const Library::StatisticSet<uint16_t>& _baseStatistics;
std::vector<ConstString> _talents;
std::vector<ConstString> _secretTalents;
const LearnableAttacks* _attacks;
public:
SpeciesVariant(ConstString name, float height, float weight, uint32_t baseExperience,
std::vector<uint8_t> types, const Library::StatisticSet<uint16_t>& baseStats,
std::vector<ConstString> talents, std::vector<ConstString> secretTalents,
const LearnableAttacks* attacks);
virtual ~SpeciesVariant();
inline const ConstString& GetName() const { return _name; }
inline float GetHeight() const { return _height; }
inline float GetWeight() const { return _weight; }
inline uint32_t GetBaseExperience() const { return _baseExperience; }
[[nodiscard]] size_t GetTypeCount() const;
[[nodiscard]] uint8_t GetType(size_t index) const;
[[nodiscard]] const std::vector<uint8_t>& GetTypes() const;
[[nodiscard]] uint32_t GetStatistic(Library::Statistic stat) const;
[[nodiscard]] const size_t GetTalentCount() const { return _talents.size(); }
[[nodiscard]] const size_t GetSecretTalentCount() const { return _secretTalents.size(); }
[[nodiscard]] const ConstString& GetTalent(const TalentIndex& index) const {
if (index.IsSecret())
return _secretTalents.at(index.GetIndex());
return _talents.at(index.GetIndex());
}
[[nodiscard]] const TalentIndex GetTalentIndex(const ConstString& talent) const;
[[nodiscard]] const LearnableAttacks* GetLearnableAttacks() const;
[[nodiscard]] TalentIndex GetRandomTalent(Arbutils::Random* rand) const;
[[nodiscard]] inline const std::vector<ConstString>& GetTalents() const { return _talents; }
[[nodiscard]] inline const std::vector<ConstString>& GetSecretTalents() const { return _secretTalents; }
};
}
#endif // CREATURELIB_SPECIESVARIANT_HPP