blob: aa3b3e8ccd2da0eb20e00c2e4bf73c43fa2f4185 (
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
40
41
42
43
44
45
46
47
|
#pragma once
#include "feature.h"
#include "spell.h"
#include "rules.h"
#include "utils.h"
#include <memory>
#include <nlohmann/json.hpp>
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<std::shared_ptr<Spell>> spells;
static std::shared_ptr<SlotLevel> create(const nlohmann::json& data);
nlohmann::json serialize() {
nlohmann::json ret;
to_json(ret, *this);
return ret;
}
};
class Spellcasting : public Feature {
public:
Spellcasting() : Feature("spellcasting", "spells", ""), innate(false), spellcasting_ability("int") {}
bool isInnate(void) const {return innate;}
rules::Ability getAbility(void) const {return spellcasting_ability;}
void setAbility(const rules::Ability& ability) {spellcasting_ability = ability;}
const std::vector<std::shared_ptr<SlotLevel>>& getSlotLevels(void) const {return levels;}
void addSlotLevel(void) {levels.push_back(std::shared_ptr<SlotLevel>(new SlotLevel()));}
std::vector<std::shared_ptr<Spell>> 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<std::shared_ptr<SlotLevel>> levels;
};
}
|