#pragma once #include "defines.h" #include #include namespace creature { class Creature; } namespace entry { class Entry { public: Entry() {} // Also can be created 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) {} 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 void init(void) {} virtual nlohmann::json serialize(void) const { nlohmann::json ret; to_json(ret, *this); return ret; } virtual std::string getText(const creature::Creature& c) const { return getName() + " (" + getType() + "): " + getText(); } NLOHMANN_DEFINE_TYPE_INTRUSIVE(Entry, entry, name, type, text); private: std::string entry; std::string name; std::string type; std::string text; }; }