aboutsummaryrefslogtreecommitdiff
path: root/backend/Location.h
diff options
context:
space:
mode:
Diffstat (limited to 'backend/Location.h')
-rw-r--r--backend/Location.h35
1 files changed, 23 insertions, 12 deletions
diff --git a/backend/Location.h b/backend/Location.h
index fb0abfc..b139da8 100644
--- a/backend/Location.h
+++ b/backend/Location.h
@@ -2,9 +2,11 @@
#include "List.h"
#include "ListIterator.h"
+#include "backend/String.h"
class Enemy;
class Object;
+class Location;
enum Direction {
NORTH = 0,
@@ -14,31 +16,39 @@ enum Direction {
};
static constexpr const Direction DIRECTIONS[] = { NORTH, EAST, SOUTH, WEST };
+Direction random_direction();
+Direction random_direction(const Location &);
+
class Location {
public:
- void set_name(const char * name);
- const char * get_name();
- void set_description(const char * description);
- const char * get_description();
+ 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);
+ Location * get_exit(Direction dir) const;
+
void add_object(Object *);
void remove_object(Object *);
- ListRange<Object *> get_objects();
+ ListRange<Object *> get_objects() const;
+
void add_enemy(Enemy *);
- ListRange<Enemy *> get_enemies();
+ void remove_enemy(Enemy *);
+ ListRange<Enemy *> get_enemies() const;
private:
friend class LocationFactory;
- Location(const char * name = "", const char * description = "");
+ Location(const String & name, const String & description);
public:
virtual ~Location();
private:
- const char * name = nullptr;
- const char * description = nullptr;
- List<Enemy*> enemies = {};
- List<Object*> objects = {};
+ String name;
+ String description;
+ List<Enemy*> enemies;
+ List<Object*> objects;
Location * edges[4] = {
nullptr,
@@ -47,3 +57,4 @@ private:
nullptr,
};
};
+