Remove GetProperty macro, as it wasn't that intuitive, and caused issues later.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
779f0b08cf
commit
b02577554f
|
@ -10,20 +10,20 @@ Battling::Creature::Creature(const BattleLibrary* library, const Library::Creatu
|
||||||
const Library::SpeciesVariant* variant, uint8_t level, uint32_t experience, uint32_t uid,
|
const Library::SpeciesVariant* variant, uint8_t level, uint32_t experience, uint32_t uid,
|
||||||
Library::Gender gender, uint8_t coloring, const Library::Item* heldItem,
|
Library::Gender gender, uint8_t coloring, const Library::Item* heldItem,
|
||||||
std::string nickname, int8_t talent, std::vector<LearnedAttack*> attacks)
|
std::string nickname, int8_t talent, std::vector<LearnedAttack*> attacks)
|
||||||
: _library(library), __Species(species), __Variant(variant), __Level(level), __Experience(experience),
|
: _library(library), _species(species), _variant(variant), _level(level), _experience(experience),
|
||||||
__UniqueIdentifier(uid), __Gender(gender), __Coloring(coloring), __HeldItem(heldItem),
|
_uniqueIdentifier(uid), _gender(gender), _coloring(coloring), _heldItem(heldItem), _nickname(std::move(nickname)),
|
||||||
_nickname(std::move(nickname)), _talentIndex(talent), _hasOverridenTalent(false), _attacks(std::move(attacks)) {
|
_talentIndex(talent), _hasOverridenTalent(false), _attacks(std::move(attacks)) {
|
||||||
_activeTalent = _library->LoadScript(ScriptResolver::ScriptCategory::Talent, GetActiveTalent());
|
_activeTalent = _library->LoadScript(ScriptResolver::ScriptCategory::Talent, GetActiveTalent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battling::Creature::ChangeLevel(int8_t amount) {
|
void Battling::Creature::ChangeLevel(int8_t amount) {
|
||||||
this->__Level += amount;
|
this->_level += amount;
|
||||||
RecalculateFlatStats();
|
RecalculateFlatStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& Battling::Creature::GetNickname() const {
|
const std::string& Battling::Creature::GetNickname() const {
|
||||||
if (_nickname.empty())
|
if (_nickname.empty())
|
||||||
return __Species->GetName();
|
return _species->GetName();
|
||||||
return _nickname;
|
return _nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ const std::string& Battling::Creature::GetActiveTalent() const {
|
||||||
if (_hasOverridenTalent) {
|
if (_hasOverridenTalent) {
|
||||||
return _overridenTalentName;
|
return _overridenTalentName;
|
||||||
}
|
}
|
||||||
return __Variant->GetTalent(_talentIndex);
|
return _variant->GetTalent(_talentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battling::Creature::SetBattleData(Battling::Battle* battle, Battling::BattleSide* side) {
|
void Battling::Creature::SetBattleData(Battling::Battle* battle, Battling::BattleSide* side) {
|
||||||
|
@ -53,7 +53,7 @@ uint32_t Battling::Creature::GetFlatStat(Core::Statistic stat) const { return _f
|
||||||
|
|
||||||
uint32_t Battling::Creature::GetBoostedStat(Core::Statistic stat) const { return _boostedStats.GetStat(stat); }
|
uint32_t Battling::Creature::GetBoostedStat(Core::Statistic stat) const { return _boostedStats.GetStat(stat); }
|
||||||
|
|
||||||
uint32_t Battling::Creature::GetBaseStat(Core::Statistic stat) const { return __Variant->GetStatistic(stat); }
|
uint32_t Battling::Creature::GetBaseStat(Core::Statistic stat) const { return _variant->GetStatistic(stat); }
|
||||||
|
|
||||||
int8_t Battling::Creature::GetStatBoost(Core::Statistic stat) const { return _statBoost.GetStat(stat); }
|
int8_t Battling::Creature::GetStatBoost(Core::Statistic stat) const { return _statBoost.GetStat(stat); }
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ Battling::Battle* Battling::Creature::GetBattle() const { return _battle; }
|
||||||
|
|
||||||
Battling::BattleSide* Battling::Creature::GetBattleSide() const { return _side; }
|
Battling::BattleSide* Battling::Creature::GetBattleSide() const { return _side; }
|
||||||
|
|
||||||
bool Battling::Creature::IsFainted() const { return this->__CurrentHealth <= 0; }
|
bool Battling::Creature::IsFainted() const { return this->_currentHealth <= 0; }
|
||||||
|
|
||||||
void Battling::Creature::OnFaint() {
|
void Battling::Creature::OnFaint() {
|
||||||
// HOOK: On Faint
|
// HOOK: On Faint
|
||||||
|
@ -96,13 +96,13 @@ void Battling::Creature::OnFaint() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battling::Creature::Damage(uint32_t damage, Battling::DamageSource source) {
|
void Battling::Creature::Damage(uint32_t damage, Battling::DamageSource source) {
|
||||||
if (damage > __CurrentHealth) {
|
if (damage > _currentHealth) {
|
||||||
damage = __CurrentHealth;
|
damage = _currentHealth;
|
||||||
}
|
}
|
||||||
// HOOK: On Damage
|
// HOOK: On Damage
|
||||||
auto newHealth = __CurrentHealth - damage;
|
auto newHealth = _currentHealth - damage;
|
||||||
this->GetBattle()->TriggerEventListener(new DamageEvent(this, source, __CurrentHealth, newHealth));
|
this->GetBattle()->TriggerEventListener(new DamageEvent(this, source, _currentHealth, newHealth));
|
||||||
__CurrentHealth = newHealth;
|
_currentHealth = newHealth;
|
||||||
|
|
||||||
if (IsFainted() && damage > 0) {
|
if (IsFainted() && damage > 0) {
|
||||||
OnFaint();
|
OnFaint();
|
||||||
|
@ -117,7 +117,7 @@ void Battling::Creature::OverrideActiveTalent(const std::string& talent) {
|
||||||
|
|
||||||
const std::vector<uint8_t>& Battling::Creature::GetTypes() const {
|
const std::vector<uint8_t>& Battling::Creature::GetTypes() const {
|
||||||
// HOOK: override types.
|
// HOOK: override types.
|
||||||
return this->__Variant->GetTypes();
|
return this->_variant->GetTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Battling::Creature::HasType(uint8_t type) const {
|
bool Battling::Creature::HasType(uint8_t type) const {
|
||||||
|
@ -134,24 +134,24 @@ void Battling::Creature::GetActiveScripts(std::vector<ScriptWrapper>& scripts) {
|
||||||
void Battling::Creature::ClearVolatileScripts() { _volatile.Clear(); }
|
void Battling::Creature::ClearVolatileScripts() { _volatile.Clear(); }
|
||||||
void Battling::Creature::AddExperience(uint32_t amount) {
|
void Battling::Creature::AddExperience(uint32_t amount) {
|
||||||
auto maxLevel = _library->GetSettings().GetMaximalLevel();
|
auto maxLevel = _library->GetSettings().GetMaximalLevel();
|
||||||
if (__Level >= maxLevel) {
|
if (_level >= maxLevel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto exp = __Experience + amount;
|
auto exp = _experience + amount;
|
||||||
auto level = _library->GetGrowthRateLibrary()->CalculateLevel(this->GetSpecies()->GetGrowthRate(), exp);
|
auto level = _library->GetGrowthRateLibrary()->CalculateLevel(this->GetSpecies()->GetGrowthRate(), exp);
|
||||||
if (level >= maxLevel) {
|
if (level >= maxLevel) {
|
||||||
exp = _library->GetGrowthRateLibrary()->CalculateExperience(this->GetSpecies()->GetGrowthRate(), maxLevel);
|
exp = _library->GetGrowthRateLibrary()->CalculateExperience(this->GetSpecies()->GetGrowthRate(), maxLevel);
|
||||||
}
|
}
|
||||||
__Experience = exp;
|
_experience = exp;
|
||||||
__Level = level;
|
_level = level;
|
||||||
}
|
}
|
||||||
const Library::CreatureSpecies* Battling::Creature::GetDisplaySpecies() {
|
const Library::CreatureSpecies* Battling::Creature::GetDisplaySpecies() {
|
||||||
auto species = __Species;
|
auto species = _species;
|
||||||
HOOK(OverrideDisplaySpecies, this, this, &species);
|
HOOK(OverrideDisplaySpecies, this, this, &species);
|
||||||
return species;
|
return species;
|
||||||
}
|
}
|
||||||
const Library::SpeciesVariant* Battling::Creature::GetDisplayVariant() {
|
const Library::SpeciesVariant* Battling::Creature::GetDisplayVariant() {
|
||||||
auto variant = __Variant;
|
auto variant = _variant;
|
||||||
HOOK(OverrideDisplayVariant, this, this, &variant);
|
HOOK(OverrideDisplayVariant, this, this, &variant);
|
||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef CREATURELIB_BATTLECREATURE_HPP
|
#ifndef CREATURELIB_BATTLECREATURE_HPP
|
||||||
#define CREATURELIB_BATTLECREATURE_HPP
|
#define CREATURELIB_BATTLECREATURE_HPP
|
||||||
|
|
||||||
#include "../../GenericTemplates.hpp"
|
|
||||||
#include "../../Library/CreatureData/CreatureSpecies.hpp"
|
#include "../../Library/CreatureData/CreatureSpecies.hpp"
|
||||||
#include "../../Library/Items/Item.hpp"
|
#include "../../Library/Items/Item.hpp"
|
||||||
#include "../ScriptHandling/ScriptAggregator.hpp"
|
#include "../ScriptHandling/ScriptAggregator.hpp"
|
||||||
|
@ -20,18 +19,17 @@ namespace CreatureLib::Battling {
|
||||||
protected:
|
protected:
|
||||||
const BattleLibrary* _library;
|
const BattleLibrary* _library;
|
||||||
|
|
||||||
GetProperty(const Library::CreatureSpecies*, Species);
|
const Library::CreatureSpecies* _species;
|
||||||
GetProperty(const Library::SpeciesVariant*, Variant);
|
const Library::SpeciesVariant* _variant;
|
||||||
|
|
||||||
GetProperty(uint8_t, Level);
|
uint8_t _level;
|
||||||
GetProperty(uint32_t, Experience);
|
uint32_t _experience;
|
||||||
GetProperty(uint32_t, UniqueIdentifier);
|
uint32_t _uniqueIdentifier;
|
||||||
GetProperty(Library::Gender, Gender);
|
Library::Gender _gender;
|
||||||
GetProperty(uint8_t, Coloring);
|
uint8_t _coloring;
|
||||||
GetProperty(const Library::Item*, HeldItem);
|
const Library::Item* _heldItem;
|
||||||
GetProperty(uint32_t, CurrentHealth);
|
uint32_t _currentHealth;
|
||||||
|
|
||||||
protected:
|
|
||||||
Core::StatisticSet<int8_t> _statBoost;
|
Core::StatisticSet<int8_t> _statBoost;
|
||||||
Core::StatisticSet<uint32_t> _flatStats;
|
Core::StatisticSet<uint32_t> _flatStats;
|
||||||
Core::StatisticSet<uint32_t> _boostedStats;
|
Core::StatisticSet<uint32_t> _boostedStats;
|
||||||
|
@ -70,9 +68,18 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
virtual void Initialize() {
|
virtual void Initialize() {
|
||||||
RecalculateFlatStats();
|
RecalculateFlatStats();
|
||||||
__CurrentHealth = GetBoostedStat(Core::Statistic::Health);
|
_currentHealth = GetBoostedStat(Core::Statistic::Health);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const Library::CreatureSpecies* GetSpecies() const { return _species; }
|
||||||
|
inline const Library::SpeciesVariant* GetVariant() const { return _variant; }
|
||||||
|
inline uint8_t GetLevel() const { return _level; }
|
||||||
|
inline uint32_t GetExperience() const { return _experience; }
|
||||||
|
inline Library::Gender GetGender() const { return _gender; }
|
||||||
|
inline uint8_t GetColoring() const { return _coloring; }
|
||||||
|
inline const Library::Item* GetHeldItem() const { return _heldItem; }
|
||||||
|
inline uint32_t GetCurrentHealth() const { return _currentHealth; }
|
||||||
|
|
||||||
void SetBattleData(Battle* battle, BattleSide* side);
|
void SetBattleData(Battle* battle, BattleSide* side);
|
||||||
Battle* GetBattle() const;
|
Battle* GetBattle() const;
|
||||||
BattleSide* GetBattleSide() const;
|
BattleSide* GetBattleSide() const;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define CREATURELIB_STATISTICSET_HPP
|
#define CREATURELIB_STATISTICSET_HPP
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "../GenericTemplates.hpp"
|
|
||||||
#include "Exceptions/NotReachableException.hpp"
|
#include "Exceptions/NotReachableException.hpp"
|
||||||
#include "Statistic.hpp"
|
#include "Statistic.hpp"
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
/*!
|
|
||||||
\brief GetProperty creates a simple wrapper for a field, creating a private field, and a public getter method.
|
|
||||||
*/
|
|
||||||
#define GetProperty(type, name) \
|
|
||||||
protected: \
|
|
||||||
type __##name; \
|
|
||||||
\
|
|
||||||
public: \
|
|
||||||
[[nodiscard]] inline type Get##name() const { return __##name; };
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief GetProperty creates a simple wrapper for a field, creating a private field, a public getter method, and a public
|
|
||||||
setter method.
|
|
||||||
*/
|
|
||||||
#define GetSetProperty(type, name) \
|
|
||||||
private: \
|
|
||||||
type __##name; \
|
|
||||||
\
|
|
||||||
public: \
|
|
||||||
[[nodiscard]] inline type Get##name() const { return __##name; }; \
|
|
||||||
\
|
|
||||||
public: \
|
|
||||||
inline void Set##name(type value) { __##name = value; };
|
|
|
@ -6,8 +6,8 @@ CreatureLib::Library::AttackData::AttackData(std::string name, std::string type,
|
||||||
uint8_t accuracy, uint8_t baseUsage,
|
uint8_t accuracy, uint8_t baseUsage,
|
||||||
CreatureLib::Library::AttackTarget target, uint8_t priority,
|
CreatureLib::Library::AttackTarget target, uint8_t priority,
|
||||||
std::unordered_set<std::string> flags)
|
std::unordered_set<std::string> flags)
|
||||||
: __Name(std::move(name)), __Type(std::move(type)), __Category(category), __BasePower(power), __Accuracy(accuracy),
|
: _name(std::move(name)), _type(std::move(type)), _category(category), _basePower(power), _accuracy(accuracy),
|
||||||
__BaseUsages(baseUsage), __Target(target), __Priority(priority), _flags(std::move(flags)) {}
|
_baseUsages(baseUsage), _target(target), _priority(priority), _flags(std::move(flags)) {}
|
||||||
|
|
||||||
bool CreatureLib::Library::AttackData::HasFlag(const std::string& key) const {
|
bool CreatureLib::Library::AttackData::HasFlag(const std::string& key) const {
|
||||||
return this->_flags.find(key) != this->_flags.end();
|
return this->_flags.find(key) != this->_flags.end();
|
||||||
|
|
|
@ -3,28 +3,35 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include "../../GenericTemplates.hpp"
|
|
||||||
#include "AttackCategory.hpp"
|
#include "AttackCategory.hpp"
|
||||||
#include "AttackTarget.hpp"
|
#include "AttackTarget.hpp"
|
||||||
|
|
||||||
namespace CreatureLib::Library {
|
namespace CreatureLib::Library {
|
||||||
class AttackData {
|
class AttackData {
|
||||||
GetProperty(std::string, Name);
|
protected:
|
||||||
GetProperty(std::string, Type);
|
const std::string _name;
|
||||||
GetProperty(AttackCategory, Category);
|
const std::string _type;
|
||||||
GetProperty(uint8_t, BasePower);
|
AttackCategory _category;
|
||||||
GetProperty(uint8_t, Accuracy);
|
uint8_t _basePower;
|
||||||
GetProperty(uint8_t, BaseUsages);
|
uint8_t _accuracy;
|
||||||
GetProperty(AttackTarget, Target);
|
uint8_t _baseUsages;
|
||||||
GetProperty(uint8_t, Priority);
|
AttackTarget _target;
|
||||||
|
int8_t _priority;
|
||||||
private:
|
|
||||||
std::unordered_set<std::string> _flags;
|
std::unordered_set<std::string> _flags;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AttackData(std::string name, std::string type, AttackCategory category, uint8_t power, uint8_t accuracy,
|
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);
|
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;
|
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,
|
CreatureSpecies::CreatureSpecies(uint16_t id, std::string name, const SpeciesVariant* defaultVariant, float genderRatio,
|
||||||
std::string growthRate, uint8_t captureRate)
|
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)) {}
|
_variants({{"default", defaultVariant}}), _name(std::move(name)) {}
|
||||||
|
|
||||||
const SpeciesVariant* CreatureSpecies::GetVariant(const std::string& key) const { return _variants.at(key); }
|
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 {
|
Gender CreatureSpecies::GetRandomGender(CreatureLib::Core::Random& rand) const {
|
||||||
// TODO: Genderless creatures
|
// TODO: Genderless creatures
|
||||||
auto val = rand.GetDouble();
|
auto val = rand.GetDouble();
|
||||||
if (val >= this->__GenderRate)
|
if (val >= this->_genderRate)
|
||||||
return Gender ::Female;
|
return Gender ::Female;
|
||||||
return Gender ::Male;
|
return Gender ::Male;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,10 @@ namespace CreatureLib::Library {
|
||||||
creatures with.
|
creatures with.
|
||||||
*/
|
*/
|
||||||
class CreatureSpecies {
|
class CreatureSpecies {
|
||||||
GetProperty(uint16_t, Id);
|
uint16_t _id;
|
||||||
GetProperty(float, GenderRate);
|
float _genderRate;
|
||||||
GetProperty(std::string, GrowthRate);
|
std::string _growthRate;
|
||||||
GetProperty(uint8_t, CaptureRate);
|
uint8_t _captureRate;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<std::string, const SpeciesVariant*> _variants;
|
std::unordered_map<std::string, const SpeciesVariant*> _variants;
|
||||||
|
@ -31,6 +31,11 @@ namespace CreatureLib::Library {
|
||||||
_variants.clear();
|
_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]] const SpeciesVariant* GetVariant(const std::string& key) const;
|
||||||
[[nodiscard]] Gender GetRandomGender(Core::Random& rand) const;
|
[[nodiscard]] Gender GetRandomGender(Core::Random& rand) const;
|
||||||
[[nodiscard]] const std::string& GetName() 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> talents,
|
||||||
std::vector<std::string> secretTalents,
|
std::vector<std::string> secretTalents,
|
||||||
const LearnableAttacks* attacks)
|
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)),
|
_types(std::move(types)), _baseStatistics(baseStats), _talents(std::move(talents)),
|
||||||
_secretTalents(std::move(secretTalents)), _attacks(attacks) {}
|
_secretTalents(std::move(secretTalents)), _attacks(attacks) {}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "../../Core/Random.hpp"
|
#include "../../Core/Random.hpp"
|
||||||
#include "../../Core/StatisticSet.hpp"
|
#include "../../Core/StatisticSet.hpp"
|
||||||
#include "../../GenericTemplates.hpp"
|
|
||||||
#include "CreatureMoves.hpp"
|
#include "CreatureMoves.hpp"
|
||||||
#include "LearnableAttacks.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.
|
\brief A single species can have more than one variant. This class holds the data for those variants.
|
||||||
*/
|
*/
|
||||||
class SpeciesVariant {
|
class SpeciesVariant {
|
||||||
GetProperty(std::string, Name);
|
protected:
|
||||||
GetProperty(float, Height);
|
std::string _name;
|
||||||
GetProperty(float, Weight);
|
float _height;
|
||||||
GetProperty(uint32_t, BaseExperience);
|
float _weight;
|
||||||
|
uint32_t _baseExperience;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<uint8_t> _types;
|
std::vector<uint8_t> _types;
|
||||||
|
@ -34,6 +34,11 @@ namespace CreatureLib::Library {
|
||||||
|
|
||||||
~SpeciesVariant();
|
~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]] size_t GetTypeCount() const;
|
||||||
[[nodiscard]] uint8_t GetType(size_t index) const;
|
[[nodiscard]] uint8_t GetType(size_t index) const;
|
||||||
[[nodiscard]] const std::vector<uint8_t>& GetTypes() const;
|
[[nodiscard]] const std::vector<uint8_t>& GetTypes() const;
|
||||||
|
|
|
@ -3,3 +3,7 @@
|
||||||
bool CreatureLib::Library::Item::HasFlag(const std::string& flag) const {
|
bool CreatureLib::Library::Item::HasFlag(const std::string& flag) const {
|
||||||
return this->_flags.find(flag) != this->_flags.end();
|
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 <string>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include "../../GenericTemplates.hpp"
|
|
||||||
#include "BattleItemCategory.hpp"
|
#include "BattleItemCategory.hpp"
|
||||||
#include "ItemCategory.hpp"
|
#include "ItemCategory.hpp"
|
||||||
|
|
||||||
namespace CreatureLib::Library {
|
namespace CreatureLib::Library {
|
||||||
class Item {
|
class Item {
|
||||||
GetProperty(std::string, Name);
|
protected:
|
||||||
GetProperty(ItemCategory, Category);
|
std::string _name;
|
||||||
GetProperty(BattleItemCategory, BattleCategory);
|
ItemCategory _category;
|
||||||
GetProperty(int32_t, Price);
|
BattleItemCategory _battleCategory;
|
||||||
|
int32_t _price;
|
||||||
private:
|
|
||||||
std::unordered_set<std::string> _flags;
|
std::unordered_set<std::string> _flags;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Item(std::string name, ItemCategory category, BattleItemCategory battleCategory, int32_t price,
|
Item(std::string name, ItemCategory category, BattleItemCategory battleCategory, int32_t price,
|
||||||
std::unordered_set<std::string> flags);
|
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;
|
bool HasFlag(const std::string& flag) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue