aboutsummaryrefslogtreecommitdiff
path: root/src/item.h
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-04-15 15:23:23 -0400
committerYour Name <you@example.com>2021-04-15 15:23:23 -0400
commitdfce4d0398a8bafbb7ad7a31345af181c0269c09 (patch)
tree695162ff8cc25e146f52d9e26fe19ffa9934b3d6 /src/item.h
parent9034c3d2533177f7cb7a7ce939ec53f7fa63f60e (diff)
downloaddmtool-dfce4d0398a8bafbb7ad7a31345af181c0269c09.tar.gz
dmtool-dfce4d0398a8bafbb7ad7a31345af181c0269c09.tar.bz2
dmtool-dfce4d0398a8bafbb7ad7a31345af181c0269c09.zip
Added spells
Diffstat (limited to 'src/item.h')
-rw-r--r--src/item.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/item.h b/src/item.h
index f8b2c87..a415947 100644
--- a/src/item.h
+++ b/src/item.h
@@ -3,25 +3,31 @@
#include "jsonable.h"
#include <memory>
-namespace item{
+namespace item {
class Item : public Jsonable {
public:
static std::shared_ptr<Item> create(const nlohmann::json& data);
- virtual ~Item();
+ virtual ~Item() {}
- virtual std::string getName(void) const;
- virtual int getCost(void) const;
- virtual double getWeight(void) const;
+ std::string getName(void) const {return name;}
+ std::string getType(void) const {return type;}
+ virtual std::string getText(void) const {return text;}
- virtual nlohmann::json toJson(void) const;
+ virtual nlohmann::json toJson(void) const {
+ return nlohmann::json({
+ {"name", name},
+ {"type", type},
+ {"text", text}
+ });
+ }
protected:
- Item(const nlohmann::json& data);
+ Item(const nlohmann::json& data) : name(data["name"]), type(data["type"]), text(data["text"]) {};
private:
const std::string name;
- const int cost;
- const double weight;
+ const std::string type;
+ const std::string text;
};
}