#pragma once #include #include #include #include "json.hpp" using json = nlohmann::json; enum class ObjectType { ITEM, SCENERY, NONE }; class Object { protected: int id; std::string name; std::string description; std::vector keywords; ObjectType type; bool canTake; int roomIdItBelongsTo; public: virtual void Interact() = 0; std::string const GetName() { return name; } std::string const GetDescription() { return description; } ObjectType const GetObjectType() { return type; } std::vector const GetKeywords() { return keywords; } int GetId() { return id; } int GetRoomId() { return roomIdItBelongsTo; } bool CanTake() { return canTake; } virtual ~Object() = default; }; // Global/Namespace scope serialization functions inline void to_json(json &j, Object &obj) { j = json{{"id", obj.GetId()}, {"name", obj.GetName()}, {"description", obj.GetDescription()}, {"keywords", obj.GetKeywords()}, {"type", obj.GetObjectType()}, {"canTake", obj.CanTake()}, {"roomIdItBelongsTo", obj.GetRoomId()}}; }