Rework TryGet on MoveLibrary to be less ugly.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-04-22 10:34:09 +02:00
parent 9ac60dfa42
commit 984088f7a9
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 6 additions and 1 deletions

View File

@ -11,7 +11,12 @@ namespace PkmnLib::Library {
virtual const MoveData* operator[](const Arbutils::CaseInsensitiveConstString& name) const { return Get(name); } virtual const MoveData* operator[](const Arbutils::CaseInsensitiveConstString& name) const { return Get(name); }
inline bool TryGet(const Arbutils::CaseInsensitiveConstString& name, const MoveData*& move) const { inline bool TryGet(const Arbutils::CaseInsensitiveConstString& name, const MoveData*& move) const {
return CreatureLib::Library::AttackLibrary::TryGet(name, (const CreatureLib::Library::AttackData*&)move); const CreatureLib::Library::AttackData* ptr;
if (CreatureLib::Library::AttackLibrary::TryGet(name, ptr)){
move = dynamic_cast<const MoveData*>(ptr);
return true;
}
return false;
} }
const MoveData* Get(const Arbutils::CaseInsensitiveConstString& name) const { const MoveData* Get(const Arbutils::CaseInsensitiveConstString& name) const {
return dynamic_cast<const MoveData*>(CreatureLib::Library::AttackLibrary::Get(name)); return dynamic_cast<const MoveData*>(CreatureLib::Library::AttackLibrary::Get(name));