Parse Rooms and added proper room JSON
This commit is contained in:
+1
-8
@@ -20,14 +20,7 @@ bool Game::Init() {
|
||||
stream.open(absolute(filePath));
|
||||
json = nlohmann::json::parse(stream);
|
||||
|
||||
// rooms = json.get<std::vector<std::vector<Room>>>();
|
||||
auto &roomData = json["rooms"];
|
||||
for (const auto &roomCol: rooms) {
|
||||
for (const auto &roomRow: roomCol) {
|
||||
// rooms.push_back(roomRow.get<Room>());
|
||||
}
|
||||
}
|
||||
|
||||
rooms = json.get<std::vector<std::vector<Room>>>();
|
||||
player.Init();
|
||||
parser = CommandParser();
|
||||
|
||||
|
||||
+3
-5
@@ -34,18 +34,16 @@ void Room::Print() const {
|
||||
}
|
||||
|
||||
|
||||
inline void from_json(const json &j, Exit &e) {
|
||||
void from_json(const json &j, Exit &e) {
|
||||
j.at("exitID").get_to(e.exitID);
|
||||
j.at("dir").get_to(e.dir);
|
||||
j.at("isLocked").get_to(e.isLocked);
|
||||
}
|
||||
|
||||
inline void to_json(json &j, const Exit &e) {
|
||||
j = json{{"exitID", e.exitID}, {"dir", e.dir}, {"isLocked", e.isLocked}};
|
||||
}
|
||||
void to_json(json &j, const Exit &e) { j = json{{"exitID", e.exitID}, {"dir", e.dir}, {"isLocked", e.isLocked}}; }
|
||||
|
||||
|
||||
inline void from_json(const json &j, Room &r) {
|
||||
void from_json(const json &j, Room &r) {
|
||||
j.at("id").get_to(r.id);
|
||||
j.at("name").get_to(r.name);
|
||||
j.at("description").get_to(r.description);
|
||||
|
||||
Reference in New Issue
Block a user