diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-18 18:23:54 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-18 18:23:54 -0400 |
commit | 103587c2d5f9deb20e549a86cdf5023b429cc6a1 (patch) | |
tree | f1e2fc60b86395e0cc40646ad1e4396a835b682f /src/map.h | |
parent | 2ec163612042bfa5e4e1bf220b489506f7039677 (diff) | |
download | therapy-103587c2d5f9deb20e549a86cdf5023b429cc6a1.tar.gz therapy-103587c2d5f9deb20e549a86cdf5023b429cc6a1.tar.bz2 therapy-103587c2d5f9deb20e549a86cdf5023b429cc6a1.zip |
Wrote an XML Schema describing maps file and also changed the spec a bit
Diffstat (limited to 'src/map.h')
-rw-r--r-- | src/map.h | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/map.h b/src/map.h index 1234dbb..4e661ab 100644 --- a/src/map.h +++ b/src/map.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <string> | 4 | #include <string> |
5 | #include <list> | 5 | #include <list> |
6 | #include <map> | ||
6 | 7 | ||
7 | class Entity; | 8 | class Entity; |
8 | 9 | ||
@@ -23,25 +24,31 @@ class Map { | |||
23 | ReverseWarp | 24 | ReverseWarp |
24 | }; | 25 | }; |
25 | 26 | ||
27 | enum class MoveDir { | ||
28 | Left, | ||
29 | Right, | ||
30 | Up, | ||
31 | Down | ||
32 | }; | ||
33 | |||
26 | struct EntityData { | 34 | struct EntityData { |
27 | std::string name; | 35 | std::string name; |
28 | std::pair<int, int> position; | 36 | std::pair<int, int> position; |
29 | }; | 37 | }; |
30 | 38 | ||
39 | struct Adjacent { | ||
40 | MoveType type = MoveType::Wall; | ||
41 | int map = -1; | ||
42 | }; | ||
43 | |||
31 | static MoveType moveTypeForShort(std::string str); | 44 | static MoveType moveTypeForShort(std::string str); |
45 | static MoveDir moveDirForShort(std::string str); | ||
32 | static bool moveTypeTakesMap(MoveType type); | 46 | static bool moveTypeTakesMap(MoveType type); |
33 | 47 | ||
34 | int getID() const; | 48 | int getID() const; |
35 | const int* getMapdata() const; | 49 | const int* getMapdata() const; |
36 | std::string getTitle() const; | 50 | std::string getTitle() const; |
37 | MoveType getLeftMoveType() const; | 51 | const Adjacent& getAdjacent(MoveDir dir) const; |
38 | MoveType getRightMoveType() const; | ||
39 | MoveType getUpMoveType() const; | ||
40 | MoveType getDownMoveType() const; | ||
41 | int getLeftMapID() const; | ||
42 | int getRightMapID() const; | ||
43 | int getUpMapID() const; | ||
44 | int getDownMapID() const; | ||
45 | 52 | ||
46 | void createEntities(std::list<std::shared_ptr<Entity>>& entities) const; | 53 | void createEntities(std::list<std::shared_ptr<Entity>>& entities) const; |
47 | bool operator==(const Map& other) const; | 54 | bool operator==(const Map& other) const; |
@@ -49,22 +56,14 @@ class Map { | |||
49 | 56 | ||
50 | void setMapdata(int* mapdata); | 57 | void setMapdata(int* mapdata); |
51 | void setTitle(std::string title); | 58 | void setTitle(std::string title); |
52 | void setLeftMoveType(MoveType type); | 59 | void setAdjacent(MoveDir dir, MoveType type, int map); |
53 | void setRightMoveType(MoveType type); | ||
54 | void setUpMoveType(MoveType type); | ||
55 | void setDownMoveType(MoveType type); | ||
56 | void setLeftMapID(int id); | ||
57 | void setRightMapID(int id); | ||
58 | void setUpMapID(int id); | ||
59 | void setDownMapID(int id); | ||
60 | void addEntity(EntityData& data); | 60 | void addEntity(EntityData& data); |
61 | private: | 61 | private: |
62 | int* mapdata; | 62 | int* mapdata; |
63 | std::string title; | 63 | std::string title; |
64 | int id; | 64 | int id; |
65 | std::list<EntityData> entities; | 65 | std::list<EntityData> entities; |
66 | MoveType leftType, rightType, upType, downType; | 66 | std::map<MoveDir, Adjacent> adjacents; |
67 | int leftMap, rightMap, upMap, downMap; | ||
68 | }; | 67 | }; |
69 | 68 | ||
70 | #endif | 69 | #endif |