aboutsummaryrefslogtreecommitdiff
path: root/src/item.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/item.cc')
-rw-r--r--src/item.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/item.cc b/src/item.cc
index 3691c28..3bb9895 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -1,4 +1,3 @@
-#include "json.hpp"
#include "item.h"
#include "weapon.h"
#include "armor.h"
@@ -6,12 +5,12 @@
#include <iostream>
#include <memory>
#include <sstream>
+#include <nlohmann/json.hpp>
using namespace std;
-typedef nlohmann::json json;
namespace entry {
- shared_ptr<Item> Item::create(const json& data) {
+ shared_ptr<Item> Item::create(const nlohmann::json& data) {
if(data["type"] == "weapons") {
return utils::loadDFromJson<Item, Weapon>(data);
} else if(data["type"] == "armor") {
@@ -20,19 +19,19 @@ namespace entry {
return shared_ptr<Item>(new Item(data));
}
- string genText(const Substantial& s) {
+ string Substantial::getText() const {
stringstream text;
- if(s.getCost() >= 0) {
+ if(getCost() >= 0) {
text << "Cost: ";
- string costStr = to_string(s.getCost()) + " cp";
+ string costStr = to_string(getCost()) + " cp";
text << costStr;
- string condensedCostStr = utils::getCostString(s.getCost());
+ string condensedCostStr = utils::getCostString(getCost());
if(costStr != condensedCostStr) {
text << ", i.e., " << condensedCostStr;
}
}
- if(s.getWeight() >= 0) {
- text << ". Weight: " << s.getWeight() << " lbs.";
+ if(getWeight() >= 0) {
+ text << ". Weight: " << getWeight() << " lbs.";
}
return text.str();
}