Implements outlines for ItemLibrary, MoveLibrary and implements NatureLibrary.
This commit is contained in:
1
src/Library/Natures/Nature.cpp
Normal file
1
src/Library/Natures/Nature.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "Nature.hpp"
|
||||
22
src/Library/Natures/Nature.hpp
Normal file
22
src/Library/Natures/Nature.hpp
Normal file
@@ -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
|
||||
1
src/Library/Natures/NatureLibrary.cpp
Normal file
1
src/Library/Natures/NatureLibrary.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "NatureLibrary.hpp"
|
||||
49
src/Library/Natures/NatureLibrary.hpp
Normal file
49
src/Library/Natures/NatureLibrary.hpp
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user