diff options
Diffstat (limited to 'src/map.h')
-rw-r--r-- | src/map.h | 66 |
1 files changed, 63 insertions, 3 deletions
diff --git a/src/map.h b/src/map.h index 6fe1e62..0e11b9d 100644 --- a/src/map.h +++ b/src/map.h | |||
@@ -4,7 +4,6 @@ | |||
4 | #include <vector> | 4 | #include <vector> |
5 | #include <string> | 5 | #include <string> |
6 | #include <list> | 6 | #include <list> |
7 | #include <stdexcept> | ||
8 | #include <map> | 7 | #include <map> |
9 | 8 | ||
10 | class Map { | 9 | class Map { |
@@ -44,6 +43,59 @@ public: | |||
44 | int mapId_; | 43 | int mapId_; |
45 | }; | 44 | }; |
46 | 45 | ||
46 | class Object { | ||
47 | public: | ||
48 | |||
49 | Object( | ||
50 | std::string type, | ||
51 | double x, | ||
52 | double y, | ||
53 | size_t index, | ||
54 | std::map<std::string, int> items) : | ||
55 | type_(std::move(type)), | ||
56 | x_(x), | ||
57 | y_(y), | ||
58 | index_(index), | ||
59 | items_(std::move(items)) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | inline const std::string& getType() const | ||
64 | { | ||
65 | return type_; | ||
66 | } | ||
67 | |||
68 | inline double getX() const | ||
69 | { | ||
70 | return x_; | ||
71 | } | ||
72 | |||
73 | inline double getY() const | ||
74 | { | ||
75 | return y_; | ||
76 | } | ||
77 | |||
78 | inline size_t getIndex() const | ||
79 | { | ||
80 | return index_; | ||
81 | } | ||
82 | |||
83 | inline const std::map<std::string, int>& getItems() const | ||
84 | { | ||
85 | return items_; | ||
86 | } | ||
87 | |||
88 | private: | ||
89 | |||
90 | std::string type_; | ||
91 | double x_; | ||
92 | double y_; | ||
93 | size_t index_; | ||
94 | std::map<std::string, int> items_; | ||
95 | }; | ||
96 | |||
97 | using object_storage_type = std::list<Object>; | ||
98 | |||
47 | Map( | 99 | Map( |
48 | int id, | 100 | int id, |
49 | std::vector<int> tiles, | 101 | std::vector<int> tiles, |
@@ -51,14 +103,16 @@ public: | |||
51 | Adjacent leftAdjacent, | 103 | Adjacent leftAdjacent, |
52 | Adjacent rightAdjacent, | 104 | Adjacent rightAdjacent, |
53 | Adjacent upAdjacent, | 105 | Adjacent upAdjacent, |
54 | Adjacent downAdjacent) : | 106 | Adjacent downAdjacent, |
107 | object_storage_type objects) : | ||
55 | id_(id), | 108 | id_(id), |
56 | tiles_(std::move(tiles)), | 109 | tiles_(std::move(tiles)), |
57 | title_(std::move(title)), | 110 | title_(std::move(title)), |
58 | leftAdjacent_(std::move(leftAdjacent)), | 111 | leftAdjacent_(std::move(leftAdjacent)), |
59 | rightAdjacent_(std::move(rightAdjacent)), | 112 | rightAdjacent_(std::move(rightAdjacent)), |
60 | upAdjacent_(std::move(upAdjacent)), | 113 | upAdjacent_(std::move(upAdjacent)), |
61 | downAdjacent_(std::move(downAdjacent)) | 114 | downAdjacent_(std::move(downAdjacent)), |
115 | objects_(std::move(objects)) | ||
62 | { | 116 | { |
63 | } | 117 | } |
64 | 118 | ||
@@ -97,6 +151,11 @@ public: | |||
97 | return downAdjacent_; | 151 | return downAdjacent_; |
98 | } | 152 | } |
99 | 153 | ||
154 | inline const object_storage_type& getObjects() const | ||
155 | { | ||
156 | return objects_; | ||
157 | } | ||
158 | |||
100 | private: | 159 | private: |
101 | 160 | ||
102 | int id_; | 161 | int id_; |
@@ -106,6 +165,7 @@ private: | |||
106 | Adjacent rightAdjacent_; | 165 | Adjacent rightAdjacent_; |
107 | Adjacent upAdjacent_; | 166 | Adjacent upAdjacent_; |
108 | Adjacent downAdjacent_; | 167 | Adjacent downAdjacent_; |
168 | object_storage_type objects_; | ||
109 | }; | 169 | }; |
110 | 170 | ||
111 | #endif /* end of include guard: MAP_H_74055FC0 */ | 171 | #endif /* end of include guard: MAP_H_74055FC0 */ |