1+ #ifndef CREATURE_H
2+ #define CREATURE_H
3+
4+ #include < nlohmann/json.hpp>
5+
6+ #include < optional>
7+ #include < regex>
8+ #include < stdexcept>
9+
10+ class CreatureElement {
11+ public:
12+ CreatureElement () = default ;
13+ virtual ~CreatureElement () = default ;
14+
15+ private:
16+ std::optional<std::string> name;
17+ std::optional<std::string> meta;
18+ std::optional<std::string> armor_class;
19+ std::optional<std::string> hit_points;
20+ std::optional<std::string> speed;
21+ std::optional<std::string> str;
22+ std::optional<std::string> str_mod;
23+ std::optional<std::string> dex;
24+ std::optional<std::string> dex_mod;
25+ std::optional<std::string> con;
26+ std::optional<std::string> con_mod;
27+ std::optional<std::string> creature_int;
28+ std::optional<std::string> int_mod;
29+ std::optional<std::string> wis;
30+ std::optional<std::string> wis_mod;
31+ std::optional<std::string> cha;
32+ std::optional<std::string> cha_mod;
33+ std::optional<std::string> saving_throws;
34+ std::optional<std::string> skills;
35+ std::optional<std::string> senses;
36+ std::optional<std::string> languages;
37+ std::optional<std::string> challenge;
38+ std::optional<std::string> traits;
39+ std::optional<std::string> actions;
40+ std::optional<std::string> legendary_actions;
41+ std::optional<std::string> img_url;
42+ std::optional<std::string> damage_immunities;
43+ std::optional<std::string> condition_immunities;
44+ std::optional<std::string> damage_resistances;
45+ std::optional<std::string> damage_vulnerabilities;
46+ std::optional<std::string> reactions;
47+
48+ public:
49+ std::optional<std::string> get_name () const { return name; }
50+ void set_name (std::optional<std::string> value) { this ->name = value; }
51+
52+ std::optional<std::string> get_meta () const { return meta; }
53+ void set_meta (std::optional<std::string> value) { this ->meta = value; }
54+
55+ std::optional<std::string> get_armor_class () const { return armor_class; }
56+ void set_armor_class (std::optional<std::string> value) {
57+ this ->armor_class = value;
58+ }
59+
60+ std::optional<std::string> get_hit_points () const { return hit_points; }
61+ void set_hit_points (std::optional<std::string> value) {
62+ this ->hit_points = value;
63+ }
64+
65+ std::optional<std::string> get_speed () const { return speed; }
66+ void set_speed (std::optional<std::string> value) { this ->speed = value; }
67+
68+ std::optional<std::string> get_str () const { return str; }
69+ void set_str (std::optional<std::string> value) { this ->str = value; }
70+
71+ std::optional<std::string> get_str_mod () const { return str_mod; }
72+ void set_str_mod (std::optional<std::string> value) { this ->str_mod = value; }
73+
74+ std::optional<std::string> get_dex () const { return dex; }
75+ void set_dex (std::optional<std::string> value) { this ->dex = value; }
76+
77+ std::optional<std::string> get_dex_mod () const { return dex_mod; }
78+ void set_dex_mod (std::optional<std::string> value) { this ->dex_mod = value; }
79+
80+ std::optional<std::string> get_con () const { return con; }
81+ void set_con (std::optional<std::string> value) { this ->con = value; }
82+
83+ std::optional<std::string> get_con_mod () const { return con_mod; }
84+ void set_con_mod (std::optional<std::string> value) { this ->con_mod = value; }
85+
86+ std::optional<std::string> get_creature_int () const { return creature_int; }
87+ void set_creature_int (std::optional<std::string> value) {
88+ this ->creature_int = value;
89+ }
90+
91+ std::optional<std::string> get_int_mod () const { return int_mod; }
92+ void set_int_mod (std::optional<std::string> value) { this ->int_mod = value; }
93+
94+ std::optional<std::string> get_wis () const { return wis; }
95+ void set_wis (std::optional<std::string> value) { this ->wis = value; }
96+
97+ std::optional<std::string> get_wis_mod () const { return wis_mod; }
98+ void set_wis_mod (std::optional<std::string> value) { this ->wis_mod = value; }
99+
100+ std::optional<std::string> get_cha () const { return cha; }
101+ void set_cha (std::optional<std::string> value) { this ->cha = value; }
102+
103+ std::optional<std::string> get_cha_mod () const { return cha_mod; }
104+ void set_cha_mod (std::optional<std::string> value) { this ->cha_mod = value; }
105+
106+ std::optional<std::string> get_saving_throws () const { return saving_throws; }
107+ void set_saving_throws (std::optional<std::string> value) {
108+ this ->saving_throws = value;
109+ }
110+
111+ std::optional<std::string> get_skills () const { return skills; }
112+ void set_skills (std::optional<std::string> value) { this ->skills = value; }
113+
114+ std::optional<std::string> get_senses () const { return senses; }
115+ void set_senses (std::optional<std::string> value) { this ->senses = value; }
116+
117+ std::optional<std::string> get_languages () const { return languages; }
118+ void set_languages (std::optional<std::string> value) {
119+ this ->languages = value;
120+ }
121+
122+ std::optional<std::string> get_challenge () const { return challenge; }
123+ void set_challenge (std::optional<std::string> value) {
124+ this ->challenge = value;
125+ }
126+
127+ std::optional<std::string> get_traits () const { return traits; }
128+ void set_traits (std::optional<std::string> value) { this ->traits = value; }
129+
130+ std::optional<std::string> get_actions () const { return actions; }
131+ void set_actions (std::optional<std::string> value) { this ->actions = value; }
132+
133+ std::optional<std::string> get_legendary_actions () const {
134+ return legendary_actions;
135+ }
136+ void set_legendary_actions (std::optional<std::string> value) {
137+ this ->legendary_actions = value;
138+ }
139+
140+ std::optional<std::string> get_img_url () const { return img_url; }
141+ void set_img_url (std::optional<std::string> value) { this ->img_url = value; }
142+
143+ std::optional<std::string> get_damage_immunities () const {
144+ return damage_immunities;
145+ }
146+ void set_damage_immunities (std::optional<std::string> value) {
147+ this ->damage_immunities = value;
148+ }
149+
150+ std::optional<std::string> get_condition_immunities () const {
151+ return condition_immunities;
152+ }
153+ void set_condition_immunities (std::optional<std::string> value) {
154+ this ->condition_immunities = value;
155+ }
156+
157+ std::optional<std::string> get_damage_resistances () const {
158+ return damage_resistances;
159+ }
160+ void set_damage_resistances (std::optional<std::string> value) {
161+ this ->damage_resistances = value;
162+ }
163+
164+ std::optional<std::string> get_damage_vulnerabilities () const {
165+ return damage_vulnerabilities;
166+ }
167+ void set_damage_vulnerabilities (std::optional<std::string> value) {
168+ this ->damage_vulnerabilities = value;
169+ }
170+
171+ std::optional<std::string> get_reactions () const { return reactions; }
172+ void set_reactions (std::optional<std::string> value) {
173+ this ->reactions = value;
174+ }
175+ };
176+
177+ namespace dnd {
178+ using Creature = CreatureElement;
179+ }
180+
181+ using json = nlohmann::json;
182+
183+ dnd::Creature parse_creature (const json& j);
184+
185+ std::vector<dnd::Creature> parse_creatures_from_file (const std::string& filename);
186+
187+ std::vector<dnd::Creature> parse_creatures_from_directory (
188+ const std::string& directory);
189+
190+ #endif
0 commit comments