Initial commit

This commit is contained in:
2019-10-06 13:50:52 +02:00
commit 265923231f
44 changed files with 16258 additions and 0 deletions

View File

@@ -0,0 +1 @@
#include "GrowthRate.hpp"

View 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

View 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);
}

View 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