diff options
Diffstat (limited to 'src/map.h')
-rw-r--r-- | src/map.h | 99 |
1 files changed, 37 insertions, 62 deletions
diff --git a/src/map.h b/src/map.h index 22333aa..9177870 100644 --- a/src/map.h +++ b/src/map.h | |||
@@ -1,70 +1,45 @@ | |||
1 | #ifndef MAP_H | 1 | #ifndef MAP_H_74055FC0 |
2 | #define MAP_H | 2 | #define MAP_H_74055FC0 |
3 | 3 | ||
4 | #include <vector> | ||
4 | #include <string> | 5 | #include <string> |
5 | #include <list> | 6 | #include <list> |
7 | #include <stdexcept> | ||
6 | #include <map> | 8 | #include <map> |
7 | 9 | ||
8 | class Entity; | ||
9 | |||
10 | class Map { | 10 | class Map { |
11 | public: | 11 | public: |
12 | Map(int id); | 12 | |
13 | Map() : Map(-1) {} | 13 | Map( |
14 | Map(const Map& map); | 14 | int id, |
15 | Map(Map&& map); | 15 | std::vector<int> tiles, |
16 | ~Map(); | 16 | std::string title) : |
17 | Map& operator= (Map other); | 17 | id_(id), |
18 | friend void swap(Map& first, Map& second); | 18 | tiles_(std::move(tiles)), |
19 | 19 | title_(std::move(title)) | |
20 | enum class MoveType { | 20 | { |
21 | Wall, | 21 | } |
22 | Wrap, | 22 | |
23 | Warp, | 23 | inline size_t getId() const |
24 | ReverseWarp | 24 | { |
25 | }; | 25 | return id_; |
26 | 26 | } | |
27 | enum class MoveDir { | 27 | |
28 | Left, | 28 | inline const std::vector<int>& getTiles() const |
29 | Right, | 29 | { |
30 | Up, | 30 | return tiles_; |
31 | Down | 31 | } |
32 | }; | 32 | |
33 | 33 | inline const std::string& getTitle() const | |
34 | struct EntityData { | 34 | { |
35 | std::string name; | 35 | return title_; |
36 | std::pair<int, int> position; | 36 | } |
37 | std::map<std::string, int> items; | 37 | |
38 | }; | 38 | private: |
39 | 39 | ||
40 | struct Adjacent { | 40 | int id_; |
41 | MoveType type = MoveType::Wall; | 41 | std::vector<int> tiles_; |
42 | int map = -1; | 42 | std::string title_; |
43 | }; | ||
44 | |||
45 | static MoveType moveTypeForShort(std::string str); | ||
46 | static MoveDir moveDirForShort(std::string str); | ||
47 | static bool moveTypeTakesMap(MoveType type); | ||
48 | |||
49 | int getID() const; | ||
50 | const int* getMapdata() const; | ||
51 | std::string getTitle() const; | ||
52 | const Adjacent& getAdjacent(MoveDir dir) const; | ||
53 | |||
54 | void createEntities(std::list<std::shared_ptr<Entity>>& entities) const; | ||
55 | bool operator==(const Map& other) const; | ||
56 | bool operator!=(const Map& other) const; | ||
57 | |||
58 | void setMapdata(int* mapdata); | ||
59 | void setTitle(std::string title); | ||
60 | void setAdjacent(MoveDir dir, MoveType type, int map); | ||
61 | void addEntity(EntityData& data); | ||
62 | private: | ||
63 | int* mapdata; | ||
64 | std::string title; | ||
65 | int id; | ||
66 | std::list<EntityData> entities; | ||
67 | std::map<MoveDir, Adjacent> adjacents; | ||
68 | }; | 43 | }; |
69 | 44 | ||
70 | #endif | 45 | #endif /* end of include guard: MAP_H_74055FC0 */ |