Initial commit
This commit is contained in:
1
src/Library/GrowthRates/GrowthRate.cpp
Normal file
1
src/Library/GrowthRates/GrowthRate.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "GrowthRate.hpp"
|
||||
14
src/Library/GrowthRates/GrowthRate.hpp
Normal file
14
src/Library/GrowthRates/GrowthRate.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef CREATURELIB_GROWTHRATE_HPP
|
||||
#define CREATURELIB_GROWTHRATE_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
class GrowthRate {
|
||||
public:
|
||||
[[nodiscard]] virtual uint8_t CalculateLevel(uint32_t experience) const = 0;
|
||||
[[nodiscard]] virtual uint32_t CalculateExperience(uint8_t level) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //CREATURELIB_GROWTHRATE_HPP
|
||||
9
src/Library/GrowthRates/GrowthRateLibrary.cpp
Normal file
9
src/Library/GrowthRates/GrowthRateLibrary.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "GrowthRateLibrary.hpp"
|
||||
|
||||
uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const std::string &growthRate, uint32_t experience) const {
|
||||
return _growthRates.at(growthRate)->CalculateLevel(experience);
|
||||
}
|
||||
|
||||
uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(const std::string &growthRate, uint8_t level) const {
|
||||
return _growthRates.at(growthRate)->CalculateExperience(level);
|
||||
}
|
||||
19
src/Library/GrowthRates/GrowthRateLibrary.hpp
Normal file
19
src/Library/GrowthRates/GrowthRateLibrary.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef CREATURELIB_GROWTHRATELIBRARY_HPP
|
||||
#define CREATURELIB_GROWTHRATELIBRARY_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "GrowthRate.hpp"
|
||||
|
||||
namespace CreatureLib::Library{
|
||||
class GrowthRateLibrary {
|
||||
private:
|
||||
std::unordered_map<std::string, GrowthRate*> _growthRates;
|
||||
public:
|
||||
[[nodiscard]] uint8_t CalculateLevel(const std::string& growthRate, uint32_t experience) const;
|
||||
[[nodiscard]] uint32_t CalculateExperience(const std::string& growthRate, uint8_t level) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //CREATURELIB_GROWTHRATELIBRARY_HPP
|
||||
Reference in New Issue
Block a user