aboutsummaryrefslogtreecommitdiff
path: root/src/spell.cc
blob: 83ec9da9a84a88795bb89292e034065e97d0dcf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "spell.h"
#include "utils.h"
#include <string>
#include <sstream>

using namespace std;

namespace entry {
    struct spellImpl {
        int level;
        std::vector<std::string> 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<std::string> 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();
    }
}