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/creature.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/creature.h') diff --git a/src/creature.h b/src/creature.h index 6e0d226..c6697ce 100644 --- a/src/creature.h +++ b/src/creature.h @@ -1,21 +1,19 @@ #pragma once -#include "json.hpp" #include "rules.h" #include "utils.h" #include "entry.h" +#include "feature.h" +#include "item.h" #include +#include namespace entry { - class Feature; - class Item; class Weapon; class Attack; class Spell; class Spellcasting; } -typedef nlohmann::json json; - namespace creature { class Creature; @@ -42,8 +40,9 @@ namespace creature { class Creature : public entry::Entry { public: - Creature(const json& data, const json& base); - virtual ~Creature() {}; + virtual ~Creature() {} + + virtual void init() override; // Getters int getSkillBonus(const rules::Skill& skill) const; @@ -91,10 +90,9 @@ namespace creature { void removeInventoryItem(std::shared_ptr item); void longRest(void); - virtual json toJson(void) const; + NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Entry, Creature, givenName, hpMax, hp, inventory, stats, skills, prof, size, alignment, hit_die_count, hit_die_sides, speed, saves, senses, langs, cr, observant, natural_armor, d_immunities, d_resistances, d_vulnerabilities, c_immunities, features); private: - std::string givenName; int hpMax; int hp; -- cgit v1.2.3