#pragma once #include "feature.h" #include "spell.h" #include "rules.h" #include "utils.h" #include #include typedef nlohmann::json json; namespace entry { struct SlotLevel; void to_json(nlohmann::json& j, const SlotLevel& sl); void from_json(const nlohmann::json& j, SlotLevel& sl); struct SlotLevel { SlotLevel() : numSlots(0) {} int numSlots; std::vector> spells; static std::shared_ptr create(const nlohmann::json& data); nlohmann::json serialize() { nlohmann::json ret; to_json(ret, *this); return ret; } }; class Spellcasting : public Feature { public: bool isInnate(void) const {return innate;} rules::Ability getAbility(void) const {return spellcasting_ability;} const std::vector>& getSlotLevels(void) const {return levels;} void addSlotLevel(void) {levels.push_back(std::shared_ptr(new SlotLevel()));} std::vector> getSpells(void) const; virtual std::string getText(const creature::Creature& c) const; NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Feature, Spellcasting, innate, spellcasting_ability, levels); private: bool innate; rules::Ability spellcasting_ability; std::vector> levels; }; }