#pragma once #include "json.hpp" #include "jsonable.h" #include namespace creature { class Creature; } namespace entry { class Entry; class Entry : public Jsonable { public: static std::shared_ptr create(const nlohmann::json& data); virtual ~Entry() {} std::string getName(void) const {return name;} std::string getType(void) const {return type;} virtual std::string getText(void) const {return text;} void setText(std::string t) {text = t;} virtual std::string getText(const creature::Creature& c) const { return getName() + " (" + getType() + "): " + getText(); } virtual nlohmann::json toJson(void) const { return nlohmann::json({ {"entry", entry}, {"name", name}, {"type", type}, {"text", text} }); } protected: Entry(const nlohmann::json& data) : Entry(data["entry"], data["name"], data["type"], data["text"]) {}; // Can also be instantiated programmatically Entry(const std::string& entry, const std::string& name, const std::string& type, const std::string& text) : entry(entry), name(name), type(type), text(text) {}; private: const std::string entry; const std::string name; const std::string type; std::string text; }; }