aboutsummaryrefslogtreecommitdiff
path: root/src/entry.h
blob: 56fc884d5f378c227f740b9ebac2eda1fcb61428 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include "defines.h"
#include <nlohmann/json.hpp>
#include <memory>

namespace creature {
    class Creature;
}

namespace entry {
    class Entry {
        public:
            static std::shared_ptr<Entry> 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;
    };
}