#include "spell.h" #include "utils.h" #include #include using namespace std; namespace entry { struct spellImpl { int level; std::vector classes; std::string casting_time; std::string range; std::string components; std::string duration; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(spellImpl, level, classes, casting_time, range, components, duration); NLOHMANN_FRIEND_DEFS(Entry, Spell, data); Spell::Spell() : data(new spellImpl()) {} int Spell::getLevel(void) const {return data->level;} std::string Spell::getSchool(void) const {return getType();} std::vector Spell::getClasses(void) const {return data->classes;} std::string Spell::getCastingTime(void) const {return data->casting_time;} std::string Spell::getRange(void) const {return data->range;} std::string Spell::getComponents(void) const {return data->components;} std::string Spell::getDuration(void) const {return data->duration;} string Spell::getText() const { stringstream text; text << utils::toOrdinal(getLevel()) << " level " << getSchool() << " spell." << endl; text << "Casting time: " << getCastingTime() << ", Duration: " << getDuration() << ", Range: " << getRange() << ", Components: " << getComponents() << "." << endl; text << Entry::getText() << endl; text << "Available for: " << utils::join(getClasses(), ", ") << "." << endl; return text.str(); } }