Implements outlines for ItemLibrary, MoveLibrary and implements NatureLibrary.
This commit is contained in:
parent
9a45d34f9f
commit
bb1791b3ae
|
@ -12,7 +12,7 @@ class PkmnLibConan(ConanFile):
|
||||||
generators = "cmake"
|
generators = "cmake"
|
||||||
exports_sources = "*"
|
exports_sources = "*"
|
||||||
compiler = "clang"
|
compiler = "clang"
|
||||||
requires = "CreatureLib/d26670082260d3eaab2126dc02c5e2fe674e0076@creaturelib/master"
|
requires = "CreatureLib/db2eb0c3fa5d67b14c84b118cd2f69bbd209ddb9@creaturelib/master"
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
cmake = CMake(self)
|
cmake = CMake(self)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
#include "Item.hpp"
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef PKMNLIB_ITEM_HPP
|
||||||
|
#define PKMNLIB_ITEM_HPP
|
||||||
|
|
||||||
|
#include <Library/Items/Item.hpp>
|
||||||
|
namespace PkmnLib::Library {
|
||||||
|
class Item : public CreatureLib::Library::Item {};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_ITEM_HPP
|
|
@ -0,0 +1 @@
|
||||||
|
#include "ItemLibrary.hpp"
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef PKMNLIB_ITEMLIBRARY_HPP
|
||||||
|
#define PKMNLIB_ITEMLIBRARY_HPP
|
||||||
|
|
||||||
|
#include <Library/ItemLibrary.hpp>
|
||||||
|
#include "Item.hpp"
|
||||||
|
namespace PkmnLib::Library {
|
||||||
|
class ItemLibrary : public CreatureLib::Library::ItemLibrary {
|
||||||
|
public:
|
||||||
|
const Item* GetItem(const std::string& name) const {
|
||||||
|
return reinterpret_cast<const Item*>(CreatureLib::Library::ItemLibrary::GetItem(name));
|
||||||
|
}
|
||||||
|
const Item* operator[](const std::string& name) const { return GetItem(name); }
|
||||||
|
void LoadItem(const std::string& name, const Item* item) {
|
||||||
|
CreatureLib::Library::ItemLibrary::LoadItem(name, item);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_ITEMLIBRARY_HPP
|
|
@ -1,4 +1 @@
|
||||||
#include "MoveLibrary.hpp"
|
#include "MoveLibrary.hpp"
|
||||||
const CreatureLib::Library::AttackData* PkmnLib::Library::MoveLibrary::operator[](const std::string& name) const {
|
|
||||||
return AttackLibrary::operator[](name);
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,10 +2,25 @@
|
||||||
#define PKMNLIB_MOVELIBRARY_HPP
|
#define PKMNLIB_MOVELIBRARY_HPP
|
||||||
|
|
||||||
#include <Library/AttackLibrary.hpp>
|
#include <Library/AttackLibrary.hpp>
|
||||||
|
#include "MoveData.hpp"
|
||||||
namespace PkmnLib::Library {
|
namespace PkmnLib::Library {
|
||||||
class MoveLibrary : public CreatureLib::Library::AttackLibrary {
|
class MoveLibrary : public CreatureLib::Library::AttackLibrary {
|
||||||
public:
|
public:
|
||||||
virtual const CreatureLib::Library::AttackData* operator[](const std::string& name) const;
|
virtual const MoveData* operator[](const std::string& name) const { return GetAttack(name); }
|
||||||
|
|
||||||
|
const MoveData* GetMove(const std::string& name) const { return GetAttack(name); }
|
||||||
|
|
||||||
|
const MoveData* GetAttack(const std::string& name) const {
|
||||||
|
return reinterpret_cast<const MoveData*>(CreatureLib::Library::AttackLibrary::GetAttack(name));
|
||||||
|
}
|
||||||
|
void LoadAttack(const std::string& name, const MoveData* attack){
|
||||||
|
CreatureLib::Library::AttackLibrary::LoadAttack(name, attack);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadMove(const std::string& name, const MoveData* attack){
|
||||||
|
CreatureLib::Library::AttackLibrary::LoadAttack(name, attack);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
#include "Nature.hpp"
|
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef PKMNLIB_NATURE_HPP
|
||||||
|
#define PKMNLIB_NATURE_HPP
|
||||||
|
|
||||||
|
#include <Core/Statistic.hpp>
|
||||||
|
namespace PkmnLib::Library {
|
||||||
|
class Nature {
|
||||||
|
private:
|
||||||
|
float _increaseModifier;
|
||||||
|
float _decreaseModifier;
|
||||||
|
CreatureLib::Core::Statistic _increaseStat;
|
||||||
|
CreatureLib::Core::Statistic _decreaseStat;
|
||||||
|
|
||||||
|
public:
|
||||||
|
[[nodiscard]] float GetIncreaseModifier() const { return _increaseModifier; }
|
||||||
|
[[nodiscard]] float GetDecreaseModifier() const { return _decreaseModifier; }
|
||||||
|
|
||||||
|
[[nodiscard]] CreatureLib::Core::Statistic GetIncreasedStat() const { return _increaseStat; }
|
||||||
|
[[nodiscard]] CreatureLib::Core::Statistic GetDecreasedStat() const { return _decreaseStat; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_NATURE_HPP
|
|
@ -0,0 +1 @@
|
||||||
|
#include "NatureLibrary.hpp"
|
|
@ -0,0 +1,49 @@
|
||||||
|
#ifndef PKMNLIB_NATURELIBRARY_HPP
|
||||||
|
#define PKMNLIB_NATURELIBRARY_HPP
|
||||||
|
|
||||||
|
#include <Core/Exceptions/CreatureException.hpp>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
#include "Nature.hpp"
|
||||||
|
namespace PkmnLib::Library {
|
||||||
|
class NatureLibrary {
|
||||||
|
private:
|
||||||
|
std::unordered_map<std::string, uint8_t> _keyLookup;
|
||||||
|
std::vector<Nature> _natures;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void LoadNature(const std::string& name, const Nature& nature) {
|
||||||
|
auto find = _keyLookup.find(name);
|
||||||
|
if (find != _keyLookup.end()) {
|
||||||
|
auto key = _keyLookup[name];
|
||||||
|
_natures[key] = nature;
|
||||||
|
} else {
|
||||||
|
_keyLookup[name] = _natures.size();
|
||||||
|
_natures.push_back(nature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const Nature& GetNatureByName(const std::string& name) const {
|
||||||
|
auto find = _keyLookup.find(name);
|
||||||
|
if (find == _keyLookup.end()) {
|
||||||
|
throw CreatureException("Invalid nature name.");
|
||||||
|
}
|
||||||
|
return _natures[_keyLookup.at(name)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const Nature& GetNature(uint8_t id) const{
|
||||||
|
return _natures[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t GetNatureId(const std::string& name) const{
|
||||||
|
auto find = _keyLookup.find(name);
|
||||||
|
if (find == _keyLookup.end()) {
|
||||||
|
throw CreatureException("Invalid nature name.");
|
||||||
|
}
|
||||||
|
return _keyLookup.at(name);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_NATURELIBRARY_HPP
|
|
@ -2,19 +2,40 @@
|
||||||
#define PKMNLIB_POKEMONLIBRARY_HPP
|
#define PKMNLIB_POKEMONLIBRARY_HPP
|
||||||
|
|
||||||
#include <Library/DataLibrary.hpp>
|
#include <Library/DataLibrary.hpp>
|
||||||
|
#include "Items/ItemLibrary.hpp"
|
||||||
|
#include "Moves/MoveLibrary.hpp"
|
||||||
|
#include "Natures/NatureLibrary.hpp"
|
||||||
#include "Species/SpeciesLibrary.hpp"
|
#include "Species/SpeciesLibrary.hpp"
|
||||||
|
|
||||||
namespace PkmnLib::Library {
|
namespace PkmnLib::Library {
|
||||||
class PokemonLibrary : public CreatureLib::Library::DataLibrary {
|
class PokemonLibrary : public CreatureLib::Library::DataLibrary {
|
||||||
|
private:
|
||||||
|
const NatureLibrary* _natures;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PokemonLibrary(CreatureLib::Library::LibrarySettings settings, PkmnLib::Library::SpeciesLibrary* species,
|
~PokemonLibrary() override {
|
||||||
CreatureLib::Library::AttackLibrary* attacks, CreatureLib::Library::ItemLibrary* items,
|
delete _natures;
|
||||||
CreatureLib::Library::GrowthRateLibrary* growthRates,
|
}
|
||||||
CreatureLib::Library::TypeLibrary* typeLibrary)
|
|
||||||
: DataLibrary(settings, species, attacks, items, growthRates, typeLibrary) {}
|
PokemonLibrary(CreatureLib::Library::LibrarySettings settings, SpeciesLibrary* species, MoveLibrary* moves,
|
||||||
const PkmnLib::Library::SpeciesLibrary* GetSpeciesLibrary() const {
|
ItemLibrary* items, CreatureLib::Library::GrowthRateLibrary* growthRates,
|
||||||
return reinterpret_cast<const PkmnLib::Library::SpeciesLibrary*>(
|
CreatureLib::Library::TypeLibrary* typeLibrary, NatureLibrary* natures)
|
||||||
CreatureLib::Library::DataLibrary::GetSpeciesLibrary());
|
: DataLibrary(settings, species, moves, items, growthRates, typeLibrary), _natures(natures) {}
|
||||||
|
|
||||||
|
[[nodiscard]] const SpeciesLibrary* GetSpeciesLibrary() const {
|
||||||
|
return (const SpeciesLibrary*)(CreatureLib::Library::DataLibrary::GetSpeciesLibrary());
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] const MoveLibrary* GetMoveLibrary() const {
|
||||||
|
return (const MoveLibrary*)(CreatureLib::Library::DataLibrary::GetAttackLibrary());
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] const ItemLibrary* GetItemLibrary() const {
|
||||||
|
return (const ItemLibrary*)(CreatureLib::Library::DataLibrary::GetItemLibrary());
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] const NatureLibrary* GetNatureLibrary() const {
|
||||||
|
return _natures;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef PKMNLIB_STATISTIC_HPP
|
||||||
|
#define PKMNLIB_STATISTIC_HPP
|
||||||
|
|
||||||
|
#include <Core/Statistic.hpp>
|
||||||
|
namespace PkmnLib::Library {
|
||||||
|
class Statistic {
|
||||||
|
public:
|
||||||
|
static constexpr const CreatureLib::Core::Statistic HealthPoints = CreatureLib::Core::Statistic::Health;
|
||||||
|
static constexpr const CreatureLib::Core::Statistic PhysicalAttack =
|
||||||
|
CreatureLib::Core::Statistic::PhysicalAttack;
|
||||||
|
static constexpr const CreatureLib::Core::Statistic PhysicalDefense =
|
||||||
|
CreatureLib::Core::Statistic::PhysicalDefense;
|
||||||
|
static constexpr const CreatureLib::Core::Statistic SpecialAttack = CreatureLib::Core::Statistic::MagicalAttack;
|
||||||
|
static constexpr const CreatureLib::Core::Statistic SpecialDefense =
|
||||||
|
CreatureLib::Core::Statistic::MagicalDefense;
|
||||||
|
static constexpr const CreatureLib::Core::Statistic Speed = CreatureLib::Core::Statistic::Speed;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_STATISTIC_HPP
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef PKMNLIB_TESTLIBRARY_HPP
|
#ifndef PKMNLIB_TESTLIBRARY_HPP
|
||||||
#define PKMNLIB_TESTLIBRARY_HPP
|
#define PKMNLIB_TESTLIBRARY_HPP
|
||||||
|
|
||||||
|
#include "../../src/Library/Moves/MoveLibrary.hpp"
|
||||||
#include "../../src/Library/PokemonLibrary.hpp"
|
#include "../../src/Library/PokemonLibrary.hpp"
|
||||||
class TestLibrary {
|
class TestLibrary {
|
||||||
private:
|
private:
|
||||||
|
@ -16,8 +17,8 @@ public:
|
||||||
|
|
||||||
static PkmnLib::Library::PokemonLibrary* BuildLibrary() {
|
static PkmnLib::Library::PokemonLibrary* BuildLibrary() {
|
||||||
return new PkmnLib::Library::PokemonLibrary(CreatureLib::Library::LibrarySettings(100, 4),
|
return new PkmnLib::Library::PokemonLibrary(CreatureLib::Library::LibrarySettings(100, 4),
|
||||||
BuildSpeciesLibrary(), BuildAttackLibrary(), BuildItemLibrary(),
|
BuildSpeciesLibrary(), BuildMoveLibrary(), BuildItemLibrary(),
|
||||||
BuildGrowthRateLibrary(), BuildTypeLibrary());
|
BuildGrowthRateLibrary(), BuildTypeLibrary(), BuildNatureLibrary());
|
||||||
}
|
}
|
||||||
|
|
||||||
static PkmnLib::Library::SpeciesLibrary* BuildSpeciesLibrary() {
|
static PkmnLib::Library::SpeciesLibrary* BuildSpeciesLibrary() {
|
||||||
|
@ -25,13 +26,13 @@ public:
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CreatureLib::Library::AttackLibrary* BuildAttackLibrary() {
|
static PkmnLib::Library::MoveLibrary* BuildMoveLibrary() {
|
||||||
auto lib = new CreatureLib::Library::AttackLibrary();
|
auto lib = new PkmnLib::Library::MoveLibrary();
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CreatureLib::Library::ItemLibrary* BuildItemLibrary() {
|
static PkmnLib::Library::ItemLibrary* BuildItemLibrary() {
|
||||||
auto lib = new CreatureLib::Library::ItemLibrary();
|
auto lib = new PkmnLib::Library::ItemLibrary();
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +45,12 @@ public:
|
||||||
auto lib = new CreatureLib::Library::TypeLibrary();
|
auto lib = new CreatureLib::Library::TypeLibrary();
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PkmnLib::Library::NatureLibrary* BuildNatureLibrary() {
|
||||||
|
auto lib = new PkmnLib::Library::NatureLibrary();
|
||||||
|
return lib;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PKMNLIB_TESTLIBRARY_HPP
|
#endif // PKMNLIB_TESTLIBRARY_HPP
|
||||||
|
|
Loading…
Reference in New Issue