diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-01 22:47:42 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-01 22:47:42 +0100 |
commit | 07796bea15a2d5f43766f062379b63fc9e9e1b5d (patch) | |
tree | 2d398f161a9a933176f50779ff164e76c3871f43 /frontend/GameData.cpp | |
parent | af76b9a0ae58dc8c87548053a5bc310ad6be25ce (diff) |
WIP consumables
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 (...) { |