From 2ab51e507d620c4479e07ca0ec47d22c8c66bc90 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 13 Apr 2021 15:14:34 -0400 Subject: Initial commit --- src/feature.cc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/feature.cc (limited to 'src/feature.cc') diff --git a/src/feature.cc b/src/feature.cc new file mode 100644 index 0000000..352850b --- /dev/null +++ b/src/feature.cc @@ -0,0 +1,38 @@ +#include "json.hpp" +#include "feature.h" +#include "creature.h" +#include +#include + +using namespace std; +typedef nlohmann::json json; + +namespace feature { + shared_ptr Feature::create(const json& data) { + return shared_ptr(new Feature(data)); + } + + Feature::Feature(const json& data) : name(data["name"]), type(data["type"]), text(data["text"]) {} + + Feature::~Feature() {} + + string Feature::getName() const { + return name; + } + + string Feature::getType() const { + return type; + } + + string Feature::getText() const { + return text; + } + + json Feature::toJson() const { + return json({ + {"name", name}, + {"type", type}, + {"text", text} + }); + } +} -- cgit v1.2.3