aboutsummaryrefslogtreecommitdiff
path: root/src/spell.h
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-05-09 19:01:59 -0400
committerYour Name <you@example.com>2021-05-09 19:01:59 -0400
commite044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd (patch)
tree344c09421c5839a764a132fe9166f0e6e3f90e45 /src/spell.h
parentd13358b71ec15085f2638fd9c3fc634df62dfc94 (diff)
downloaddmtool-e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd.tar.gz
dmtool-e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd.tar.bz2
dmtool-e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd.zip
Code refactoring
Diffstat (limited to 'src/spell.h')
-rw-r--r--src/spell.h35
1 files changed, 11 insertions, 24 deletions
diff --git a/src/spell.h b/src/spell.h
index 31b7d72..1a560f2 100644
--- a/src/spell.h
+++ b/src/spell.h
@@ -1,44 +1,31 @@
#pragma once
-#include "json.hpp"
#include "entry.h"
+#include <nlohmann/json.hpp>
namespace entry {
class Spell : public Entry {
public:
- Spell(const nlohmann::json& data, const nlohmann::json& base) : Entry(base), level(data["level"]), classes(data["classes"]), castingTime(data["casting_time"]), range(data["range"]), components(data["components"]), duration(data["duration"]) {};
- virtual ~Spell() {};
+ Spell() {}
+ virtual ~Spell() {}
- //std::string getName(void) const {return name;}
int getLevel(void) const {return level;}
std::string getSchool(void) const {return getType();}
std::vector<std::string> getClasses(void) const {return classes;}
- std::string getCastingTime(void) const {return castingTime;}
+ std::string getCastingTime(void) const {return casting_time;}
std::string getRange(void) const {return range;}
std::string getComponents(void) const {return components;}
std::string getDuration(void) const {return duration;}
std::string getText(void) const override;
- virtual nlohmann::json toJson(void) const {
- auto data = Entry::toJson();
- data["level"] = level;
- data["classes"] = classes;
- data["casting_time"] = castingTime;
- data["range"] = range;
- data["components"] = components;
- data["duration"] = duration;
- return data;
- }
+ NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Entry, Spell, level, classes, casting_time, range, components, duration);
private:
- //const std::string name;
- const int level;
- //const std::string school;
- const std::vector<std::string> classes;
- const std::string castingTime;
- const std::string range;
- const std::string components;
- const std::string duration;
- //const std::string text;
+ int level;
+ std::vector<std::string> classes;
+ std::string casting_time;
+ std::string range;
+ std::string components;
+ std::string duration;
};
}