diff options
Diffstat (limited to 'frontend/GameData.cpp')
-rw-r--r-- | frontend/GameData.cpp | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/frontend/GameData.cpp b/frontend/GameData.cpp index a716a57..30816c8 100644 --- a/frontend/GameData.cpp +++ b/frontend/GameData.cpp @@ -49,20 +49,11 @@ Enemy * GameData::create_enemy(const string & name) const { } } -static const unordered_map<string, ObjectType> type_map = { - { "teleportatiedrank", ObjectType::CONSUMABLE }, - { "ervaringsdrank", ObjectType::CONSUMABLE }, - { "levenselixer", ObjectType::CONSUMABLE }, - { "wapenrusting", ObjectType::ARMOR }, - { "wapen", ObjectType::WEAPON }, - { "goudstukken", ObjectType::GOLD }, -}; - Object * GameData::create_object(const string & name) const { static DBStatement query = this->db.prepare(R"( select - type, omschrijving, + type, minimumwaarde, maximumwaarde, bescherming @@ -76,14 +67,11 @@ Object * GameData::create_object(const string & name) const { try { auto row = query.row(); - string type = row.col<const char *>(0); - if (!type_map.contains(type)) throw std::exception(); return ObjectFactory::create_object({ .name = name.c_str(), - .description = row.col<const char *>(1, nullptr), - .type = type_map.at(type), - .min_value = row.col<int>(2), - .max_value = row.col<int>(3), + .description = row.col<const char *>(0, nullptr), + .type = row.col<const char *>(1, nullptr), + .value = { row.col<int>(2), row.col<int>(3) }, .protection = row.col<int>(4), }); } catch (...) { |