diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-01 18:31:16 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-01 18:31:16 +0100 |
commit | ca3e80a5b474d99391c253d3173117e955e33a20 (patch) | |
tree | a4bf3d639b74d82a72203c314c5cf7f54015e133 /frontend/cmd/go.cpp | |
parent | 5376efe7e63ef3c848a971ea845a16c7e030d153 (diff) |
improve error message consistency
Diffstat (limited to 'frontend/cmd/go.cpp')
-rw-r--r-- | frontend/cmd/go.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/frontend/cmd/go.cpp b/frontend/cmd/go.cpp index 185d727..75f6345 100644 --- a/frontend/cmd/go.cpp +++ b/frontend/cmd/go.cpp @@ -1,7 +1,7 @@ #include "backend/Location.h" -#include "backend/print.h" #include "backend/Dungeon.h" #include "backend/Exception.h" +#include "backend/print.h" #include "../GameController.h" #include "../strings.h" @@ -18,17 +18,21 @@ static const unordered_map<string, Direction> direction_map = { void GameController::cmd_go(string & argv) { string direction_str = str_consume_arg(argv); if (direction_str.size() == 0) - throw Exception("Dit commando heeft nog een argument met een richting nodig"); + throw Exception("dit commando heeft nog een argument met een richting nodig"); if (!direction_map.contains(direction_str)) - throw Exception("Onbekende richting \"%s\", probeer noord|zuid|oost|west", direction_str.c_str()); + throw Exception("onbekende richting \"%s\", probeer noord|zuid|oost|west", direction_str.c_str()); Player & player = this->dungeon->get_player(); Direction direction = direction_map.at(direction_str); Location * next_location = player.get_location().get_exit(direction); if (next_location == nullptr) - throw Exception("Er is geen uitgang in deze richting"); + throw Exception("er is geen uitgang in deze richting"); - player.set_location(*next_location); this->dungeon->update(); + + if (!player.is_dead()) { + player.set_location(*next_location); + lprtf("Je staat nu bij de locatie %s\n", player.get_location().get_name().c_str()); + } } |