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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#include "backend/Location.h"
#include "backend/Object.h"
#include "backend/Enemy.h"
#include "backend/print.h"
#include "backend/Dungeon.h"
#include "../GameController.h"
using namespace std;
static const unordered_map<Direction, string> direction_map = {
{ Direction::NORTH, "Noord" },
{ Direction::EAST, "Oost" },
{ Direction::SOUTH, "Zuid" },
{ Direction::WEST, "West" },
};
void GameController::cmd_query(string &) {
Player & player = this->dungeon->get_player();
Location & location = player.get_location();
lprtf("Je staat bij de locatie %s.\n", location.get_name().c_str());
lprtf("%s\n", location.get_description().c_str());
{
lprtf("Zichtbare objecten: ");
size_t objects = 0;
for (Object * obj : location.get_visible_objects()) {
if (objects > 0) lprtf(", ");
lprtf("%s", obj->get_displayname().c_str());
objects++;
}
if (objects == 0)
lprtf("(geen)");
lprtf("\n");
}
{
lprtf("Uitgangen: ");
bool first = true;
for (Direction direction : DIRECTIONS) {
if (location.get_exit(direction) == nullptr) continue;
if (!first) lprtf(", ");
lprtf("%s", direction_map.at(direction).c_str());
first = false;
}
lprtf("\n");
}
{
lprtf("Vijanden: ");
size_t enemies = 0;
for (Enemy * enemy : location.get_enemies()) {
if (enemies > 0) lprtf(", ");
lprtf("%s", enemy->get_displayname().c_str());
enemies++;
}
if (enemies == 0)
lprtf("(geen)");
lprtf("\n");
}
}
|