From 7b5d1e3d46e94262a9c0fd3a01ab4685aea9d12d Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 1 May 2021 15:10:54 -0400 Subject: Added bash completion, amongst others --- src/item.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/item.cc') 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::create(const json& data) { - if(data["type"] == "weapon") { + if(data["type"] == "weapons") { return utils::loadDFromJson(data); } else if(data["type"] == "armor") { return utils::loadDFromJson(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(); } } -- cgit v1.2.3