diff options
author | Your Name <you@example.com> | 2021-04-16 11:23:27 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-04-16 11:23:27 -0400 |
commit | 4618763c0e3a723bf4bb43c7b9edbce87240e0af (patch) | |
tree | a18aa4bf7da05ac02b4e37b199aeeb82da977aea /src/entry.h | |
parent | dfce4d0398a8bafbb7ad7a31345af181c0269c09 (diff) | |
download | dmtool-4618763c0e3a723bf4bb43c7b9edbce87240e0af.tar.gz dmtool-4618763c0e3a723bf4bb43c7b9edbce87240e0af.tar.bz2 dmtool-4618763c0e3a723bf4bb43c7b9edbce87240e0af.zip |
Rebased feature/item on entry
Diffstat (limited to 'src/entry.h')
-rw-r--r-- | src/entry.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/entry.h b/src/entry.h new file mode 100644 index 0000000..20f38e0 --- /dev/null +++ b/src/entry.h @@ -0,0 +1,39 @@ +#pragma once +#include "json.hpp" +#include "jsonable.h" +#include <memory> + +namespace creature { + class Creature; +} + +namespace entry { + class Entry : public Jsonable { + public: + virtual ~Entry() {} + + std::string getName(void) const {return name;} + std::string getType(void) const {return type;} + std::string getText(void) const {return text;} + virtual std::string getText(const creature::Creature& c) const; + + virtual nlohmann::json toJson(void) const { + return nlohmann::json({ + {"name", name}, + {"type", type}, + {"text", text} + }); + } + + protected: + Entry(const nlohmann::json& data) : name(data["name"]), type(data["type"]), text(data["text"]) {}; + + private: + const std::string name; + const std::string type; + const std::string text; + }; + + // Set up default text generation + std::string genText(const Entry& e, const creature::Creature& c); +} |