Breaking change: rework of talents.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -9,16 +9,17 @@ namespace CreatureLib::Library {
|
||||
uint32_t _baseExperience;
|
||||
ArbUt::List<uint8_t> _types;
|
||||
Library::StatisticSet<uint16_t> _baseStatistics;
|
||||
ArbUt::List<ArbUt::StringView> _talents;
|
||||
ArbUt::List<ArbUt::StringView> _secretTalents;
|
||||
ArbUt::List<ArbUt::BorrowedPtr<const Talent>> _talents;
|
||||
ArbUt::List<ArbUt::BorrowedPtr<const Talent>> _secretTalents;
|
||||
std::unique_ptr<const LearnableAttacks> _attacks;
|
||||
std::unordered_set<uint32_t> _flags;
|
||||
|
||||
public:
|
||||
impl(const ArbUt::StringView& name, float height, float weight, uint32_t baseExperience,
|
||||
ArbUt::List<uint8_t> types, Library::StatisticSet<uint16_t> baseStats,
|
||||
ArbUt::List<ArbUt::StringView> talents, ArbUt::List<ArbUt::StringView> secretTalents,
|
||||
const LearnableAttacks* attacks, std::unordered_set<uint32_t> flags)
|
||||
ArbUt::List<ArbUt::BorrowedPtr<const Talent>> talents,
|
||||
ArbUt::List<ArbUt::BorrowedPtr<const Talent>> secretTalents, const LearnableAttacks* attacks,
|
||||
std::unordered_set<uint32_t> flags)
|
||||
: _name(name), _height(height), _weight(weight), _baseExperience(baseExperience),
|
||||
_types(std::move((types))), _baseStatistics(baseStats), _talents(std::move(talents)),
|
||||
_secretTalents(std::move(secretTalents)), _attacks(attacks), _flags(std::move(flags)){};
|
||||
@@ -36,7 +37,7 @@ namespace CreatureLib::Library {
|
||||
}
|
||||
[[nodiscard]] inline size_t GetTalentCount() const noexcept { return _talents.Count(); }
|
||||
[[nodiscard]] inline size_t GetSecretTalentCount() const noexcept { return _secretTalents.Count(); }
|
||||
[[nodiscard]] const ArbUt::StringView& GetTalent(const TalentIndex& index) const {
|
||||
[[nodiscard]] const ArbUt::BorrowedPtr<const Talent>& GetTalent(const TalentIndex& index) const {
|
||||
if (index.IsSecret() && _secretTalents.Count() > 0) {
|
||||
auto i = index.GetIndex();
|
||||
if (i > _secretTalents.Count()) {
|
||||
@@ -50,7 +51,7 @@ namespace CreatureLib::Library {
|
||||
}
|
||||
return _talents.At(i);
|
||||
}
|
||||
[[nodiscard]] TalentIndex GetTalentIndex(const ArbUt::StringView& talent) const {
|
||||
[[nodiscard]] TalentIndex GetTalentIndex(const ArbUt::BorrowedPtr<Talent>& talent) const {
|
||||
for (size_t i = 0; i < _talents.Count(); i++) {
|
||||
if (_talents.At(i) == talent) {
|
||||
return TalentIndex(false, i);
|
||||
@@ -63,6 +64,19 @@ namespace CreatureLib::Library {
|
||||
}
|
||||
THROW("The given talent is not a valid talent for this creature.");
|
||||
}
|
||||
[[nodiscard]] TalentIndex GetTalentIndex(const ArbUt::StringView& talentName) const {
|
||||
for (size_t i = 0; i < _talents.Count(); i++) {
|
||||
if (_talents.At(i)->GetName() == talentName) {
|
||||
return TalentIndex(false, i);
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < _secretTalents.Count(); i++) {
|
||||
if (_secretTalents.At(i)->GetName() == talentName) {
|
||||
return TalentIndex(true, i);
|
||||
}
|
||||
}
|
||||
THROW("The given talent name is not a valid talent for this creature.");
|
||||
}
|
||||
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const CreatureLib::Library::LearnableAttacks>
|
||||
GetLearnableAttacks() const {
|
||||
@@ -71,8 +85,12 @@ namespace CreatureLib::Library {
|
||||
[[nodiscard]] inline TalentIndex GetRandomTalent(ArbUt::Random& rand) const noexcept {
|
||||
return TalentIndex(false, rand.Get(_talents.Count()));
|
||||
}
|
||||
[[nodiscard]] inline const ArbUt::List<ArbUt::StringView>& GetTalents() const { return _talents; }
|
||||
[[nodiscard]] inline const ArbUt::List<ArbUt::StringView>& GetSecretTalents() const { return _secretTalents; }
|
||||
[[nodiscard]] inline const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>& GetTalents() const {
|
||||
return _talents;
|
||||
}
|
||||
[[nodiscard]] inline const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>& GetSecretTalents() const {
|
||||
return _secretTalents;
|
||||
}
|
||||
|
||||
inline bool HasFlag(const ArbUt::StringView& key) const noexcept {
|
||||
return this->_flags.find(key) != this->_flags.end();
|
||||
@@ -84,9 +102,9 @@ namespace CreatureLib::Library {
|
||||
|
||||
SpeciesVariant::SpeciesVariant(const ArbUt::StringView& name, float height, float weight, uint32_t baseExperience,
|
||||
const ArbUt::List<uint8_t>& types, StatisticSet<uint16_t> baseStats,
|
||||
const ArbUt::List<ArbUt::StringView>& talents,
|
||||
const ArbUt::List<ArbUt::StringView>& secretTalents, const LearnableAttacks* attacks,
|
||||
const std::unordered_set<uint32_t>& flags)
|
||||
const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>& talents,
|
||||
const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>& secretTalents,
|
||||
const LearnableAttacks* attacks, const std::unordered_set<uint32_t>& flags)
|
||||
: _impl(new impl(name, height, weight, baseExperience, types, baseStats, talents, secretTalents, attacks,
|
||||
flags)) {}
|
||||
SpeciesVariant::~SpeciesVariant() = default;
|
||||
@@ -105,18 +123,21 @@ namespace CreatureLib::Library {
|
||||
|
||||
ImplGetter(size_t, GetTalentCount);
|
||||
ImplGetter(size_t, GetSecretTalentCount);
|
||||
const ArbUt::StringView& SpeciesVariant::GetTalent(const TalentIndex& index) const {
|
||||
const ArbUt::BorrowedPtr<const Talent>& SpeciesVariant::GetTalent(const TalentIndex& index) const {
|
||||
return _impl->GetTalent(index);
|
||||
}
|
||||
TalentIndex SpeciesVariant::GetTalentIndex(const ArbUt::StringView& talent) const {
|
||||
TalentIndex SpeciesVariant::GetTalentIndex(const ArbUt::BorrowedPtr<Talent>& talent) const {
|
||||
return _impl->GetTalentIndex(talent);
|
||||
}
|
||||
TalentIndex SpeciesVariant::GetTalentIndex(const ArbUt::StringView& talentName) const {
|
||||
return _impl->GetTalentIndex(talentName);
|
||||
}
|
||||
ImplGetter(ArbUt::BorrowedPtr<const LearnableAttacks>, GetLearnableAttacks);
|
||||
TalentIndex SpeciesVariant::GetRandomTalent(ArbUt::Random& rand) const noexcept {
|
||||
return _impl->GetRandomTalent(rand);
|
||||
}
|
||||
ImplGetter(const ArbUt::List<ArbUt::StringView>&, GetTalents);
|
||||
ImplGetter(const ArbUt::List<ArbUt::StringView>&, GetSecretTalents);
|
||||
ImplGetter(const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>&, GetTalents);
|
||||
ImplGetter(const ArbUt::List<ArbUt::BorrowedPtr<const Talent>>&, GetSecretTalents);
|
||||
|
||||
bool SpeciesVariant::HasFlag(const ArbUt::StringView& key) const noexcept { return _impl->HasFlag(key); }
|
||||
bool SpeciesVariant::HasFlag(uint32_t keyHash) const noexcept { return _impl->HasFlag(keyHash); }
|
||||
|
||||
Reference in New Issue
Block a user