Make type library work case insensitive.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
925763752f
commit
52d24922ff
|
@ -27,7 +27,7 @@ namespace CreatureLib::Library {
|
|||
void LoadSpecies(const std::string& name, const CreatureSpecies* species);
|
||||
void DeleteSpecies(const std::string& name);
|
||||
|
||||
size_t GetCount() const { return _species.count(); }
|
||||
size_t GetCount() const { return _species.size(); }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "TypeLibrary.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace CreatureLib::Library;
|
||||
|
||||
|
@ -14,10 +15,16 @@ float TypeLibrary::GetSingleEffectiveness(uint8_t attacking, uint8_t defensive)
|
|||
return _effectiveness[attacking][defensive];
|
||||
}
|
||||
|
||||
uint8_t TypeLibrary::GetTypeId(const std::string& s) const { return _types.at(s); }
|
||||
uint8_t TypeLibrary::GetTypeId(const std::string& s) const {
|
||||
std::string key = s;
|
||||
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
|
||||
return _types.at(key);
|
||||
}
|
||||
|
||||
uint8_t TypeLibrary::RegisterType(const std::string& typeName) {
|
||||
_types.insert({typeName, _types.size()});
|
||||
std::string key = typeName;
|
||||
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
|
||||
_types.insert({key, _types.size()});
|
||||
_effectiveness.resize(_types.size());
|
||||
for (auto& eff : _effectiveness) {
|
||||
eff.resize(_types.size(), 1);
|
||||
|
|
Loading…
Reference in New Issue