diff options
author | Your Name <you@example.com> | 2021-05-01 15:10:54 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-05-01 15:10:54 -0400 |
commit | 7b5d1e3d46e94262a9c0fd3a01ab4685aea9d12d (patch) | |
tree | d9b808542216f71dbab053ad23145903e96c6401 /src/item.cc | |
parent | 5a813a75412ac9b8fadb90c9abd46dd95aee8e9b (diff) | |
download | dmtool-7b5d1e3d46e94262a9c0fd3a01ab4685aea9d12d.tar.gz dmtool-7b5d1e3d46e94262a9c0fd3a01ab4685aea9d12d.tar.bz2 dmtool-7b5d1e3d46e94262a9c0fd3a01ab4685aea9d12d.zip |
Added bash completion, amongst others
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(); } } |