#include "backend/Location.h" #include "backend/print.h" #include "../Player.h" #include "../strings.h" using namespace std; static const unordered_map direction_map = { { "noord", Direction::NORTH }, { "oost", Direction::EAST }, { "zuid", Direction::SOUTH }, { "west", Direction::WEST }, }; 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(direction_str); Location * next_location = this->location.get_exit(direction); if (next_location == nullptr) { lprtf("Er is geen uitgang in deze richting!\n"); return FollowupAction::NONE; } this->location = *next_location; return FollowupAction::UPDATE; }