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 | |
parent | 5376efe7e63ef3c848a971ea845a16c7e030d153 (diff) |
improve error message consistency
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/GameController.cpp | 2 | ||||
-rw-r--r-- | frontend/cmd/equip.cpp | 4 | ||||
-rw-r--r-- | frontend/cmd/get.cpp | 2 | ||||
-rw-r--r-- | frontend/cmd/go.cpp | 14 | ||||
-rw-r--r-- | frontend/cmd/hit.cpp | 2 | ||||
-rw-r--r-- | frontend/cmd/put.cpp | 2 | ||||
-rw-r--r-- | frontend/cmd/view.cpp | 2 |
7 files changed, 16 insertions, 12 deletions
diff --git a/frontend/GameController.cpp b/frontend/GameController.cpp index f160006..d7b5f96 100644 --- a/frontend/GameController.cpp +++ b/frontend/GameController.cpp @@ -85,7 +85,7 @@ void GameController::gameloop() { try { this->cmd(line); } catch (Exception & e) { - lprtf("FOUT: %s\n", e.what()); + lprtf("FOUT: %s.\n", e.what()); } if (player.is_dead()) diff --git a/frontend/cmd/equip.cpp b/frontend/cmd/equip.cpp index 238d287..9d2a006 100644 --- a/frontend/cmd/equip.cpp +++ b/frontend/cmd/equip.cpp @@ -28,8 +28,8 @@ void GameController::cmd_equip(string & target_name) { return; } - throw Exception("Object \"%s\" is niet draagbaar.", target_name.c_str()); + throw Exception("object \"%s\" is niet draagbaar", target_name.c_str()); } - throw Exception("Object \"%s\" niet gevonden.", target_name.c_str()); + throw Exception("object \"%s\" niet gevonden", target_name.c_str()); } diff --git a/frontend/cmd/get.cpp b/frontend/cmd/get.cpp index dd098d1..3e85e57 100644 --- a/frontend/cmd/get.cpp +++ b/frontend/cmd/get.cpp @@ -23,7 +23,7 @@ void GameController::cmd_get(string & target_name) { break; } if (target == nullptr) - throw Exception("Object \"%s\" niet gevonden.", target_name.c_str()); + throw Exception("object \"%s\" niet gevonden", target_name.c_str()); // gold objects are collected and (implicitly) destroyed GoldObject * gold = dynamic_cast<GoldObject *>(target.get()); 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()); + } } diff --git a/frontend/cmd/hit.cpp b/frontend/cmd/hit.cpp index 8491758..8866f60 100644 --- a/frontend/cmd/hit.cpp +++ b/frontend/cmd/hit.cpp @@ -28,6 +28,6 @@ void GameController::cmd_hit(string & target_name) { return; } - throw Exception("Vijand \"%s\" niet gevonden.", target_name.c_str()); + throw Exception("vijand \"%s\" niet gevonden", target_name.c_str()); } diff --git a/frontend/cmd/put.cpp b/frontend/cmd/put.cpp index be3bcca..7f54c3b 100644 --- a/frontend/cmd/put.cpp +++ b/frontend/cmd/put.cpp @@ -20,6 +20,6 @@ void GameController::cmd_put(string & target_name) { return; } - throw Exception("Object \"%s\" niet gevonden.", target_name.c_str()); + throw Exception("object \"%s\" niet gevonden", target_name.c_str()); } diff --git a/frontend/cmd/view.cpp b/frontend/cmd/view.cpp index bd9e99b..291e321 100644 --- a/frontend/cmd/view.cpp +++ b/frontend/cmd/view.cpp @@ -81,6 +81,6 @@ void GameController::cmd_view(string & target) { return; } - throw Exception("geen entiteit met naam \"%s\" gevonden.", target.c_str()); + throw Exception("geen entiteit met naam \"%s\" gevonden", target.c_str()); } |