diff options
Diffstat (limited to 'src/item.cc')
-rw-r--r-- | src/item.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/item.cc b/src/item.cc index 6c91206..3691c28 100644 --- a/src/item.cc +++ b/src/item.cc @@ -12,7 +12,7 @@ typedef nlohmann::json json; namespace entry { shared_ptr<Item> Item::create(const json& data) { - if(data["type"] == "weapon") { + if(data["type"] == "weapons") { return utils::loadDFromJson<Item, Weapon>(data); } else if(data["type"] == "armor") { return utils::loadDFromJson<Item, Armor>(data); @@ -22,8 +22,18 @@ namespace entry { string genText(const Substantial& s) { stringstream text; - text << "Cost: " << s.getCost() << " cp, i.e., " << utils::getCostString(s.getCost()); - text << ". Weight: " << s.getWeight() << " lbs."; + 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(); } } |