diff options
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/GameController.cpp | 5 | ||||
-rw-r--r-- | frontend/GameData.cpp | 9 | ||||
-rw-r--r-- | frontend/cmd/query.cpp | 2 | ||||
-rw-r--r-- | frontend/cmd/view.cpp | 15 |
4 files changed, 24 insertions, 7 deletions
diff --git a/frontend/GameController.cpp b/frontend/GameController.cpp index 5505380..a75767c 100644 --- a/frontend/GameController.cpp +++ b/frontend/GameController.cpp @@ -1,13 +1,18 @@ +#include "rl.h" #include "GameData.h" #include "strings.h" #include "GameController.h" +#include "backend/print.h" #include "backend/WeaponObject.h" #include "backend/Dungeon.h" using namespace std; GameController::GameController(Dungeon & dungeon) : dungeon(dungeon), player(dungeon.get_player()) { + lprtf("Wat is de naam van je karakter?\n"); + string name = rl(); + player.name = name.c_str(); cmdset_default(); player.set_location(dungeon.get_start_location()); player.equip(static_cast<WeaponObject *>(GameData::get_instance().create_object("Dolk"))); diff --git a/frontend/GameData.cpp b/frontend/GameData.cpp index 4556621..e62cff1 100644 --- a/frontend/GameData.cpp +++ b/frontend/GameData.cpp @@ -41,8 +41,13 @@ Enemy * GameData::create_enemy(const string & name) { try { auto row = query.row(); - return EnemyFactory::create_enemy(row.col<const char *>(0), row.col<const char *>(1)); - // TODO: set all other properties + auto enemy = unique_ptr<Enemy>{ EnemyFactory::create_enemy(row.col<const char *>(0), row.col<const char *>(1)) }; + // TODO: min/max objects(?) + enemy->set_health(row.col<int>(4)); + enemy->set_attack(static_cast<float>(row.col<int>(5)) / 100); + enemy->set_damage_min(row.col<int>(6)); + enemy->set_damage_max(row.col<int>(7)); + return enemy.release(); } catch (...) { return EnemyFactory::create_enemy(name.c_str()); } diff --git a/frontend/cmd/query.cpp b/frontend/cmd/query.cpp index f04e053..2a62b45 100644 --- a/frontend/cmd/query.cpp +++ b/frontend/cmd/query.cpp @@ -49,7 +49,7 @@ FollowupAction GameController::cmd_query(string &) { size_t enemies = 0; for (Enemy * enemy : location.get_enemies()) { if (enemies > 0) lprtf(", "); - lprtf("%s", enemy->get_name().c_str()); + lprtf("%s", enemy->get_displayname().c_str()); enemies++; } if (enemies == 0) diff --git a/frontend/cmd/view.cpp b/frontend/cmd/view.cpp index 69eb96e..04ad6aa 100644 --- a/frontend/cmd/view.cpp +++ b/frontend/cmd/view.cpp @@ -33,7 +33,7 @@ FollowupAction GameController::cmd_view(string & target) { lprtf("Je hebt %u goundstuk%s.\n", this->player.gold, this->player.gold == 1 ? "" : "ken"); size_t items = this->player.inventory.size(); - lprtf("Je hebt %d overige object%s%s\n", items, items == 1 ? "" : "en", items > 0 ? ":" : "."); + lprtf("Je hebt %d %s%s\n", items, items == 1 ? "overig object" : "overige objecten", items > 0 ? ":" : "."); for (auto & object : this->player.inventory) { lprtf("- %s\n", object->get_displayname().c_str()); } @@ -64,9 +64,16 @@ FollowupAction GameController::cmd_view(string & target) { lprtf("%s\n", enemy->get_description().c_str()); unsigned enemy_health = enemy->get_health(); lprtf("%s heeft %s levenspunten.\n", enemy->get_name().c_str(), enemy_health); - // IF enemy_health == 0: - // TODO: show enemy hidden objects - // TODO: move enemy hidden objects to location visible objects + + if (!enemy->is_dead()) return FollowupAction::NONE; + bool snatched = false; + for (Object * object : enemy->get_hidden_objects()) { + if (!snatched) lprtf("%s had de volgende voorwerpen:\n", enemy->get_displayname().c_str()); + lprtf("- %s\n", object->get_displayname().c_str()); + enemy->remove_hidden_object(object); + location.add_visible_object(object); + snatched = true; + } return FollowupAction::NONE; } |