aboutsummaryrefslogtreecommitdiff
path: root/src/features/feature.cc
blob: 0fd2d6c2633485cefcbb0fd9c99f9618e8ebe103 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "feature.h"
#include "../spellcasting.h"
#include "../attack.h"
#include "../utils.h"
#include <nlohmann/json.hpp>
#include <memory>

using namespace std;

namespace entry {
    shared_ptr<Feature> Feature::create(const nlohmann::json& data) {
        if(data["type"] == "spells") {
            return utils::loadDFromJson<Feature, Spellcasting>(data);
        } else if(data["type"] == "attack") {
            return utils::loadDFromJson<Feature, Attack>(data);
        }
        return shared_ptr<Feature>(new Feature(data));
    }
}