blob: f602be2153b06f0c14fe9aba9bac14f2737698aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "json.hpp"
#include "item.h"
#include "weapon.h"
#include "armor.h"
#include "utils.h"
#include <iostream>
#include <memory>
using namespace std;
typedef nlohmann::json json;
namespace item {
shared_ptr<Item> Item::create(const json& data) {
if(data["type"] == "weapon") {
return utils::loadDFromJson<Item, Weapon>(data);
} else if(data["type"] == "armor") {
return utils::loadDFromJson<Item, Armor>(data);
}
return shared_ptr<Item>(new Item(data));
}
}
|