Fixed parsing Scenery

This commit is contained in:
Timothy O'Barr
2026-09-02 11:24:10 -05:00
parent 668d416256
commit 0e7406db96
4 changed files with 100 additions and 29 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ private:
public:
Room();
Room(int id, std::string name, std::string desc, std::vector<Exit> e, std::vector<Scenery> s);
Room(int i, std::string n, std::string desc, std::vector<Exit> e, std::vector<Scenery> s);
Room(const Room &r);
void PrintAvalibleExits();
+7 -6
View File
@@ -10,12 +10,12 @@ Room::Room() {
exits.clear();
}
Room::Room(int id, std::string n, std::string desc, std::vector<Exit> e, std::vector<Scenery> s) {
id = id;
name = n;
description = desc;
exits = e;
scenery = s;
Room::Room(int i, std::string n, std::string desc, std::vector<Exit> e, std::vector<Scenery> s) {
id = i;
name = std::move(n);
description = std::move(desc);
exits = std::move(e);
scenery = std::move(s);
}
Room::Room(const Room &r) {
@@ -23,6 +23,7 @@ Room::Room(const Room &r) {
name = r.name;
description = r.description;
exits = r.exits;
scenery = r.scenery;
}
Room::~Room() {
+77 -15
View File
@@ -1,39 +1,101 @@
[
[
{
"description": "A fascinating Room. There's ... nothing in it, neat.",
"description": "First Test Room",
"exits": [
{
"dir": 1,
"exitID": 0,
"isLocked": false
},
{
"dir": 2,
"exitID": 1,
"isLocked": false
}
],
"id": 0,
"name": "Test Room 1",
"scenery": [
{
"canTake": false,
"description": "A Grey Rock",
"id": 0,
"keywords": [
"Rock"
],
"name": "Rock",
"roomIdItBelongsTo": 0,
"type": 1
}
]
},
{
"description": "A court yard",
"exits": [
{
"dir": 3,
"exitID": 2,
"isLocked": false
},
{
"dir": 2,
"exitID": 3,
"isLocked": false
},
{
"dir": 1,
"exitID": 2,
"exitID": 4,
"isLocked": false
}
],
"id": 1,
"name": "Test Room 2",
"scenery": [
{
"canTake": false,
"description": "A fine looking Tree stands in the courtyard",
"id": 1,
"keywords": [
"Tree"
],
"name": "Tree",
"roomIdItBelongsTo": 1,
"type": 1
}
],
"id": -8528,
"name": "Test Room 1"
},
{
"description": "Another test room. What a shocker",
"exits": [],
"id": -8608,
"name": "Test Room 2"
]
}
],
[
{
"description": "Testing another column",
"exits": [],
"id": -8656,
"name": "Test Room 3"
"description": "You can hear the sound of a waterfall nearby",
"exits": [
{
"dir": 0,
"exitID": 5,
"isLocked": false
},
{
"dir": 2,
"exitID": 6,
"isLocked": false
}
],
"id": 3,
"name": "Test Room 3",
"scenery": [
{
"canTake": false,
"description": "A fine waterfall on a cliff",
"id": 3,
"keywords": [
"Waterfall"
],
"name": "Waterfall",
"roomIdItBelongsTo": 3,
"type": 1
}
]
}
]
]
+15 -7
View File
@@ -1,18 +1,20 @@
#include "game.h"
int main(int argc, char *argv[]) {
Game game; // Calls default constructor which Initializes GAME
void EditRooms() {
fs::path path("Resources/rooms.json");
std::vector<std::vector<Room>> rooms = {
std::vector<std::vector<Room>> roomDat = {
{
{
0,
"Test Room 1",
"First Test Room",
{{0, S, false}, {1, E, false}},
{{0, "Rock", "A Grey Rock", {"Rock"}, ObjectType::SCENERY, false, 0}},
{
{0, "Rock", "A Grey Rock", {"Rock"}, ObjectType::SCENERY, false, 0},
},
},
{1,
"Test Room 2",
@@ -33,19 +35,25 @@ int main(int argc, char *argv[]) {
{{5, N, false}, {6, E, false}},
{{3, "Waterfall", "A fine waterfall on a cliff", {"Waterfall"}, ObjectType::SCENERY, false, 3}}}}};
nlohmann::json j(rooms);
nlohmann::json j(roomDat);
std::fstream outFile(absolute(path), std::fstream::in | std::fstream::out | std::fstream::app);
outFile << std::setw(4) << j << std::endl;
outFile.close();
/*if (!game) {
}
int main(int argc, char *argv[]) {
Game game; // Calls default constructor which Initializes GAME
if (!game) {
game.Init();
Game::SetGameInstance(&game);
}
while (game.GetIsActive()) {
game.Run();
}*/
}
return 0;
}