Wip: working on add scenery

This commit is contained in:
Timothy O'Barr
2026-09-01 16:27:01 -05:00
parent 15f0e369b2
commit 668d416256
7 changed files with 138 additions and 71 deletions
+6 -3
View File
@@ -10,11 +10,12 @@ Room::Room() {
exits.clear();
}
Room::Room(int id, std::string n, std::string desc, std::vector<Exit> e) {
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(const Room &r) {
@@ -67,8 +68,10 @@ void from_json(const json &j, Room &r) {
j.at("name").get_to(r.name);
j.at("description").get_to(r.description);
j.at("exits").get_to(r.exits);
j.at("scenery").get_to(r.scenery);
}
void to_json(nlohmann::json &j, const Room &r) {
j = json{{"id", r.id}, {"name", r.name}, {"description", r.description}, {"exits", r.exits}};
void to_json(json &j, const Room &r) {
j = json{
{"id", r.id}, {"name", r.name}, {"description", r.description}, {"exits", r.exits}, {"scenery", r.scenery}};
}
+31 -20
View File
@@ -1,29 +1,40 @@
#include "scenery.h"
Scenery::Scenery()
{
type = ObjectType::SCENERY;
name = "Scenery";
containsItem = false;
Scenery::Scenery() {
type = ObjectType::SCENERY;
name = "Scenery";
}
void Scenery::Interact()
{
if (containsItem)
{
// Give Item
}
Examine();
Scenery::Scenery(int i, std::string n, std::string desc, std::vector<std::string> k, ObjectType t, bool cT, int rID) {
id = i;
name = std::move(n);
description = std::move(desc);
keywords = std::move(k);
type = t;
canTake = cT;
roomIdItBelongsTo = rID;
}
void Scenery::Examine()
{
printf("%s\n", GetDescription().data());
void Scenery::Interact() { Examine(); }
void Scenery::Examine() { printf("%s\n", GetDescription().data()); }
void from_json(const json &j, Scenery &s) {
j.at("id").get_to(s.id);
j.at("name").get_to(s.name);
j.at("description").get_to(s.description);
j.at("keywords").get_to(s.keywords);
j.at("type").get_to(s.type);
j.at("canTake").get_to(s.canTake);
j.at("roomIdItBelongsTo").get_to(s.roomIdItBelongsTo);
}
Scenery::~Scenery()
{
type = ObjectType::NONE;
name = "";
keywords.clear();
void to_json(json &j, const Scenery &s) {
j = json{{"id", s.id},
{"name", s.name},
{"description", s.description},
{"keywords", s.keywords},
{"type", s.type},
{"canTake", s.canTake},
{"roomIdItBelongsTo", s.roomIdItBelongsTo}};
}