aboutsummaryrefslogtreecommitdiff
path: root/src/features
diff options
context:
space:
mode:
authorYour Name <you@example.com>2022-01-16 21:32:01 -0500
committerYour Name <you@example.com>2022-01-16 21:32:01 -0500
commitd0e356d09e30a11c1e072415a5088f829d5c0a04 (patch)
tree1e64d37b9b424cd74c30ad4c8225828c7a76874e /src/features
parent3f78a7e1647ba94129236bd2bf4fc855c109628a (diff)
downloaddmtool-d0e356d09e30a11c1e072415a5088f829d5c0a04.tar.gz
dmtool-d0e356d09e30a11c1e072415a5088f829d5c0a04.tar.bz2
dmtool-d0e356d09e30a11c1e072415a5088f829d5c0a04.zip
Worked on features
Diffstat (limited to 'src/features')
-rw-r--r--src/features/feature.cc19
-rw-r--r--src/features/feature.h14
2 files changed, 33 insertions, 0 deletions
diff --git a/src/features/feature.cc b/src/features/feature.cc
new file mode 100644
index 0000000..0fd2d6c
--- /dev/null
+++ b/src/features/feature.cc
@@ -0,0 +1,19 @@
+#include "feature.h"
+#include "../spellcasting.h"
+#include "../attack.h"
+#include "../utils.h"
+#include <nlohmann/json.hpp>
+#include <memory>
+
+using namespace std;
+
+namespace entry {
+ shared_ptr<Feature> Feature::create(const nlohmann::json& data) {
+ if(data["type"] == "spells") {
+ return utils::loadDFromJson<Feature, Spellcasting>(data);
+ } else if(data["type"] == "attack") {
+ return utils::loadDFromJson<Feature, Attack>(data);
+ }
+ return shared_ptr<Feature>(new Feature(data));
+ }
+}
diff --git a/src/features/feature.h b/src/features/feature.h
new file mode 100644
index 0000000..209a30a
--- /dev/null
+++ b/src/features/feature.h
@@ -0,0 +1,14 @@
+#pragma once
+#include <nlohmann/json.hpp>
+#include "../entry.h"
+#include <memory>
+
+namespace entry {
+ class Feature : public Entry {
+ public:
+ Feature() {}
+ Feature(const std::string& name, const std::string& type, const std::string& text) : Entry("feature", name, type, text) {}
+ static std::shared_ptr<Feature> create(const nlohmann::json& data);
+ virtual ~Feature() {}
+ };
+}