From b27700a7e0b281ece3dea23060c17e0cae28715d Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 20 May 2021 17:00:53 -0400 Subject: Reduced exposure of implementation details --- src/weapon.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/weapon.cc') diff --git a/src/weapon.cc b/src/weapon.cc index 0c4dc29..053dbc1 100644 --- a/src/weapon.cc +++ b/src/weapon.cc @@ -9,6 +9,30 @@ using namespace std; namespace entry { + struct weaponImpl { + std::vector damage; + std::set properties; + std::string weapon_type; + std::pair range; + int reach; + int cost; + double weight; + }; + + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(weaponImpl, damage, properties, weapon_type, range, reach, cost, weight); + + NLOHMANN_FRIEND_DEFS(Item, Weapon, data); + + Weapon::Weapon() : data(new weaponImpl()) {} + + std::vector Weapon::getDamage(void) const {return data->damage;} + std::set Weapon::getProperties(void) const {return data->properties;} + std::string Weapon::getWeaponType(void) const {return data->weapon_type;} + std::pair Weapon::getRange(void) const {return data->range;} + int Weapon::getReach(void) const {return data->reach;} + int Weapon::getCost(void) const {return data->cost;} + double Weapon::getWeight(void) const {return data->weight;} + string getTextHelper(const Weapon& w, string toHitBonus, string damageBonus) { stringstream text; text << "+" << toHitBonus << " to hit, "; -- cgit v1.2.3