Make Attack, Item and Species libraries be case insensitive.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
bool CreatureLib::Library::ItemLibrary::TryGetItem(const std::string& name,
|
||||
const CreatureLib::Library::Item*& item) const {
|
||||
auto find = this->_items.find(name);
|
||||
std::string key = name;
|
||||
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
|
||||
auto find = this->_items.find(key);
|
||||
if (find == this->_items.end()) {
|
||||
item = nullptr;
|
||||
return false;
|
||||
@@ -12,7 +14,9 @@ bool CreatureLib::Library::ItemLibrary::TryGetItem(const std::string& name,
|
||||
}
|
||||
|
||||
const CreatureLib::Library::Item* CreatureLib::Library::ItemLibrary::GetItem(const std::string& name) const {
|
||||
return this->_items.at(name);
|
||||
std::string key = name;
|
||||
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
|
||||
return this->_items.at(key);
|
||||
}
|
||||
|
||||
const CreatureLib::Library::Item* CreatureLib::Library::ItemLibrary::operator[](const std::string& name) const {
|
||||
@@ -20,7 +24,13 @@ const CreatureLib::Library::Item* CreatureLib::Library::ItemLibrary::operator[](
|
||||
}
|
||||
|
||||
void CreatureLib::Library::ItemLibrary::LoadItem(const std::string& name, const CreatureLib::Library::Item* item) {
|
||||
this->_items.insert({name, item});
|
||||
std::string key = name;
|
||||
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
|
||||
this->_items.insert({key, item});
|
||||
}
|
||||
|
||||
void CreatureLib::Library::ItemLibrary::DeleteItem(const std::string& name) { this->_items.erase(name); }
|
||||
void CreatureLib::Library::ItemLibrary::DeleteItem(const std::string& name) {
|
||||
std::string key = name;
|
||||
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
|
||||
this->_items.erase(key);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user