Used ClangFormat style guide I'm happy with.
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,16 +1,8 @@
|
||||
#include "CreatureMoves.hpp"
|
||||
#include <utility>
|
||||
|
||||
CreatureLib::Library::LevelMove::LevelMove(uint8_t level, std::string name)
|
||||
:_level(level),
|
||||
_name(std::move(name))
|
||||
{}
|
||||
CreatureLib::Library::LevelMove::LevelMove(uint8_t level, std::string name) : _level(level), _name(std::move(name)) {}
|
||||
|
||||
uint8_t CreatureLib::Library::LevelMove::GetLevel() const {
|
||||
return this->_level;
|
||||
}
|
||||
|
||||
std::string CreatureLib::Library::LevelMove::GetName() const {
|
||||
return this->_name;
|
||||
}
|
||||
uint8_t CreatureLib::Library::LevelMove::GetLevel() const { return this->_level; }
|
||||
|
||||
std::string CreatureLib::Library::LevelMove::GetName() const { return this->_name; }
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace CreatureLib::Library{
|
||||
class LevelMove{
|
||||
namespace CreatureLib::Library {
|
||||
class LevelMove {
|
||||
private:
|
||||
uint8_t _level;
|
||||
std::string _name;
|
||||
|
||||
public:
|
||||
LevelMove(uint8_t level, std::string name);
|
||||
[[nodiscard]] inline uint8_t GetLevel() const;
|
||||
@@ -23,10 +24,10 @@ namespace CreatureLib::Library{
|
||||
std::vector<std::string> _machineMoves;
|
||||
std::vector<std::string> _tutorMoves;
|
||||
std::vector<std::string> _variantDependentMoves;
|
||||
|
||||
public:
|
||||
//TODO: Public API funcs
|
||||
// TODO: Public API funcs
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //CREATURELIB_CREATUREMOVES_HPP
|
||||
#endif // CREATURELIB_CREATUREMOVES_HPP
|
||||
|
||||
@@ -2,30 +2,19 @@
|
||||
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
CreatureSpecies::CreatureSpecies(uint16_t id, std::string name, const SpeciesVariant* defaultVariant,
|
||||
float genderRatio, std::string growthRate, uint8_t captureRate, uint8_t baseHappiness)
|
||||
:
|
||||
__Id(id),
|
||||
__GenderRate(genderRatio),
|
||||
__GrowthRate(std::move(growthRate)),
|
||||
__CaptureRate(captureRate),
|
||||
__BaseHappiness(baseHappiness),
|
||||
_variants({{"default", defaultVariant}}),
|
||||
_name(std::move(name))
|
||||
{}
|
||||
CreatureSpecies::CreatureSpecies(uint16_t id, std::string name, const SpeciesVariant* defaultVariant, float genderRatio,
|
||||
std::string growthRate, uint8_t captureRate, uint8_t baseHappiness)
|
||||
: __Id(id), __GenderRate(genderRatio), __GrowthRate(std::move(growthRate)), __CaptureRate(captureRate),
|
||||
__BaseHappiness(baseHappiness), _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); }
|
||||
|
||||
Gender CreatureSpecies::GetRandomGender(CreatureLib::Core::Random &rand) const {
|
||||
Gender CreatureSpecies::GetRandomGender(CreatureLib::Core::Random& rand) const {
|
||||
// TODO: Genderless creatures
|
||||
auto val = rand.GetDouble();
|
||||
if (val >= this->__GenderRate) return Gender ::Female;
|
||||
if (val >= this->__GenderRate)
|
||||
return Gender ::Female;
|
||||
return Gender ::Male;
|
||||
}
|
||||
|
||||
const std::string &CreatureSpecies::GetName() const {
|
||||
return _name;
|
||||
}
|
||||
|
||||
const std::string& CreatureSpecies::GetName() const { return _name; }
|
||||
|
||||
@@ -3,28 +3,31 @@
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "SpeciesVariant.hpp"
|
||||
#include "../Gender.hpp"
|
||||
#include "SpeciesVariant.hpp"
|
||||
|
||||
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.
|
||||
*/
|
||||
/*!
|
||||
\brief This holds the data required for a species of a creature, so the general data we can describe different
|
||||
creatures with.
|
||||
*/
|
||||
class CreatureSpecies {
|
||||
GetProperty(uint16_t, Id);
|
||||
GetProperty(float, GenderRate);
|
||||
GetProperty(std::string, GrowthRate);
|
||||
GetProperty(uint8_t, CaptureRate);
|
||||
GetProperty(uint8_t, BaseHappiness);
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, const SpeciesVariant*> _variants;
|
||||
std::string _name;
|
||||
public:
|
||||
CreatureSpecies(uint16_t id, std::string name, const SpeciesVariant* defaultVariant,
|
||||
float genderRatio, std::string growthRate, uint8_t captureRate, uint8_t baseHappiness);
|
||||
|
||||
~CreatureSpecies(){
|
||||
for (auto v: _variants)
|
||||
public:
|
||||
CreatureSpecies(uint16_t id, std::string name, const SpeciesVariant* defaultVariant, float genderRatio,
|
||||
std::string growthRate, uint8_t captureRate, uint8_t baseHappiness);
|
||||
|
||||
~CreatureSpecies() {
|
||||
for (auto v : _variants)
|
||||
delete v.second;
|
||||
_variants.clear();
|
||||
}
|
||||
@@ -35,4 +38,4 @@ namespace CreatureLib::Library {
|
||||
};
|
||||
}
|
||||
|
||||
#endif //CREATURELIB_CREATURESPECIES_HPP
|
||||
#endif // CREATURELIB_CREATURESPECIES_HPP
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
void LearnableAttacks::AddLevelMove(uint8_t level, AttackData *attack) {
|
||||
_learnedByLevel[level].push_back(attack);
|
||||
}
|
||||
void LearnableAttacks::AddLevelMove(uint8_t level, AttackData* attack) { _learnedByLevel[level].push_back(attack); }
|
||||
|
||||
const std::vector<const AttackData *> &LearnableAttacks::GetMovesForLevel(uint8_t level) const {
|
||||
const std::vector<const AttackData*>& LearnableAttacks::GetMovesForLevel(uint8_t level) const {
|
||||
return _learnedByLevel[level];
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
namespace CreatureLib::Library {
|
||||
class LearnableAttacks {
|
||||
std::vector<std::vector<const AttackData*>> _learnedByLevel;
|
||||
|
||||
public:
|
||||
LearnableAttacks(uint8_t maxLevel)
|
||||
:_learnedByLevel(std::vector<std::vector<const AttackData*>>(maxLevel)){}
|
||||
LearnableAttacks(uint8_t maxLevel) : _learnedByLevel(std::vector<std::vector<const AttackData*>>(maxLevel)) {}
|
||||
|
||||
void AddLevelMove(uint8_t level, AttackData* attack);
|
||||
|
||||
@@ -17,5 +17,4 @@ namespace CreatureLib::Library {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //CREATURELIB_LEARNABLEATTACKS_HPP
|
||||
#endif // CREATURELIB_LEARNABLEATTACKS_HPP
|
||||
|
||||
@@ -2,24 +2,18 @@
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
const std::vector<uint8_t>& CreatureLib::Library::SpeciesVariant::GetTypes() const {
|
||||
return _types;
|
||||
}
|
||||
const std::vector<uint8_t>& CreatureLib::Library::SpeciesVariant::GetTypes() const { return _types; }
|
||||
|
||||
size_t CreatureLib::Library::SpeciesVariant::GetTypeCount() const {
|
||||
return _types.size();
|
||||
}
|
||||
size_t CreatureLib::Library::SpeciesVariant::GetTypeCount() const { return _types.size(); }
|
||||
|
||||
uint8_t CreatureLib::Library::SpeciesVariant::GetType(size_t index) const {
|
||||
return _types[index];
|
||||
}
|
||||
uint8_t CreatureLib::Library::SpeciesVariant::GetType(size_t index) const { return _types[index]; }
|
||||
|
||||
uint32_t CreatureLib::Library::SpeciesVariant::GetStatistic(CreatureLib::Core::Statistic stat) const {
|
||||
return _baseStatistics.GetStat(stat);
|
||||
}
|
||||
|
||||
const std::string& CreatureLib::Library::SpeciesVariant::GetTalent(int32_t index) const {
|
||||
if (index < 0){
|
||||
if (index < 0) {
|
||||
index = -index - 1;
|
||||
return _secretTalents[index];
|
||||
}
|
||||
@@ -30,42 +24,34 @@ const std::string& CreatureLib::Library::SpeciesVariant::GetTalent(int32_t index
|
||||
return &_moves;
|
||||
}*/
|
||||
|
||||
int8_t CreatureLib::Library::SpeciesVariant::GetTalentIndex(const std::string& talent) const{
|
||||
int8_t CreatureLib::Library::SpeciesVariant::GetTalentIndex(const std::string& talent) const {
|
||||
auto i = std::find(_talents.begin(), _talents.end(), talent);
|
||||
if (i != _talents.end()){
|
||||
if (i != _talents.end()) {
|
||||
return std::distance(_talents.begin(), i);
|
||||
}
|
||||
i = std::find(_secretTalents.begin(), _secretTalents.end(), talent);
|
||||
if (i != _secretTalents.end()){
|
||||
if (i != _secretTalents.end()) {
|
||||
return std::distance(_secretTalents.begin(), i);
|
||||
}
|
||||
throw CreatureException("The given talent is not a valid talent for this creature.");
|
||||
}
|
||||
|
||||
int8_t CreatureLib::Library::SpeciesVariant::GetRandomTalent(CreatureLib::Core::Random *rand) const {
|
||||
int8_t CreatureLib::Library::SpeciesVariant::GetRandomTalent(CreatureLib::Core::Random* rand) const {
|
||||
return rand->Get(_talents.size());
|
||||
}
|
||||
|
||||
const CreatureLib::Library::LearnableAttacks *CreatureLib::Library::SpeciesVariant::GetLearnableAttacks() const {
|
||||
const CreatureLib::Library::LearnableAttacks* CreatureLib::Library::SpeciesVariant::GetLearnableAttacks() const {
|
||||
return _attacks;
|
||||
}
|
||||
|
||||
CreatureLib::Library::SpeciesVariant::SpeciesVariant(std::string name, float height, float weight,
|
||||
uint32_t baseExperience, std::vector<uint8_t> types,
|
||||
CreatureLib::Core::StatisticSet<uint16_t > baseStats,
|
||||
CreatureLib::Core::StatisticSet<uint16_t> baseStats,
|
||||
std::vector<std::string> talents,
|
||||
std::vector<std::string> secretTalents, const LearnableAttacks* attacks)
|
||||
: __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)
|
||||
{}
|
||||
std::vector<std::string> secretTalents,
|
||||
const LearnableAttacks* attacks)
|
||||
: __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) {}
|
||||
|
||||
CreatureLib::Library::SpeciesVariant::~SpeciesVariant() {
|
||||
delete _attacks;
|
||||
}
|
||||
CreatureLib::Library::SpeciesVariant::~SpeciesVariant() { delete _attacks; }
|
||||
@@ -3,37 +3,40 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "CreatureMoves.hpp"
|
||||
#include "../../Core/Random.hpp"
|
||||
#include "../../Core/StatisticSet.hpp"
|
||||
#include "../../GenericTemplates.cpp"
|
||||
#include "../../Core/Random.hpp"
|
||||
#include "CreatureMoves.hpp"
|
||||
#include "LearnableAttacks.hpp"
|
||||
|
||||
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 {
|
||||
GetProperty(std::string, Name);
|
||||
GetProperty(float, Height);
|
||||
GetProperty(float, Weight);
|
||||
GetProperty(uint32_t, BaseExperience);
|
||||
|
||||
private:
|
||||
std::vector<uint8_t > _types;
|
||||
const Core::StatisticSet<uint16_t > _baseStatistics;
|
||||
std::vector<uint8_t> _types;
|
||||
const Core::StatisticSet<uint16_t> _baseStatistics;
|
||||
std::vector<std::string> _talents;
|
||||
std::vector<std::string> _secretTalents;
|
||||
const LearnableAttacks* _attacks;
|
||||
|
||||
public:
|
||||
SpeciesVariant(std::string name, float height, float weight, uint32_t baseExperience,
|
||||
std::vector<uint8_t> types, Core::StatisticSet<uint16_t > baseStats, std::vector<std::string> talents,
|
||||
std::vector<std::string> secretTalents, const LearnableAttacks* attacks);
|
||||
std::vector<uint8_t> types, Core::StatisticSet<uint16_t> baseStats,
|
||||
std::vector<std::string> talents, std::vector<std::string> secretTalents,
|
||||
const LearnableAttacks* attacks);
|
||||
|
||||
~SpeciesVariant();
|
||||
|
||||
[[nodiscard]] size_t GetTypeCount() 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;
|
||||
[[nodiscard]] uint32_t GetStatistic(Core::Statistic stat) const;
|
||||
[[nodiscard]] const std::string& GetTalent(int32_t index) const;
|
||||
[[nodiscard]] const LearnableAttacks* GetLearnableAttacks() const;
|
||||
@@ -42,4 +45,4 @@ namespace CreatureLib::Library {
|
||||
};
|
||||
}
|
||||
|
||||
#endif //CREATURELIB_SPECIESVARIANT_HPP
|
||||
#endif // CREATURELIB_SPECIESVARIANT_HPP
|
||||
|
||||
Reference in New Issue
Block a user