Update to new Arbutils
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-06-26 17:08:23 +02:00
parent f50f76e993
commit 48639eeee5
44 changed files with 177 additions and 200 deletions

View File

@@ -1,7 +1,7 @@
#include "GrowthRateLibrary.hpp"
#include "../Exceptions/CreatureException.hpp"
uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const ConstString& growthRate,
uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const ArbUt::BasicStringView& growthRate,
uint32_t experience) const {
auto find = _growthRates.find(growthRate);
if (find == _growthRates.end()) {
@@ -18,7 +18,7 @@ uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(uint32_t hash, u
return find->second->CalculateLevel(experience);
}
uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(const ConstString& growthRate,
uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(const ArbUt::BasicStringView& growthRate,
uint8_t level) const {
auto find = _growthRates.find(growthRate);
if (find == _growthRates.end()) {
@@ -35,7 +35,7 @@ uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(uint32_t h
return find->second->CalculateExperience(level);
}
void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(const ConstString& name,
void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(const ArbUt::StringView& name,
CreatureLib::Library::GrowthRate* rate) {
_growthRates.insert({name, std::unique_ptr<const GrowthRate>(rate)});
}

View File

@@ -1,15 +1,13 @@
#ifndef CREATURELIB_GROWTHRATELIBRARY_HPP
#define CREATURELIB_GROWTHRATELIBRARY_HPP
#include <Arbutils/ConstString.hpp>
#include <Arbutils/StringView.hpp>
#include <cstdint>
#include <memory>
#include <string>
#include <unordered_map>
#include "GrowthRate.hpp"
using ConstString = ArbUt::CaseInsensitiveConstString;
namespace CreatureLib::Library {
class GrowthRateLibrary {
private:
@@ -21,13 +19,13 @@ namespace CreatureLib::Library {
virtual ~GrowthRateLibrary() = default;
[[nodiscard]] uint8_t CalculateLevel(const ConstString& growthRate, uint32_t experience) const;
[[nodiscard]] uint8_t CalculateLevel(const ArbUt::BasicStringView& growthRate, uint32_t experience) const;
[[nodiscard]] uint8_t CalculateLevel(uint32_t hash, uint32_t experience) const;
[[nodiscard]] uint32_t CalculateExperience(const ConstString& growthRate, uint8_t level) const;
[[nodiscard]] uint32_t CalculateExperience(const ArbUt::BasicStringView& growthRate, uint8_t level) const;
[[nodiscard]] uint32_t CalculateExperience(uint32_t hash, uint8_t level) const;
void AddGrowthRate(uint32_t hash, GrowthRate* rate);
void AddGrowthRate(const ConstString& name, GrowthRate* rate);
void AddGrowthRate(const ArbUt::StringView& name, GrowthRate* rate);
};
}