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
64
65
66
67
68
|
#pragma once
#include "List.h"
#include "ListIterator.h"
#include "backend/String.h"
class Enemy;
class Object;
class Location;
enum Direction {
NORTH = 0,
EAST = 1,
SOUTH = 2,
WEST = 3,
};
static constexpr const Direction DIRECTIONS[] = { NORTH, EAST, SOUTH, WEST };
Direction random_direction();
Direction random_direction(const Location &);
class Location {
public:
void set_name(const String & name);
const String & get_name() const;
void set_description(const String & description);
const String & get_description() const;
void set_exit(Direction dir, Location * location = nullptr);
Location * get_exit(Direction dir) const;
void add_visible_object(Object *);
void remove_visible_object(Object *);
ListRange<Object *> get_visible_objects() const;
void add_hidden_object(Object *);
void remove_hidden_object(Object *);
ListRange<Object *> get_hidden_objects() const;
void hide_object(Object *);
void unhide_object(Object *);
void add_enemy(Enemy *);
void remove_enemy(Enemy *);
ListRange<Enemy *> get_enemies() const;
private:
friend class LocationFactory;
Location(const String & name, const String & description);
public:
virtual ~Location();
private:
String name;
String description;
List<Enemy*> enemies;
List<Object*> hidden_objects;
List<Object*> visible_objects;
Location * edges[4] = {
nullptr,
nullptr,
nullptr,
nullptr,
};
};
|