blob: cbe8e7c84c7c37318481bc551734b482fa7b2581 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include "backend/Location.h"
#include "../Player.h"
#include "../print.h"
using namespace std;
static const unordered_map<string, Direction> direction_map = {
{ "noord", Direction::NORTH },
{ "oost", Direction::EAST },
{ "zuid", Direction::SOUTH },
{ "west", Direction::WEST },
};
FollowupAction Player::cmd_go(Argv argv) {
if (argv.size() == 0 || !direction_map.contains(argv[0])) {
lprtf("Fout, gebruik: Ga <noord|zuid|oost|west>\n");
return FollowupAction::NONE;
}
Direction direction = direction_map.at(argv[0]);
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;
}
|