Support ConstString in TypeLibrary.
This commit is contained in:
@@ -1,22 +1,24 @@
|
||||
#ifndef CREATURELIB_TYPELIBRARY_HPP
|
||||
#define CREATURELIB_TYPELIBRARY_HPP
|
||||
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
using ConstString = Arbutils::CaseInsensitiveConstString;
|
||||
|
||||
namespace CreatureLib::Library {
|
||||
class TypeLibrary {
|
||||
std::unordered_map<std::string, uint8_t> _types;
|
||||
std::unordered_map<ConstString, uint8_t> _types;
|
||||
std::vector<std::vector<float>> _effectiveness;
|
||||
|
||||
public:
|
||||
TypeLibrary(size_t initialCapacity = 20) : _types(std::unordered_map<std::string, uint8_t>(initialCapacity)) {}
|
||||
TypeLibrary(size_t initialCapacity = 20) : _types(std::unordered_map<ConstString, uint8_t>(initialCapacity)) {}
|
||||
|
||||
uint8_t GetTypeId(const std::string& s) const;
|
||||
uint8_t GetTypeId(const ConstString& s) const;
|
||||
float GetSingleEffectiveness(uint8_t attacking, uint8_t defensive) const;
|
||||
float GetEffectiveness(uint8_t attacking, const std::vector<uint8_t>& defensive) const;
|
||||
|
||||
uint8_t RegisterType(const std::string& typeName);
|
||||
uint8_t RegisterType(const ConstString& typeName);
|
||||
void SetEffectiveness(uint8_t attacking, uint8_t defensive, float effectiveness);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user