Make Attack, Item and Species libraries be case insensitive.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-02-13 16:05:27 +01:00
parent 8d4860f553
commit 611198009b
3 changed files with 42 additions and 12 deletions

View File

@@ -2,7 +2,9 @@
bool CreatureLib::Library::AttackLibrary::TryGetAttack(const std::string& name,
const CreatureLib::Library::AttackData*& move) const {
auto find = _attacks.find(name);
std::string key = name;
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
auto find = _attacks.find(key);
if (find == _attacks.end()) {
move = nullptr;
return false;
@@ -12,7 +14,9 @@ bool CreatureLib::Library::AttackLibrary::TryGetAttack(const std::string& name,
}
const CreatureLib::Library::AttackData* CreatureLib::Library::AttackLibrary::GetAttack(const std::string& name) const {
return this->_attacks.at(name);
std::string key = name;
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
return this->_attacks.at(key);
}
const CreatureLib::Library::AttackData* CreatureLib::Library::AttackLibrary::operator[](const std::string& name) const {
@@ -21,7 +25,13 @@ const CreatureLib::Library::AttackData* CreatureLib::Library::AttackLibrary::ope
void CreatureLib::Library::AttackLibrary::LoadAttack(const std::string& name,
const CreatureLib::Library::AttackData* attack) {
this->_attacks.insert({name, attack});
std::string key = name;
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
this->_attacks.insert({key, attack});
}
void CreatureLib::Library::AttackLibrary::DeleteAttack(const std::string& name) { this->_attacks.erase(name); }
void CreatureLib::Library::AttackLibrary::DeleteAttack(const std::string& name) {
std::string key = name;
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
this->_attacks.erase(key);
}