summary refs log tree commit diff stats
path: root/src/map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp107
1 files changed, 20 insertions, 87 deletions
diff --git a/src/map.cpp b/src/map.cpp index fa940ef..c4f31d1 100644 --- a/src/map.cpp +++ b/src/map.cpp
@@ -20,14 +20,7 @@ Map::Map(const Map& map)
20 20
21 id = map.id; 21 id = map.id;
22 title = map.title; 22 title = map.title;
23 leftMap = map.leftMap; 23 adjacents = map.adjacents;
24 rightMap = map.rightMap;
25 downMap = map.downMap;
26 upMap = map.upMap;
27 leftType = map.leftType;
28 rightType = map.rightType;
29 upType = map.upType;
30 downType = map.downType;
31 entities = map.entities; 24 entities = map.entities;
32} 25}
33 26
@@ -52,14 +45,7 @@ void swap(Map& first, Map& second)
52{ 45{
53 std::swap(first.mapdata, second.mapdata); 46 std::swap(first.mapdata, second.mapdata);
54 std::swap(first.title, second.title); 47 std::swap(first.title, second.title);
55 std::swap(first.leftMap, second.leftMap); 48 std::swap(first.adjacents, second.adjacents);
56 std::swap(first.rightMap, second.rightMap);
57 std::swap(first.downMap, second.downMap);
58 std::swap(first.upMap, second.upMap);
59 std::swap(first.leftType, second.leftType);
60 std::swap(first.rightType, second.rightType);
61 std::swap(first.upType, second.upType);
62 std::swap(first.downType, second.downType);
63 std::swap(first.id, second.id); 49 std::swap(first.id, second.id);
64 std::swap(first.entities, second.entities); 50 std::swap(first.entities, second.entities);
65} 51}
@@ -109,44 +95,24 @@ Map::MoveType Map::moveTypeForShort(std::string str)
109 return MoveType::Wall; 95 return MoveType::Wall;
110} 96}
111 97
112Map::MoveType Map::getLeftMoveType() const 98Map::MoveDir Map::moveDirForShort(std::string str)
113{ 99{
114 return leftType; 100 if (str == "right") return MoveDir::Right;
115} 101 if (str == "up") return MoveDir::Up;
116 102 if (str == "down") return MoveDir::Down;
117Map::MoveType Map::getRightMoveType() const 103
118{ 104 return MoveDir::Left;
119 return rightType;
120}
121
122Map::MoveType Map::getUpMoveType() const
123{
124 return upType;
125}
126
127Map::MoveType Map::getDownMoveType() const
128{
129 return downType;
130}
131
132int Map::getLeftMapID() const
133{
134 return leftMap;
135}
136
137int Map::getRightMapID() const
138{
139 return rightMap;
140}
141
142int Map::getUpMapID() const
143{
144 return upMap;
145} 105}
146 106
147int Map::getDownMapID() const 107static const Map::Adjacent defaultAdjacent {};
108const Map::Adjacent& Map::getAdjacent(MoveDir dir) const
148{ 109{
149 return downMap; 110 if (adjacents.count(dir) > 0)
111 {
112 return adjacents.at(dir);
113 } else {
114 return defaultAdjacent;
115 }
150} 116}
151 117
152bool Map::moveTypeTakesMap(MoveType type) 118bool Map::moveTypeTakesMap(MoveType type)
@@ -171,44 +137,11 @@ void Map::setTitle(std::string title)
171 this->title = title; 137 this->title = title;
172} 138}
173 139
174void Map::setLeftMoveType(MoveType type) 140void Map::setAdjacent(MoveDir dir, MoveType type, int map)
175{
176 leftType = type;
177}
178
179void Map::setRightMoveType(MoveType type)
180{
181 rightType = type;
182}
183
184void Map::setUpMoveType(MoveType type)
185{
186 upType = type;
187}
188
189void Map::setDownMoveType(MoveType type)
190{
191 downType = type;
192}
193
194void Map::setLeftMapID(int id)
195{
196 leftMap = id;
197}
198
199void Map::setRightMapID(int id)
200{
201 rightMap = id;
202}
203
204void Map::setUpMapID(int id)
205{
206 upMap = id;
207}
208
209void Map::setDownMapID(int id)
210{ 141{
211 downMap = id; 142 Adjacent& cur = adjacents[dir];
143 cur.type = type;
144 if (map != -1) cur.map = map;
212} 145}
213 146
214void Map::addEntity(EntityData& data) 147void Map::addEntity(EntityData& data)