From e044fc4255aa64ef1dbc3d20ed87ed6e2f61a6bd Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 9 May 2021 19:01:59 -0400 Subject: Code refactoring --- src/attack.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/attack.h') 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; }; } -- cgit v1.2.3