#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"] == "creature") { return utils::loadDFromJson(data); } else if(data["entry"] == "spell") { return utils::loadDFromJson(data); } throw std::invalid_argument("Invalid entry: " + std::string(data["entry"])); } std::string genText(const Entry& e, const creature::Creature& c) { return e.getName() + " (" + e.getType() + ")"; } }