aboutsummaryrefslogtreecommitdiff
path: root/src/attack.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/attack.h
parentd13358b71ec15085f2638fd9c3fc634df62dfc94 (diff)
downloaddmtool-e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd.tar.gz
dmtool-e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd.tar.bz2
dmtool-e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd.zip
Code refactoring
Diffstat (limited to 'src/attack.h')
-rw-r--r--src/attack.h16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/attack.h b/src/attack.h
index 0a9ad68..2e4125b 100644
--- a/src/attack.h
+++ b/src/attack.h
@@ -1,10 +1,7 @@
#pragma once
#include "feature.h"
-#include "json.hpp"
#include "weapon.h"
-typedef nlohmann::json json;
-
namespace creature {
class Creature;
}
@@ -12,19 +9,14 @@ namespace creature {
namespace entry {
class Attack : public Feature {
public:
- Attack(const json& data, const json& base): Feature(base), weapon(data["attack"], data["attack"]) {}
virtual ~Attack() {}
- virtual std::string getText(const creature::Creature& c) const override {return weapon.getText(c) + " " + Entry::getText();}
- Weapon getWeapon(void) {return weapon;}
+ virtual std::string getText(const creature::Creature& c) const override {return getWeapon().getText(c) + " " + Entry::getText();}
+ Weapon getWeapon(void) const {return attack;}
- json toJson(void) const {
- auto data = Feature::toJson();
- data["attack"] = weapon.toJson();
- return data;
- }
+ NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Feature, Attack, attack);
private:
- const Weapon weapon;
+ Weapon attack;
};
}