From 6e1d62955c7a7f39bc9126d709a42a70e02a1d30 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 30 Oct 2024 19:59:38 +0100 Subject: create backend string class --- backend/Location.h | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'backend/Location.h') 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 get_objects(); + ListRange get_objects() const; + void add_enemy(Enemy *); - ListRange get_enemies(); + void remove_enemy(Enemy *); + ListRange 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 enemies = {}; - List objects = {}; + String name; + String description; + List enemies; + List objects; Location * edges[4] = { nullptr, @@ -47,3 +57,4 @@ private: nullptr, }; }; + -- cgit v1.2.3