Mark LearnableAttacks on SpeciesVariant as unique.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-03-27 20:46:44 +01:00
parent 214ff81992
commit aee5bcb088
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
3 changed files with 9 additions and 7 deletions

View File

@ -46,6 +46,8 @@ SIMPLE_GET_FUNC(SpeciesVariant, GetSecretTalentCount, size_t);
export uint8_t CreatureLib_SpeciesVariant_GetTalent(SpeciesVariant* p, bool secret, uint8_t index) {
return p->GetTalent(TalentIndex(secret, index));
}
SIMPLE_GET_FUNC(SpeciesVariant, GetLearnableAttacks, const LearnableAttacks*);
export const LearnableAttacks* CreatureLib_SpeciesVariant_GetLearnableAttacks(SpeciesVariant* p) {
return p->GetLearnableAttacks().get();
}
#undef SIMPLE_GET_FUNC

View File

@ -31,7 +31,8 @@ CreatureLib::Library::TalentIndex CreatureLib::Library::SpeciesVariant::GetRando
return TalentIndex(false, rand->Get(_talents.Count()));
}
const CreatureLib::Library::LearnableAttacks* CreatureLib::Library::SpeciesVariant::GetLearnableAttacks() const {
const std::unique_ptr<const CreatureLib::Library::LearnableAttacks>&
CreatureLib::Library::SpeciesVariant::GetLearnableAttacks() const {
return _attacks;
}
@ -43,5 +44,3 @@ CreatureLib::Library::SpeciesVariant::SpeciesVariant(ConstString name, float hei
: _name(std::move(name)), _height(height), _weight(weight), _baseExperience(baseExperience),
_types(std::move(types)), _baseStatistics(baseStats), _talents(std::move(talents)),
_secretTalents(std::move(secretTalents)), _attacks(attacks) {}
CreatureLib::Library::SpeciesVariant::~SpeciesVariant() { delete _attacks; }

View File

@ -3,6 +3,7 @@
#include <Arbutils/Collections/List.hpp>
#include <Arbutils/Random.hpp>
#include <memory>
#include <string>
#include "../StatisticSet.hpp"
#include "CreatureMoves.hpp"
@ -27,14 +28,14 @@ namespace CreatureLib::Library {
Library::StatisticSet<uint16_t> _baseStatistics;
List<ConstString> _talents;
List<ConstString> _secretTalents;
const LearnableAttacks* _attacks;
std::unique_ptr<const LearnableAttacks> _attacks;
public:
SpeciesVariant(ConstString name, float height, float weight, uint32_t baseExperience, List<uint8_t> types,
Library::StatisticSet<uint16_t> baseStats, List<ConstString> talents,
List<ConstString> secretTalents, const LearnableAttacks* attacks);
virtual ~SpeciesVariant();
virtual ~SpeciesVariant() = default;
inline const ConstString& GetName() const { return _name; }
inline float GetHeight() const { return _height; }
@ -54,7 +55,7 @@ namespace CreatureLib::Library {
}
[[nodiscard]] const TalentIndex GetTalentIndex(const ConstString& talent) const;
[[nodiscard]] const LearnableAttacks* GetLearnableAttacks() const;
[[nodiscard]] const std::unique_ptr<const CreatureLib::Library::LearnableAttacks>& GetLearnableAttacks() const;
[[nodiscard]] TalentIndex GetRandomTalent(Arbutils::Random* rand) const;
[[nodiscard]] inline const List<ConstString>& GetTalents() const { return _talents; }
[[nodiscard]] inline const List<ConstString>& GetSecretTalents() const { return _secretTalents; }