#include "entry.h" #include "utils.h" #include "feature.h" #include "item.h" #include "spell.h" #include "creature.h" #include namespace entry { // Returns either a feature, an item, a creature, or a spell std::shared_ptr Entry::create(const nlohmann::json& data) { if(data["entry"] == "feature") { return Feature::create(data); } else if(data["entry"] == "item") { return Item::create(data); } else if(data["entry"] == "creatures") { return utils::loadDFromJson(data); } else if(data["entry"] == "spells") { return utils::loadDFromJson(data); } throw std::invalid_argument("Invalid entry: " + std::string(data["entry"])); } }