Remove GetProperty macro, as it wasn't that intuitive, and caused issues later.
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:
@@ -6,8 +6,8 @@ CreatureLib::Library::AttackData::AttackData(std::string name, std::string type,
|
||||
uint8_t accuracy, uint8_t baseUsage,
|
||||
CreatureLib::Library::AttackTarget target, uint8_t priority,
|
||||
std::unordered_set<std::string> flags)
|
||||
: __Name(std::move(name)), __Type(std::move(type)), __Category(category), __BasePower(power), __Accuracy(accuracy),
|
||||
__BaseUsages(baseUsage), __Target(target), __Priority(priority), _flags(std::move(flags)) {}
|
||||
: _name(std::move(name)), _type(std::move(type)), _category(category), _basePower(power), _accuracy(accuracy),
|
||||
_baseUsages(baseUsage), _target(target), _priority(priority), _flags(std::move(flags)) {}
|
||||
|
||||
bool CreatureLib::Library::AttackData::HasFlag(const std::string& key) const {
|
||||
return this->_flags.find(key) != this->_flags.end();
|
||||
|
||||
@@ -3,28 +3,35 @@
|
||||
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include "../../GenericTemplates.hpp"
|
||||
#include "AttackCategory.hpp"
|
||||
#include "AttackTarget.hpp"
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
class AttackData {
|
||||
GetProperty(std::string, Name);
|
||||
GetProperty(std::string, Type);
|
||||
GetProperty(AttackCategory, Category);
|
||||
GetProperty(uint8_t, BasePower);
|
||||
GetProperty(uint8_t, Accuracy);
|
||||
GetProperty(uint8_t, BaseUsages);
|
||||
GetProperty(AttackTarget, Target);
|
||||
GetProperty(uint8_t, Priority);
|
||||
|
||||
private:
|
||||
protected:
|
||||
const std::string _name;
|
||||
const std::string _type;
|
||||
AttackCategory _category;
|
||||
uint8_t _basePower;
|
||||
uint8_t _accuracy;
|
||||
uint8_t _baseUsages;
|
||||
AttackTarget _target;
|
||||
int8_t _priority;
|
||||
std::unordered_set<std::string> _flags;
|
||||
|
||||
public:
|
||||
AttackData(std::string name, std::string type, AttackCategory category, uint8_t power, uint8_t accuracy,
|
||||
uint8_t baseUsage, AttackTarget target, uint8_t priority, std::unordered_set<std::string> flags);
|
||||
|
||||
inline const std::string& GetName() const { return _name; }
|
||||
inline const std::string& GetType() const { return _type; }
|
||||
inline AttackCategory GetCategory() const { return _category; }
|
||||
inline uint8_t GetBasePower() const { return _basePower; }
|
||||
inline uint8_t GetAccuracy() const { return _accuracy; }
|
||||
inline uint8_t GetBaseUsages() const { return _baseUsages; }
|
||||
inline AttackTarget GetTarget() const { return _target; }
|
||||
inline int8_t GetPriority() const { return _priority; }
|
||||
|
||||
bool HasFlag(const std::string& key) const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using namespace CreatureLib::Library;
|
||||
|
||||
CreatureSpecies::CreatureSpecies(uint16_t id, std::string name, const SpeciesVariant* defaultVariant, float genderRatio,
|
||||
std::string growthRate, uint8_t captureRate)
|
||||
: __Id(id), __GenderRate(genderRatio), __GrowthRate(std::move(growthRate)), __CaptureRate(captureRate),
|
||||
: _id(id), _genderRate(genderRatio), _growthRate(std::move(growthRate)), _captureRate(captureRate),
|
||||
_variants({{"default", defaultVariant}}), _name(std::move(name)) {}
|
||||
|
||||
const SpeciesVariant* CreatureSpecies::GetVariant(const std::string& key) const { return _variants.at(key); }
|
||||
@@ -12,7 +12,7 @@ const SpeciesVariant* CreatureSpecies::GetVariant(const std::string& key) const
|
||||
Gender CreatureSpecies::GetRandomGender(CreatureLib::Core::Random& rand) const {
|
||||
// TODO: Genderless creatures
|
||||
auto val = rand.GetDouble();
|
||||
if (val >= this->__GenderRate)
|
||||
if (val >= this->_genderRate)
|
||||
return Gender ::Female;
|
||||
return Gender ::Male;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace CreatureLib::Library {
|
||||
creatures with.
|
||||
*/
|
||||
class CreatureSpecies {
|
||||
GetProperty(uint16_t, Id);
|
||||
GetProperty(float, GenderRate);
|
||||
GetProperty(std::string, GrowthRate);
|
||||
GetProperty(uint8_t, CaptureRate);
|
||||
uint16_t _id;
|
||||
float _genderRate;
|
||||
std::string _growthRate;
|
||||
uint8_t _captureRate;
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, const SpeciesVariant*> _variants;
|
||||
@@ -31,6 +31,11 @@ namespace CreatureLib::Library {
|
||||
_variants.clear();
|
||||
}
|
||||
|
||||
inline uint16_t GetId() const { return _id; }
|
||||
inline float GetGenderRate() const { return _genderRate; }
|
||||
inline const std::string& GetGrowthRate() const { return _growthRate; }
|
||||
inline uint8_t GetCaptureRate() const { return _captureRate; }
|
||||
|
||||
[[nodiscard]] const SpeciesVariant* GetVariant(const std::string& key) const;
|
||||
[[nodiscard]] Gender GetRandomGender(Core::Random& rand) const;
|
||||
[[nodiscard]] const std::string& GetName() const;
|
||||
|
||||
@@ -50,7 +50,7 @@ CreatureLib::Library::SpeciesVariant::SpeciesVariant(std::string name, float hei
|
||||
std::vector<std::string> talents,
|
||||
std::vector<std::string> secretTalents,
|
||||
const LearnableAttacks* attacks)
|
||||
: __Name(std::move(name)), __Height(height), __Weight(weight), __BaseExperience(baseExperience),
|
||||
: _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) {}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <vector>
|
||||
#include "../../Core/Random.hpp"
|
||||
#include "../../Core/StatisticSet.hpp"
|
||||
#include "../../GenericTemplates.hpp"
|
||||
#include "CreatureMoves.hpp"
|
||||
#include "LearnableAttacks.hpp"
|
||||
|
||||
@@ -14,10 +13,11 @@ namespace CreatureLib::Library {
|
||||
\brief A single species can have more than one variant. This class holds the data for those variants.
|
||||
*/
|
||||
class SpeciesVariant {
|
||||
GetProperty(std::string, Name);
|
||||
GetProperty(float, Height);
|
||||
GetProperty(float, Weight);
|
||||
GetProperty(uint32_t, BaseExperience);
|
||||
protected:
|
||||
std::string _name;
|
||||
float _height;
|
||||
float _weight;
|
||||
uint32_t _baseExperience;
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> _types;
|
||||
@@ -34,6 +34,11 @@ namespace CreatureLib::Library {
|
||||
|
||||
~SpeciesVariant();
|
||||
|
||||
inline const std::string& 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;
|
||||
|
||||
@@ -3,3 +3,7 @@
|
||||
bool CreatureLib::Library::Item::HasFlag(const std::string& flag) const {
|
||||
return this->_flags.find(flag) != this->_flags.end();
|
||||
}
|
||||
CreatureLib::Library::Item::Item(std::string name, CreatureLib::Library::ItemCategory category,
|
||||
CreatureLib::Library::BattleItemCategory battleCategory, int32_t price,
|
||||
std::unordered_set<std::string> flags)
|
||||
: _name(name), _category(category), _battleCategory(battleCategory), _price(price), _flags(flags) {}
|
||||
|
||||
@@ -3,24 +3,27 @@
|
||||
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include "../../GenericTemplates.hpp"
|
||||
#include "BattleItemCategory.hpp"
|
||||
#include "ItemCategory.hpp"
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
class Item {
|
||||
GetProperty(std::string, Name);
|
||||
GetProperty(ItemCategory, Category);
|
||||
GetProperty(BattleItemCategory, BattleCategory);
|
||||
GetProperty(int32_t, Price);
|
||||
|
||||
private:
|
||||
protected:
|
||||
std::string _name;
|
||||
ItemCategory _category;
|
||||
BattleItemCategory _battleCategory;
|
||||
int32_t _price;
|
||||
std::unordered_set<std::string> _flags;
|
||||
|
||||
public:
|
||||
Item(std::string name, ItemCategory category, BattleItemCategory battleCategory, int32_t price,
|
||||
std::unordered_set<std::string> flags);
|
||||
|
||||
inline const std::string GetName() const { return _name; }
|
||||
inline ItemCategory GetCategory() const { return _category; }
|
||||
inline BattleItemCategory GetBattleCategory() const { return _battleCategory; }
|
||||
inline const int32_t GetPrice() const { return _price; }
|
||||
|
||||
bool HasFlag(const std::string& flag) const;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user