From 6dfa3fb34fb0a2ea028fd46e77296e26b092fb99 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 30 Oct 2024 14:48:02 +0100 Subject: use string instead of argument vector for commands --- frontend/cmd/go.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'frontend/cmd/go.cpp') 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 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 \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"); -- cgit v1.2.3