Update to newer Arbutils version.
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:
@@ -1,7 +1,7 @@
|
||||
#include "AttackData.hpp"
|
||||
#include <utility>
|
||||
|
||||
CreatureLib::Library::AttackData::AttackData(const ConstString& name, uint8_t type,
|
||||
CreatureLib::Library::AttackData::AttackData(const ArbUt::CaseInsensitiveConstString& name, uint8_t type,
|
||||
CreatureLib::Library::AttackCategory category, uint8_t power,
|
||||
uint8_t accuracy, uint8_t baseUsage,
|
||||
CreatureLib::Library::AttackTarget target, int8_t priority,
|
||||
@@ -9,7 +9,7 @@ CreatureLib::Library::AttackData::AttackData(const ConstString& name, uint8_t ty
|
||||
: _name(name), _type(type), _category(category), _basePower(power), _accuracy(accuracy), _baseUsages(baseUsage),
|
||||
_target(target), _priority(priority), _effect(effect), _flags(std::move(flags)) {}
|
||||
|
||||
bool CreatureLib::Library::AttackData::HasFlag(const ConstString& key) const noexcept {
|
||||
bool CreatureLib::Library::AttackData::HasFlag(const ArbUt::CaseInsensitiveConstString& key) const noexcept {
|
||||
return this->_flags.find(key) != this->_flags.end();
|
||||
}
|
||||
bool CreatureLib::Library::AttackData::HasFlag(uint32_t key) const noexcept {
|
||||
|
||||
@@ -9,12 +9,10 @@
|
||||
#include "AttackTarget.hpp"
|
||||
#include "SecondaryEffect.hpp"
|
||||
|
||||
using ConstString = Arbutils::CaseInsensitiveConstString;
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
class AttackData {
|
||||
protected:
|
||||
ConstString _name;
|
||||
ArbUt::CaseInsensitiveConstString _name;
|
||||
uint8_t _type;
|
||||
AttackCategory _category;
|
||||
uint8_t _basePower;
|
||||
@@ -26,12 +24,12 @@ namespace CreatureLib::Library {
|
||||
std::unordered_set<uint32_t> _flags;
|
||||
|
||||
public:
|
||||
AttackData(const ConstString& name, uint8_t type, AttackCategory category, uint8_t power, uint8_t accuracy,
|
||||
uint8_t baseUsage, AttackTarget target, int8_t priority, const SecondaryEffect* effect,
|
||||
std::unordered_set<uint32_t> flags);
|
||||
AttackData(const ArbUt::CaseInsensitiveConstString& name, uint8_t type, AttackCategory category, uint8_t power,
|
||||
uint8_t accuracy, uint8_t baseUsage, AttackTarget target, int8_t priority,
|
||||
const SecondaryEffect* effect, std::unordered_set<uint32_t> flags);
|
||||
virtual ~AttackData() = default;
|
||||
|
||||
inline const ConstString& GetName() const noexcept { return _name; }
|
||||
inline const ArbUt::CaseInsensitiveConstString& GetName() const noexcept { return _name; }
|
||||
inline const uint8_t GetType() const noexcept { return _type; }
|
||||
inline AttackCategory GetCategory() const noexcept { return _category; }
|
||||
inline uint8_t GetBasePower() const noexcept { return _basePower; }
|
||||
@@ -44,7 +42,7 @@ namespace CreatureLib::Library {
|
||||
}
|
||||
inline const std::unique_ptr<const SecondaryEffect>& GetSecondaryEffect() const noexcept { return _effect; }
|
||||
|
||||
bool HasFlag(const ConstString& key) const noexcept;
|
||||
bool HasFlag(const ArbUt::CaseInsensitiveConstString& key) const noexcept;
|
||||
bool HasFlag(uint32_t keyHash) const noexcept;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,18 +6,17 @@
|
||||
#include <any>
|
||||
#include "../EffectParameter.hpp"
|
||||
|
||||
using namespace Arbutils::Collections;
|
||||
namespace CreatureLib::Library {
|
||||
class SecondaryEffect {
|
||||
private:
|
||||
float _chance;
|
||||
Arbutils::CaseInsensitiveConstString _effectName;
|
||||
List<EffectParameter*> _parameters;
|
||||
ArbUt::CaseInsensitiveConstString _effectName;
|
||||
ArbUt::List<EffectParameter*> _parameters;
|
||||
|
||||
public:
|
||||
SecondaryEffect() noexcept : _chance(0), _effectName() {}
|
||||
SecondaryEffect(float chance, const Arbutils::CaseInsensitiveConstString& effectName,
|
||||
const List<EffectParameter*>& parameters) noexcept
|
||||
SecondaryEffect(float chance, const ArbUt::CaseInsensitiveConstString& effectName,
|
||||
const ArbUt::List<EffectParameter*>& parameters) noexcept
|
||||
: _chance(chance), _effectName(effectName), _parameters(parameters) {}
|
||||
|
||||
~SecondaryEffect() {
|
||||
@@ -27,10 +26,8 @@ namespace CreatureLib::Library {
|
||||
}
|
||||
|
||||
constexpr inline float GetChance() const noexcept { return _chance; }
|
||||
constexpr inline const Arbutils::CaseInsensitiveConstString& GetEffectName() const noexcept {
|
||||
return _effectName;
|
||||
}
|
||||
const inline List<EffectParameter*>& GetParameters() const noexcept { return _parameters; }
|
||||
constexpr inline const ArbUt::CaseInsensitiveConstString& GetEffectName() const noexcept { return _effectName; }
|
||||
const inline ArbUt::List<EffectParameter*>& GetParameters() const noexcept { return _parameters; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <Arbutils/Collections/Dictionary.hpp>
|
||||
#include <Arbutils/Collections/List.hpp>
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <Arbutils/Memory/borrowed_ptr.hpp>
|
||||
#include <Arbutils/Memory/BorrowedPtr.hpp>
|
||||
#include <Arbutils/Random.hpp>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
template <class T> class BaseLibrary {
|
||||
Arbutils::Collections::Dictionary<uint32_t, std::unique_ptr<const T>> _values;
|
||||
Arbutils::Collections::List<uint32_t> _listValues;
|
||||
ArbUt::Dictionary<uint32_t, std::unique_ptr<const T>> _values;
|
||||
ArbUt::List<uint32_t> _listValues;
|
||||
size_t _index;
|
||||
|
||||
public:
|
||||
@@ -22,7 +22,7 @@ namespace CreatureLib::Library {
|
||||
|
||||
virtual ~BaseLibrary() { _values.Clear(); }
|
||||
|
||||
inline void Insert(const Arbutils::CaseInsensitiveConstString& key, const T* value) {
|
||||
inline void Insert(const ArbUt::CaseInsensitiveConstString& key, const T* value) {
|
||||
AssertNotNull(value)
|
||||
_values.GetStdMap().insert({key.GetHash(), std::unique_ptr<const T>(value)});
|
||||
_listValues.Append(key);
|
||||
@@ -33,7 +33,7 @@ namespace CreatureLib::Library {
|
||||
_listValues.Append(hashedKey);
|
||||
}
|
||||
|
||||
inline void Delete(const Arbutils::CaseInsensitiveConstString& key) {
|
||||
inline void Delete(const ArbUt::CaseInsensitiveConstString& key) {
|
||||
_values.erase(key.GetHash());
|
||||
auto k = _listValues.IndexOf(key);
|
||||
_listValues.Remove(k);
|
||||
@@ -44,10 +44,10 @@ namespace CreatureLib::Library {
|
||||
_listValues.Remove(k);
|
||||
}
|
||||
|
||||
bool TryGet(const Arbutils::CaseInsensitiveConstString& name, borrowed_ptr<const T>& out) const {
|
||||
bool TryGet(const ArbUt::CaseInsensitiveConstString& name, ArbUt::BorrowedPtr<const T>& out) const {
|
||||
return TryGet(name.GetHash(), out);
|
||||
}
|
||||
bool TryGet(uint32_t hashedKey, borrowed_ptr<const T>& out) const {
|
||||
bool TryGet(uint32_t hashedKey, ArbUt::BorrowedPtr<const T>& out) const {
|
||||
auto find = _values.GetStdMap().find(hashedKey);
|
||||
if (find == _values.GetStdMap().end())
|
||||
return false;
|
||||
@@ -55,27 +55,29 @@ namespace CreatureLib::Library {
|
||||
return true;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline borrowed_ptr<const T> Get(const Arbutils::CaseInsensitiveConstString& name) const {
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> Get(const ArbUt::CaseInsensitiveConstString& name) const {
|
||||
return _values.Get(name.GetHash());
|
||||
}
|
||||
[[nodiscard]] inline borrowed_ptr<const T> Get(uint32_t hashedKey) const { return _values.Get(hashedKey); }
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> Get(uint32_t hashedKey) const {
|
||||
return _values.Get(hashedKey);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline borrowed_ptr<const T> operator[](const Arbutils::CaseInsensitiveConstString& name) const {
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const T>
|
||||
operator[](const ArbUt::CaseInsensitiveConstString& name) const {
|
||||
return Get(name);
|
||||
}
|
||||
[[nodiscard]] inline borrowed_ptr<const T> operator[](uint32_t hashedKey) const { return Get(hashedKey); }
|
||||
[[nodiscard]] inline const Arbutils::Collections::Dictionary<uint32_t, const std::unique_ptr<const T>>&
|
||||
GetIterator() const {
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> operator[](uint32_t hashedKey) const { return Get(hashedKey); }
|
||||
[[nodiscard]] inline const ArbUt::Dictionary<uint32_t, const std::unique_ptr<const T>>& GetIterator() const {
|
||||
return _values;
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t GetCount() const { return _values.Count(); }
|
||||
|
||||
inline borrowed_ptr<const T> GetRandomValue(Arbutils::Random rand = Arbutils::Random()) const {
|
||||
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random rand = ArbUt::Random()) const {
|
||||
auto i = rand.Get(_listValues.Count());
|
||||
return _values[_listValues[i]];
|
||||
}
|
||||
inline borrowed_ptr<const T> GetRandomValue(Arbutils::Random* rand) const {
|
||||
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random* rand) const {
|
||||
auto i = rand->Get(_listValues.Count());
|
||||
return _values[_listValues[i]];
|
||||
}
|
||||
|
||||
@@ -3,19 +3,21 @@
|
||||
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
CreatureSpecies::CreatureSpecies(uint16_t id, const ConstString& name, const SpeciesVariant* defaultVariant,
|
||||
float genderRatio, const ConstString& growthRate, uint8_t captureRate)
|
||||
CreatureSpecies::CreatureSpecies(uint16_t id, const ArbUt::CaseInsensitiveConstString& name,
|
||||
const SpeciesVariant* defaultVariant, float genderRatio,
|
||||
const ArbUt::CaseInsensitiveConstString& growthRate, uint8_t captureRate)
|
||||
: _name(name), _id(id), _genderRate(genderRatio), _growthRate(growthRate), _captureRate(captureRate), _variants(1) {
|
||||
AssertNotNull(defaultVariant)
|
||||
SetVariant("default"_cnc, defaultVariant);
|
||||
}
|
||||
|
||||
bool CreatureSpecies::HasVariant(const ConstString& name) const { return _variants.Has(name); }
|
||||
bool CreatureSpecies::HasVariant(const ArbUt::CaseInsensitiveConstString& name) const { return _variants.Has(name); }
|
||||
|
||||
bool CreatureSpecies::TryGetVariant(const ConstString& name, borrowed_ptr<const SpeciesVariant>& out) const {
|
||||
bool CreatureSpecies::TryGetVariant(const ArbUt::CaseInsensitiveConstString& name,
|
||||
ArbUt::BorrowedPtr<const SpeciesVariant>& out) const {
|
||||
return TryGetVariant(name.GetHash(), out);
|
||||
}
|
||||
bool CreatureSpecies::TryGetVariant(uint32_t hash, borrowed_ptr<const SpeciesVariant>& out) const {
|
||||
bool CreatureSpecies::TryGetVariant(uint32_t hash, ArbUt::BorrowedPtr<const SpeciesVariant>& out) const {
|
||||
auto find = _variants.GetStdMap().find(hash);
|
||||
if (find == _variants.end())
|
||||
return false;
|
||||
@@ -23,17 +25,18 @@ bool CreatureSpecies::TryGetVariant(uint32_t hash, borrowed_ptr<const SpeciesVar
|
||||
return true;
|
||||
}
|
||||
|
||||
borrowed_ptr<const SpeciesVariant> CreatureSpecies::GetVariant(const ConstString& name) const {
|
||||
ArbUt::BorrowedPtr<const SpeciesVariant>
|
||||
CreatureSpecies::GetVariant(const ArbUt::CaseInsensitiveConstString& name) const {
|
||||
return _variants.Get(name);
|
||||
}
|
||||
borrowed_ptr<const SpeciesVariant> CreatureSpecies::GetVariant(uint32_t key) const { return _variants.Get(key); }
|
||||
ArbUt::BorrowedPtr<const SpeciesVariant> CreatureSpecies::GetVariant(uint32_t key) const { return _variants.Get(key); }
|
||||
bool CreatureSpecies::HasVariant(uint32_t hash) const { return _variants.Has(hash); }
|
||||
|
||||
void CreatureSpecies::SetVariant(const ConstString& name, const SpeciesVariant* variant) {
|
||||
void CreatureSpecies::SetVariant(const ArbUt::CaseInsensitiveConstString& name, const SpeciesVariant* variant) {
|
||||
_variants.GetStdMap().insert({name, std::unique_ptr<const SpeciesVariant>(variant)});
|
||||
}
|
||||
|
||||
Gender CreatureSpecies::GetRandomGender(Arbutils::Random& rand) const {
|
||||
Gender CreatureSpecies::GetRandomGender(ArbUt::Random& rand) const {
|
||||
// TODO: Genderless creatures
|
||||
auto val = rand.GetDouble();
|
||||
if (val >= this->_genderRate)
|
||||
|
||||
@@ -3,52 +3,52 @@
|
||||
|
||||
#include <Arbutils/Collections/Dictionary.hpp>
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <Arbutils/Memory/borrowed_ptr.hpp>
|
||||
#include <Arbutils/Memory/BorrowedPtr.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "../Gender.hpp"
|
||||
#include "SpeciesVariant.hpp"
|
||||
|
||||
using ConstString = Arbutils::CaseInsensitiveConstString;
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
/*!
|
||||
\brief This holds the data required for a species of a creature, so the general data we can describe different
|
||||
creatures with.
|
||||
*/
|
||||
class CreatureSpecies {
|
||||
const ConstString _name;
|
||||
const ArbUt::CaseInsensitiveConstString _name;
|
||||
uint16_t _id;
|
||||
float _genderRate;
|
||||
const ConstString _growthRate;
|
||||
const ArbUt::CaseInsensitiveConstString _growthRate;
|
||||
uint8_t _captureRate;
|
||||
Arbutils::Collections::Dictionary<uint32_t, std::unique_ptr<const SpeciesVariant>> _variants;
|
||||
ArbUt::Dictionary<uint32_t, std::unique_ptr<const SpeciesVariant>> _variants;
|
||||
|
||||
public:
|
||||
CreatureSpecies(uint16_t id, const ConstString& name, const SpeciesVariant* defaultVariant, float genderRatio,
|
||||
const ConstString& growthRate, uint8_t captureRate);
|
||||
CreatureSpecies(uint16_t id, const ArbUt::CaseInsensitiveConstString& name,
|
||||
const SpeciesVariant* defaultVariant, float genderRatio,
|
||||
const ArbUt::CaseInsensitiveConstString& growthRate, uint8_t captureRate);
|
||||
|
||||
virtual ~CreatureSpecies() { _variants.Clear(); }
|
||||
|
||||
inline uint16_t GetId() const { return _id; }
|
||||
inline float GetGenderRate() const { return _genderRate; }
|
||||
inline const ConstString& GetGrowthRate() const { return _growthRate; }
|
||||
inline const ArbUt::CaseInsensitiveConstString& GetGrowthRate() const { return _growthRate; }
|
||||
inline uint8_t GetCaptureRate() const { return _captureRate; }
|
||||
|
||||
[[nodiscard]] bool HasVariant(const ConstString& key) const;
|
||||
[[nodiscard]] bool HasVariant(const ArbUt::CaseInsensitiveConstString& key) const;
|
||||
[[nodiscard]] bool HasVariant(uint32_t hash) const;
|
||||
[[nodiscard]] bool TryGetVariant(const ConstString& name, borrowed_ptr<const SpeciesVariant>& out) const;
|
||||
[[nodiscard]] bool TryGetVariant(uint32_t hash, borrowed_ptr<const SpeciesVariant>& out) const;
|
||||
[[nodiscard]] borrowed_ptr<const SpeciesVariant> GetVariant(const ConstString& key) const;
|
||||
[[nodiscard]] borrowed_ptr<const SpeciesVariant> GetVariant(uint32_t key) const;
|
||||
[[nodiscard]] Gender GetRandomGender(Arbutils::Random& rand) const;
|
||||
[[nodiscard]] const ConstString& GetName() const { return _name; }
|
||||
[[nodiscard]] bool TryGetVariant(const ArbUt::CaseInsensitiveConstString& name,
|
||||
ArbUt::BorrowedPtr<const SpeciesVariant>& out) const;
|
||||
[[nodiscard]] bool TryGetVariant(uint32_t hash, ArbUt::BorrowedPtr<const SpeciesVariant>& out) const;
|
||||
[[nodiscard]] ArbUt::BorrowedPtr<const SpeciesVariant>
|
||||
GetVariant(const ArbUt::CaseInsensitiveConstString& key) const;
|
||||
[[nodiscard]] ArbUt::BorrowedPtr<const SpeciesVariant> GetVariant(uint32_t key) const;
|
||||
[[nodiscard]] Gender GetRandomGender(ArbUt::Random& rand) const;
|
||||
[[nodiscard]] const ArbUt::CaseInsensitiveConstString& GetName() const { return _name; }
|
||||
|
||||
void SetVariant(const ConstString& name, const SpeciesVariant* variant);
|
||||
void SetVariant(const ArbUt::CaseInsensitiveConstString& name, const SpeciesVariant* variant);
|
||||
|
||||
const Arbutils::Collections::Dictionary<uint32_t, std::unique_ptr<const SpeciesVariant>>&
|
||||
GetVariantsIterator() const {
|
||||
const ArbUt::Dictionary<uint32_t, std::unique_ptr<const SpeciesVariant>>& GetVariantsIterator() const {
|
||||
return _variants;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
void LearnableAttacks::AddLevelAttack(uint8_t level, const AttackData* attack) {
|
||||
|
||||
List<const AttackData*> levelData;
|
||||
ArbUt::List<const AttackData*> levelData;
|
||||
if (_learnedByLevel.TryGet(level, levelData)) {
|
||||
levelData.Append(attack);
|
||||
} else {
|
||||
@@ -14,6 +13,6 @@ void LearnableAttacks::AddLevelAttack(uint8_t level, const AttackData* attack) {
|
||||
_distinctAttacks.insert(attack);
|
||||
}
|
||||
|
||||
const List<const AttackData*>& LearnableAttacks::GetAttacksForLevel(uint8_t level) const {
|
||||
const ArbUt::List<const AttackData*>& LearnableAttacks::GetAttacksForLevel(uint8_t level) const {
|
||||
return _learnedByLevel.Get(level);
|
||||
}
|
||||
|
||||
@@ -8,17 +8,15 @@
|
||||
#include <unordered_map>
|
||||
#include "../Attacks/AttackData.hpp"
|
||||
|
||||
using namespace Arbutils::Collections;
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
class LearnableAttacks {
|
||||
protected:
|
||||
Dictionary<uint8_t, List<const AttackData*>> _learnedByLevel;
|
||||
ArbUt::Dictionary<uint8_t, ArbUt::List<const AttackData*>> _learnedByLevel;
|
||||
std::unordered_set<const AttackData*> _distinctAttacks;
|
||||
|
||||
public:
|
||||
explicit LearnableAttacks(size_t levelAttackCapacity)
|
||||
: _learnedByLevel(Dictionary<uint8_t, List<const AttackData*>>(levelAttackCapacity)) {
|
||||
: _learnedByLevel(ArbUt::Dictionary<uint8_t, ArbUt::List<const AttackData*>>(levelAttackCapacity)) {
|
||||
for (auto kv : _learnedByLevel) {
|
||||
for (auto attack : kv.second) {
|
||||
AssertNotNull(attack)
|
||||
@@ -31,9 +29,9 @@ namespace CreatureLib::Library {
|
||||
|
||||
void AddLevelAttack(uint8_t level, const AttackData* attack);
|
||||
|
||||
const List<const AttackData*>& GetAttacksForLevel(uint8_t level) const;
|
||||
const ArbUt::List<const AttackData*>& GetAttacksForLevel(uint8_t level) const;
|
||||
|
||||
virtual const AttackData* GetRandomAttack(Arbutils::Random& rand) const {
|
||||
virtual const AttackData* GetRandomAttack(ArbUt::Random& rand) const {
|
||||
if (_distinctAttacks.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
const List<uint8_t>& CreatureLib::Library::SpeciesVariant::GetTypes() const { return _types; }
|
||||
const ArbUt::List<uint8_t>& CreatureLib::Library::SpeciesVariant::GetTypes() const { return _types; }
|
||||
|
||||
size_t CreatureLib::Library::SpeciesVariant::GetTypeCount() const { return _types.Count(); }
|
||||
|
||||
@@ -13,7 +13,7 @@ uint16_t CreatureLib::Library::SpeciesVariant::GetStatistic(CreatureLib::Library
|
||||
}
|
||||
|
||||
const CreatureLib::Library::TalentIndex
|
||||
CreatureLib::Library::SpeciesVariant::GetTalentIndex(const ConstString& talent) const {
|
||||
CreatureLib::Library::SpeciesVariant::GetTalentIndex(const ArbUt::CaseInsensitiveConstString& talent) const {
|
||||
for (size_t i = 0; i < _talents.Count(); i++) {
|
||||
if (_talents.At(i) == talent) {
|
||||
return TalentIndex(false, i);
|
||||
@@ -27,7 +27,7 @@ CreatureLib::Library::SpeciesVariant::GetTalentIndex(const ConstString& talent)
|
||||
throw CreatureException("The given talent is not a valid talent for this creature.");
|
||||
}
|
||||
|
||||
CreatureLib::Library::TalentIndex CreatureLib::Library::SpeciesVariant::GetRandomTalent(Arbutils::Random* rand) const {
|
||||
CreatureLib::Library::TalentIndex CreatureLib::Library::SpeciesVariant::GetRandomTalent(ArbUt::Random* rand) const {
|
||||
return TalentIndex(false, rand->Get(_talents.Count()));
|
||||
}
|
||||
|
||||
@@ -36,10 +36,11 @@ CreatureLib::Library::SpeciesVariant::GetLearnableAttacks() const {
|
||||
return _attacks;
|
||||
}
|
||||
|
||||
CreatureLib::Library::SpeciesVariant::SpeciesVariant(ConstString name, float height, float weight,
|
||||
uint32_t baseExperience, List<uint8_t> types,
|
||||
CreatureLib::Library::SpeciesVariant::SpeciesVariant(ArbUt::CaseInsensitiveConstString name, float height, float weight,
|
||||
uint32_t baseExperience, ArbUt::List<uint8_t> types,
|
||||
CreatureLib::Library::StatisticSet<uint16_t> baseStats,
|
||||
List<ConstString> talents, List<ConstString> secretTalents,
|
||||
ArbUt::List<ArbUt::CaseInsensitiveConstString> talents,
|
||||
ArbUt::List<ArbUt::CaseInsensitiveConstString> secretTalents,
|
||||
const LearnableAttacks* attacks)
|
||||
: _name(std::move(name)), _height(height), _weight(weight), _baseExperience(baseExperience),
|
||||
_types(std::move(types)), _baseStatistics(baseStats), _talents(std::move(talents)),
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include "../StatisticSet.hpp"
|
||||
#include "LearnableAttacks.hpp"
|
||||
#include "TalentIndex.hpp"
|
||||
using ConstString = Arbutils::CaseInsensitiveConstString;
|
||||
using namespace Arbutils::Collections;
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
/*!
|
||||
@@ -17,47 +15,52 @@ namespace CreatureLib::Library {
|
||||
*/
|
||||
class SpeciesVariant {
|
||||
protected:
|
||||
ConstString _name;
|
||||
ArbUt::CaseInsensitiveConstString _name;
|
||||
float _height;
|
||||
float _weight;
|
||||
uint32_t _baseExperience;
|
||||
|
||||
private:
|
||||
List<uint8_t> _types;
|
||||
ArbUt::List<uint8_t> _types;
|
||||
Library::StatisticSet<uint16_t> _baseStatistics;
|
||||
List<ConstString> _talents;
|
||||
List<ConstString> _secretTalents;
|
||||
ArbUt::List<ArbUt::CaseInsensitiveConstString> _talents;
|
||||
ArbUt::List<ArbUt::CaseInsensitiveConstString> _secretTalents;
|
||||
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);
|
||||
SpeciesVariant(ArbUt::CaseInsensitiveConstString name, float height, float weight, uint32_t baseExperience,
|
||||
ArbUt::List<uint8_t> types, Library::StatisticSet<uint16_t> baseStats,
|
||||
ArbUt::List<ArbUt::CaseInsensitiveConstString> talents,
|
||||
ArbUt::List<ArbUt::CaseInsensitiveConstString> secretTalents, const LearnableAttacks* attacks);
|
||||
|
||||
virtual ~SpeciesVariant() = default;
|
||||
|
||||
inline const ConstString& GetName() const { return _name; }
|
||||
inline const ArbUt::CaseInsensitiveConstString& 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 List<uint8_t>& GetTypes() const;
|
||||
[[nodiscard]] const ArbUt::List<uint8_t>& GetTypes() const;
|
||||
[[nodiscard]] uint16_t GetStatistic(Library::Statistic stat) const;
|
||||
[[nodiscard]] const size_t GetTalentCount() const { return _talents.Count(); }
|
||||
[[nodiscard]] const size_t GetSecretTalentCount() const { return _secretTalents.Count(); }
|
||||
[[nodiscard]] const ConstString& GetTalent(const TalentIndex& index) const {
|
||||
[[nodiscard]] const ArbUt::CaseInsensitiveConstString& 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 TalentIndex GetTalentIndex(const ArbUt::CaseInsensitiveConstString& talent) 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; }
|
||||
[[nodiscard]] TalentIndex GetRandomTalent(ArbUt::Random* rand) const;
|
||||
[[nodiscard]] inline const ArbUt::List<ArbUt::CaseInsensitiveConstString>& GetTalents() const {
|
||||
return _talents;
|
||||
}
|
||||
[[nodiscard]] inline const ArbUt::List<ArbUt::CaseInsensitiveConstString>& GetSecretTalents() const {
|
||||
return _secretTalents;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@ namespace CreatureLib::Library {
|
||||
class EffectParameter {
|
||||
private:
|
||||
EffectParameterType _type = EffectParameterType::None;
|
||||
std::variant<bool, int64_t, float, Arbutils::CaseInsensitiveConstString> _value;
|
||||
std::variant<bool, int64_t, float, ArbUt::CaseInsensitiveConstString> _value;
|
||||
|
||||
public:
|
||||
EffectParameter() : _type(EffectParameterType::None){};
|
||||
explicit EffectParameter(bool b) : _type(EffectParameterType::Bool), _value(b){};
|
||||
explicit EffectParameter(int64_t i) : _type(EffectParameterType::Int), _value(i){};
|
||||
explicit EffectParameter(float f) : _type(EffectParameterType::Float), _value(f){};
|
||||
explicit EffectParameter(const Arbutils::CaseInsensitiveConstString& s)
|
||||
explicit EffectParameter(const ArbUt::CaseInsensitiveConstString& s)
|
||||
: _type(EffectParameterType::String), _value(s){};
|
||||
EffectParameter(const EffectParameter& other) = delete;
|
||||
EffectParameter& operator=(const EffectParameter& other) = delete;
|
||||
@@ -54,13 +54,13 @@ namespace CreatureLib::Library {
|
||||
}
|
||||
return std::get<float>(_value);
|
||||
}
|
||||
const Arbutils::CaseInsensitiveConstString& AsString() const {
|
||||
const ArbUt::CaseInsensitiveConstString& AsString() const {
|
||||
if (_type != EffectParameterType::String) {
|
||||
std::stringstream ss;
|
||||
ss << "Cast effect parameter to string, but was " << EffectParameterTypeHelper::ToString(_type);
|
||||
throw CreatureException(ss.str());
|
||||
}
|
||||
return std::get<Arbutils::CaseInsensitiveConstString>(_value);
|
||||
return std::get<ArbUt::CaseInsensitiveConstString>(_value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <unordered_map>
|
||||
#include "GrowthRate.hpp"
|
||||
|
||||
using ConstString = Arbutils::CaseInsensitiveConstString;
|
||||
using ConstString = ArbUt::CaseInsensitiveConstString;
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
class GrowthRateLibrary {
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
namespace CreatureLib::Library {
|
||||
class LookupGrowthRate : public GrowthRate {
|
||||
protected:
|
||||
Arbutils::Collections::List<uint32_t> _experience;
|
||||
ArbUt::List<uint32_t> _experience;
|
||||
|
||||
public:
|
||||
LookupGrowthRate(const Arbutils::Collections::List<uint32_t>& experience) : _experience(experience) {}
|
||||
LookupGrowthRate(const ArbUt::List<uint32_t>& experience) : _experience(experience) {}
|
||||
|
||||
uint8_t CalculateLevel(uint32_t experience) const override {
|
||||
for (uint8_t i = 0; i < _experience.Count(); i++) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "Item.hpp"
|
||||
|
||||
bool CreatureLib::Library::Item::HasFlag(const Arbutils::CaseInsensitiveConstString& flag) const noexcept {
|
||||
bool CreatureLib::Library::Item::HasFlag(const ArbUt::CaseInsensitiveConstString& flag) const noexcept {
|
||||
return this->_flags.find(flag) != this->_flags.end();
|
||||
}
|
||||
bool CreatureLib::Library::Item::HasFlag(uint32_t flag) const noexcept {
|
||||
return this->_flags.find(flag) != this->_flags.end();
|
||||
}
|
||||
|
||||
CreatureLib::Library::Item::Item(const Arbutils::CaseInsensitiveConstString& name,
|
||||
CreatureLib::Library::Item::Item(const ArbUt::CaseInsensitiveConstString& name,
|
||||
CreatureLib::Library::ItemCategory category,
|
||||
CreatureLib::Library::BattleItemCategory battleCategory, int32_t price,
|
||||
const std::unordered_set<uint32_t>& flags)
|
||||
|
||||
@@ -10,22 +10,22 @@
|
||||
namespace CreatureLib::Library {
|
||||
class Item {
|
||||
protected:
|
||||
Arbutils::CaseInsensitiveConstString _name;
|
||||
ArbUt::CaseInsensitiveConstString _name;
|
||||
ItemCategory _category;
|
||||
BattleItemCategory _battleCategory;
|
||||
int32_t _price;
|
||||
std::unordered_set<uint32_t> _flags;
|
||||
|
||||
public:
|
||||
Item(const Arbutils::CaseInsensitiveConstString& name, ItemCategory category, BattleItemCategory battleCategory,
|
||||
Item(const ArbUt::CaseInsensitiveConstString& name, ItemCategory category, BattleItemCategory battleCategory,
|
||||
int32_t price, const std::unordered_set<uint32_t>& flags);
|
||||
|
||||
inline const Arbutils::CaseInsensitiveConstString& GetName() const noexcept { return _name; }
|
||||
inline const ArbUt::CaseInsensitiveConstString& GetName() const noexcept { return _name; }
|
||||
inline ItemCategory GetCategory() const noexcept { return _category; }
|
||||
inline BattleItemCategory GetBattleCategory() const noexcept { return _battleCategory; }
|
||||
inline const int32_t GetPrice() const noexcept { return _price; }
|
||||
|
||||
bool HasFlag(const Arbutils::CaseInsensitiveConstString& flag) const noexcept;
|
||||
bool HasFlag(const ArbUt::CaseInsensitiveConstString& flag) const noexcept;
|
||||
bool HasFlag(uint32_t flag) const noexcept;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
float TypeLibrary::GetEffectiveness(uint8_t attacking, const List<uint8_t>& defensive) const {
|
||||
float TypeLibrary::GetEffectiveness(uint8_t attacking, const ArbUt::List<uint8_t>& defensive) const {
|
||||
return std::accumulate(
|
||||
defensive.begin(), defensive.end(), (float)1,
|
||||
[this, attacking](float init, uint8_t defense) { return init * GetSingleEffectiveness(attacking, defense); });
|
||||
@@ -14,10 +14,10 @@ float TypeLibrary::GetSingleEffectiveness(uint8_t attacking, uint8_t defensive)
|
||||
return _effectiveness[attacking][defensive];
|
||||
}
|
||||
|
||||
uint8_t TypeLibrary::GetTypeId(const ConstString& key) const { return _types.Get(key); }
|
||||
uint8_t TypeLibrary::GetTypeId(const ArbUt::CaseInsensitiveConstString& key) const { return _types.Get(key); }
|
||||
uint8_t TypeLibrary::GetTypeId(uint32_t s) const { return _types.Get(s); }
|
||||
|
||||
uint8_t TypeLibrary::RegisterType(const ConstString& key) {
|
||||
uint8_t TypeLibrary::RegisterType(const ArbUt::CaseInsensitiveConstString& key) {
|
||||
_types.Insert(key, _types.Count());
|
||||
_effectiveness.Resize(_types.Count());
|
||||
for (auto& eff : _effectiveness) {
|
||||
|
||||
@@ -6,23 +6,21 @@
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
using ConstString = Arbutils::CaseInsensitiveConstString;
|
||||
using namespace Arbutils::Collections;
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
class TypeLibrary {
|
||||
Dictionary<uint32_t, uint8_t> _types;
|
||||
List<List<float>> _effectiveness;
|
||||
ArbUt::Dictionary<uint32_t, uint8_t> _types;
|
||||
ArbUt::List<ArbUt::List<float>> _effectiveness;
|
||||
|
||||
public:
|
||||
TypeLibrary(size_t initialCapacity = 20) : _types(Dictionary<uint32_t, uint8_t>(initialCapacity)) {}
|
||||
TypeLibrary(size_t initialCapacity = 20) : _types(ArbUt::Dictionary<uint32_t, uint8_t>(initialCapacity)) {}
|
||||
|
||||
uint8_t GetTypeId(const ConstString& s) const;
|
||||
uint8_t GetTypeId(const ArbUt::CaseInsensitiveConstString& s) const;
|
||||
uint8_t GetTypeId(uint32_t s) const;
|
||||
[[nodiscard]] float GetSingleEffectiveness(uint8_t attacking, uint8_t defensive) const;
|
||||
[[nodiscard]] float GetEffectiveness(uint8_t attacking, const List<uint8_t>& defensive) const;
|
||||
[[nodiscard]] float GetEffectiveness(uint8_t attacking, const ArbUt::List<uint8_t>& defensive) const;
|
||||
|
||||
uint8_t RegisterType(const ConstString& typeName);
|
||||
uint8_t RegisterType(const ArbUt::CaseInsensitiveConstString& typeName);
|
||||
uint8_t RegisterType(uint32_t typeHash);
|
||||
void SetEffectiveness(uint8_t attacking, uint8_t defensive, float effectiveness);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user