#include "json.hpp" #include "item.h" #include "weapon.h" #include "armor.h" #include "utils.h" #include #include #include using namespace std; typedef nlohmann::json json; namespace entry { shared_ptr Item::create(const json& data) { if(data["type"] == "weapons") { return utils::loadDFromJson(data); } else if(data["type"] == "armor") { return utils::loadDFromJson(data); } return shared_ptr(new Item(data)); } string genText(const Substantial& s) { stringstream text; if(s.getCost() >= 0) { text << "Cost: "; string costStr = to_string(s.getCost()) + " cp"; text << costStr; string condensedCostStr = utils::getCostString(s.getCost()); if(costStr != condensedCostStr) { text << ", i.e., " << condensedCostStr; } } if(s.getWeight() >= 0) { text << ". Weight: " << s.getWeight() << " lbs."; } return text.str(); } }