diff options
author | Your Name <you@example.com> | 2021-05-19 18:00:16 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-05-19 18:00:16 -0400 |
commit | be88609c825e18201f240415fe74a31c1a789484 (patch) | |
tree | 8b051262fcd9e1388ba45f14369112d3d9fb0d52 /src/creature.h | |
parent | 38e33d8756a5b652965be8ada478b5c4238b857c (diff) | |
download | dmtool-be88609c825e18201f240415fe74a31c1a789484.tar.gz dmtool-be88609c825e18201f240415fe74a31c1a789484.tar.bz2 dmtool-be88609c825e18201f240415fe74a31c1a789484.zip |
Added git command; refactoring
Diffstat (limited to 'src/creature.h')
-rw-r--r-- | src/creature.h | 78 |
1 files changed, 26 insertions, 52 deletions
diff --git a/src/creature.h b/src/creature.h index b2a01e6..c343482 100644 --- a/src/creature.h +++ b/src/creature.h @@ -4,7 +4,6 @@ #include "entry.h" #include "feature.h" #include "item.h" -#include <cmath> #include <nlohmann/json.hpp> namespace entry { @@ -16,6 +15,7 @@ namespace entry { namespace creature { class Creature; + struct creatureImpl; struct dmgType { std::string type; @@ -40,6 +40,7 @@ namespace creature { class Creature : public entry::Entry { public: + Creature(); virtual ~Creature() {} virtual void init() override; @@ -49,41 +50,37 @@ namespace creature { int getAbilitySaveBonus(const rules::Ability& ability) const; std::map<rules::Skill, int> getSkills(void) const; std::map<rules::Ability, int> getSaves(void) const; - //Override getText virtual std::string getText() const override; - - // Inline getters - std::string getCreatureName(void) const {return getName();} - std::string getGivenName(void) const {return givenName;} - std::string getSize(void) const {return size;} - std::string getAlignment(void) const {return alignment;} - double getCR(void) const {return cr;} - NatArmor getNaturalArmor(void) const {return natural_armor;} - std::string getLanguages(void) const {return langs;} - int getHP(void) const {return hp;} - int getHPMax(void) const {return hpMax;} - std::vector<std::string> getSenses(void) const {return senses;} - std::string getSpeed(void) const {return speed;} - int getScore(const rules::Ability& ability) const {return stats.at(ability);} - int getBonus(const rules::Ability& ability) const {return std::floor((getScore(ability) - 10) / 2.0);} - int getProficiency(void) const {return prof;} - std::vector<std::shared_ptr<entry::Feature>> getFeatures(void) const {return features;} + std::string getCreatureName(void) const; + std::string getGivenName(void) const; + std::string getSize(void) const; + std::string getAlignment(void) const; + double getCR(void) const; + NatArmor getNaturalArmor(void) const; + std::string getLanguages(void) const; + int getHP(void) const; + int getHPMax(void) const; + std::vector<std::string> getSenses(void) const; + std::string getSpeed(void) const; + int getScore(const rules::Ability& ability) const; + int getBonus(const rules::Ability& ability) const; + int getProficiency(void) const; + std::vector<std::shared_ptr<entry::Feature>> getFeatures(void) const; std::shared_ptr<entry::Spellcasting> getSpellcasting(void) const; - std::vector<std::shared_ptr<entry::Item>> getInventory(void) const {return inventory;} - std::vector<dmgType> getDmgImmunities(void) const {return d_immunities;} - std::vector<dmgType> getDmgResistances(void) const {return d_resistances;} - std::vector<dmgType> getDmgVulnerabilities(void) const {return d_vulnerabilities;} - std::vector<dmgType> getCondImmunities(void) const {return c_immunities;} - + std::vector<std::shared_ptr<entry::Item>> getInventory(void) const; + std::vector<dmgType> getDmgImmunities(void) const; + std::vector<dmgType> getDmgResistances(void) const; + std::vector<dmgType> getDmgVulnerabilities(void) const; + std::vector<dmgType> getCondImmunities(void) const; // Setters (mutators) - void setGivenName(std::string name) {givenName = name;} + void setGivenName(const std::string& name); void applyDamage(int amount, const std::string& type, const std::vector<rules::Qualifier>& qualifiers); void applyHealing(int amount); void setScore(const rules::Ability& ability, int score); void setProfLevel(const rules::Skill& skill, int level); - void setProficiency(int p) {prof = p;} + void setProficiency(int p); void addInventoryItem(std::shared_ptr<entry::Item> item); void addSpellcasting(void); void addSpell(std::shared_ptr<entry::Spell> spell); @@ -91,33 +88,10 @@ namespace creature { void removeInventoryItem(std::shared_ptr<entry::Item> item); void longRest(void); - 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); + NLOHMANN_FRIEND_DECLARES(Creature); private: - std::string givenName; - int hpMax; - int hp; - std::vector<std::shared_ptr<entry::Item>> inventory; - std::map<rules::Ability, int> stats; - std::map<rules::Skill, int> skills; - int prof; - std::string size; - std::string alignment; - int hit_die_count; - int hit_die_sides; - std::string speed; - std::vector<rules::Ability> saves; - std::vector<std::string> senses; - std::string langs; - double cr; - bool observant; - NatArmor natural_armor; - std::vector<dmgType> d_immunities; - std::vector<dmgType> d_resistances; - std::vector<dmgType> d_vulnerabilities; - std::vector<dmgType> c_immunities; - std::vector<std::shared_ptr<entry::Feature>> features; - + std::shared_ptr<creatureImpl> data; }; // Helper function to get all attacks (weapons and pseudo-weapons included) |