diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-30 14:48:02 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-30 14:48:02 +0100 |
commit | 6dfa3fb34fb0a2ea028fd46e77296e26b092fb99 (patch) | |
tree | 51257e54561550c91dbec262fe143d4dbe41f059 /frontend/cmd/go.cpp | |
parent | 862186ae7cbbd922057fa5f6b49509c36f9ade36 (diff) |
use string instead of argument vector for commands
Diffstat (limited to 'frontend/cmd/go.cpp')
-rw-r--r-- | frontend/cmd/go.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/frontend/cmd/go.cpp b/frontend/cmd/go.cpp index cbe8e7c..624bf6c 100644 --- a/frontend/cmd/go.cpp +++ b/frontend/cmd/go.cpp @@ -2,6 +2,7 @@ #include "../Player.h" #include "../print.h" +#include "../strings.h" using namespace std; @@ -12,13 +13,14 @@ static const unordered_map<string, Direction> direction_map = { { "west", Direction::WEST }, }; -FollowupAction Player::cmd_go(Argv argv) { - if (argv.size() == 0 || !direction_map.contains(argv[0])) { +FollowupAction Player::cmd_go(string & argv) { + string direction_str = str_consume_arg(argv); + if (direction_str.size() == 0 || !direction_map.contains(direction_str)) { lprtf("Fout, gebruik: Ga <noord|zuid|oost|west>\n"); return FollowupAction::NONE; } - Direction direction = direction_map.at(argv[0]); + Direction direction = direction_map.at(direction_str); Location * next_location = this->location.get_exit(direction); if (next_location == nullptr) { lprtf("Er is geen uitgang in deze richting!\n"); |