CreatureLib/src/Library/CreatureData/SpeciesVariant.hpp

115 lines
6.3 KiB
C++

#ifndef CREATURELIB_SPECIESVARIANT_HPP
#define CREATURELIB_SPECIESVARIANT_HPP
#include "../StatisticSet.hpp"
#include "LearnableAttacks.hpp"
#include "Talent.hpp"
#include "TalentIndex.hpp"
namespace CreatureLib::Library {
/// @brief A single species can have more than one variant. This class holds the data for those variants.
class SpeciesVariant {
private:
struct impl;
std::unique_ptr<impl> _impl;
public:
/// @brief Instantiate SpeciesVariant.
/// @param name The unique name of the variant.
/// @param height The height of the variant.
/// @param weight The weight of the variant.
/// @param baseExperience The number of base experienced that a variant returns when defeated.
/// @param types The indices of the types of the variant, as retrieved from the TypeLibrary.
/// @param baseStats The basic, unboosted stats of the variant.
/// @param talents The names of the possible talents of the variant. These are later resolved as scripts when
/// battling.
/// @param secretTalents The names of the possible secret talents of the variant. These are later resolved as
/// scripts when battling.
/// @param attacks The attacks that this variant can learn.
/// @param flags A set of flags for use by the developer. These can be used for easy grouping.
SpeciesVariant(const ArbUt::StringView& name, float height, float weight, u32 baseExperience,
const ArbUt::List<u8>& types, Library::StatisticSet<u16> baseStats,
const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>& talents,
const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>& secretTalents,
const LearnableAttacks* non_null attacks, const std::unordered_set<u32>& flags = {});
virtual ~SpeciesVariant();
/// @brief Returns the unique name of the variant.
/// @return The unique name of the variant.
const ArbUt::StringView& GetName() const noexcept;
/// @brief Returns the height of the variant.
/// @return The height of the variant. Traditionally in meters.
float GetHeight() const noexcept;
/// @brief Returns the weight of the variant.
/// @return The weight of the variant. Traditionally in kilograms.
float GetWeight() const noexcept;
/// @brief Returns the amount of base experience gained when defeating a creature with this variant.
/// @return The amount of base experience gained when defeating a creature with this variant.
u32 GetBaseExperience() const noexcept;
/// @brief Returns the amount of types this variant has.
/// @return The amount of types this variant has.
[[nodiscard]] size_t GetTypeCount() const noexcept;
/// @brief Returns a type index at a specified index.
/// @param index The index of the type requested.
/// @return A type index, as defined in TypeLibrary.
[[nodiscard]] u8 GetType(size_t index) const;
/// @brief Returns a list of the types on this variant.
/// @return A list of types on the variant,
[[nodiscard]] const ArbUt::List<u8>& GetTypes() const noexcept;
/// @brief Returns the base statistics.
/// @return The base statistics.
[[nodiscard]] const Library::StatisticSet<u16>& GetStatistics() const noexcept;
/// @brief Returns the value of a base statistic.
/// @param stat The desired statistic.
/// @return The base statistic value.
[[nodiscard]] u16 GetStatistic(Library::Statistic stat) const noexcept;
/// @brief Returns the amount of talents this variant has.
/// @return The amount of talents this variant has.
[[nodiscard]] size_t GetTalentCount() const noexcept;
/// @brief Returns the amount of secret talents this variant has.
/// @return The amount of secret talents this variant has.
[[nodiscard]] size_t GetSecretTalentCount() const noexcept;
/// @brief Returns a talent name at a specified TalentIndex.
/// @param index Whether it's a secret talent, and which index to get.
/// @return The name of the talent at the given TalentIndex.
[[nodiscard]] const ArbUt::BorrowedPtr<const Talent>& GetTalent(const TalentIndex& index) const;
/// @brief Search for the index of a specific talent.
/// @param talent The talent that's being looked for.
/// @return The index of the talent.
[[nodiscard]] TalentIndex GetTalentIndex(const ArbUt::BorrowedPtr<Talent>& talent) const;
/// @brief Search for the index of a talent with a name.
/// @param talentName The name that's being looked for.
/// @return The index of the talent.
[[nodiscard]] TalentIndex GetTalentIndex(const ArbUt::StringView& talentName) const;
/// @brief Returns the attacks the variant can learn.
/// @return The attacks the variant can learn.
[[nodiscard]] ArbUt::BorrowedPtr<const LearnableAttacks> GetLearnableAttacks() const noexcept;
/// @brief Returns a random talent from the normal talents (so not from the secret talents).
/// @param rand The random number generator.
/// @return The index of the random talent.
[[nodiscard]] TalentIndex GetRandomTalent(ArbUt::Random& rand) const noexcept;
/// @brief Returns a list of talents of the variant.
/// @return A list of talents of the variant.
[[nodiscard]] const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>& GetTalents() const noexcept;
/// @brief Returns a list of secret talents of the variant.
/// @return A list of secret talents of the variant.
[[nodiscard]] const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>& GetSecretTalents() const noexcept;
/// @brief Checks whether the species has a specific flag.
/// @param key The flag to check for.
/// @return True if the species has the flag, false otherwise.
bool HasFlag(const ArbUt::StringView& key) const noexcept;
/// @brief Checks whether the species has a specific flag.
/// @param keyHash The flag to check for.
/// @return True if the species has the flag, false otherwise.
bool HasFlag(u32 keyHash) const noexcept;
};
}
#endif // CREATURELIB_SPECIESVARIANT_HPP