Implements TryGet functions on several libraries.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-02-01 15:33:44 +01:00
parent dba271681d
commit bb9b9609a6
6 changed files with 36 additions and 0 deletions

View File

@@ -1,5 +1,16 @@
#include "ItemLibrary.hpp"
bool CreatureLib::Library::ItemLibrary::TryGetItem(const std::string& name,
const CreatureLib::Library::Item*& item) const {
auto find = this->_items.find(name);
if (find == this->_items.end()) {
item = nullptr;
return false;
}
item = find->second;
return true;
}
const CreatureLib::Library::Item* CreatureLib::Library::ItemLibrary::GetItem(const std::string& name) const {
return this->_items.at(name);
}