Remove GetProperty macro, as it wasn't that intuitive, and caused issues later.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-01-12 17:04:42 +01:00
parent 779f0b08cf
commit b02577554f
12 changed files with 95 additions and 88 deletions

View File

@@ -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();

View File

@@ -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;
};
}