Support for learnable moves
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,6 +1,5 @@
|
||||
#include "CreatureSpecies.hpp"
|
||||
|
||||
#include <utility>
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
CreatureSpecies::CreatureSpecies(uint16_t id, std::string name, const SpeciesVariant* defaultVariant,
|
||||
|
||||
11
src/Library/CreatureData/LearnableAttacks.cpp
Normal file
11
src/Library/CreatureData/LearnableAttacks.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "LearnableAttacks.hpp"
|
||||
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
void LearnableAttacks::AddLevelMove(uint8_t level, AttackData *attack) {
|
||||
_learnedByLevel[level].push_back(attack);
|
||||
}
|
||||
|
||||
const std::vector<const AttackData *> &LearnableAttacks::GetMovesForLevel(uint8_t level) const {
|
||||
return _learnedByLevel[level];
|
||||
}
|
||||
21
src/Library/CreatureData/LearnableAttacks.hpp
Normal file
21
src/Library/CreatureData/LearnableAttacks.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef CREATURELIB_LEARNABLEATTACKS_HPP
|
||||
#define CREATURELIB_LEARNABLEATTACKS_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "../Attacks/AttackData.hpp"
|
||||
|
||||
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)){}
|
||||
|
||||
void AddLevelMove(uint8_t level, AttackData* attack);
|
||||
|
||||
const std::vector<const AttackData*>& GetMovesForLevel(uint8_t level) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //CREATURELIB_LEARNABLEATTACKS_HPP
|
||||
@@ -42,11 +42,15 @@ int8_t CreatureLib::Library::SpeciesVariant::GetRandomTalent(CreatureLib::Core::
|
||||
return rand->Get(_talents.size());
|
||||
}
|
||||
|
||||
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<std::string> types,
|
||||
CreatureLib::Core::StatisticSet<uint16_t > baseStats,
|
||||
std::vector<std::string> talents,
|
||||
std::vector<std::string> secretTalents)
|
||||
std::vector<std::string> secretTalents, const LearnableAttacks* attacks)
|
||||
: __Name(name),
|
||||
__Height(height),
|
||||
__Weight(weight),
|
||||
@@ -54,5 +58,10 @@ CreatureLib::Library::SpeciesVariant::SpeciesVariant(std::string name, float hei
|
||||
_types(types),
|
||||
_baseStatistics(baseStats),
|
||||
_talents(talents),
|
||||
_secretTalents(secretTalents)
|
||||
_secretTalents(secretTalents),
|
||||
_attacks(attacks)
|
||||
{}
|
||||
|
||||
CreatureLib::Library::SpeciesVariant::~SpeciesVariant() {
|
||||
delete _attacks;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "../../Core/StatisticSet.hpp"
|
||||
#include "../../GenericTemplates.cpp"
|
||||
#include "../../Core/Random.hpp"
|
||||
#include "LearnableAttacks.hpp"
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
/*!
|
||||
@@ -22,17 +23,19 @@ namespace CreatureLib::Library {
|
||||
const Core::StatisticSet<uint16_t > _baseStatistics;
|
||||
std::vector<std::string> _talents;
|
||||
std::vector<std::string> _secretTalents;
|
||||
//CreatureMoves _moves;
|
||||
const LearnableAttacks* _attacks;
|
||||
public:
|
||||
SpeciesVariant(std::string name, float height, float weight, uint32_t baseExperience,
|
||||
std::vector<std::string> types, Core::StatisticSet<uint16_t > baseStats, std::vector<std::string> talents,
|
||||
std::vector<std::string> secretTalents);
|
||||
std::vector<std::string> secretTalents, const LearnableAttacks* attacks);
|
||||
|
||||
~SpeciesVariant();
|
||||
|
||||
[[nodiscard]] size_t GetTypeCount() const;
|
||||
[[nodiscard]] std::string GetType(size_t index) const;
|
||||
[[nodiscard]] uint32_t GetStatistic(Core::Statistic stat) const;
|
||||
[[nodiscard]] std::string GetTalent(int32_t index) const;
|
||||
//[[nodiscard]] const CreatureMoves* GetCreatureMoves() const;
|
||||
[[nodiscard]] const LearnableAttacks* GetLearnableAttacks() const;
|
||||
[[nodiscard]] int8_t GetTalentIndex(std::string talent) const;
|
||||
[[nodiscard]] int8_t GetRandomTalent(Core::Random* rand) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user