#include "item.h" #include "weapon.h" #include "armor.h" #include "utils.h" #include #include #include #include using namespace std; namespace entry { shared_ptr Item::create(const nlohmann::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 Substantial::getText() const { stringstream text; if(getCost() >= 0) { text << "Cost: "; string costStr = to_string(getCost()) + " cp"; text << costStr; string condensedCostStr = utils::getCostString(getCost()); if(costStr != condensedCostStr) { text << ", i.e., " << condensedCostStr; } } if(getWeight() >= 0) { text << ". Weight: " << getWeight() << " lbs."; } return text.str(); } }