OpenAstra
 
Loading...
Searching...
No Matches
gamerules.h
1#ifndef GAMERULES_H
2#define GAMERULES_H
3
4#include <memory>
5
6#include "../utils/json.hpp"
7
8class GameRules
9{
10public:
11 static bool initialize( const std::string& templates_path );
12
13 static bool templateExist( const std::string& category, const std::string& type );
14 static nlohmann::json getTemplate( const std::string& category, const std::string& type );
15
16 static std::string getRandomName( const std::string& type );
17
18 static const nlohmann::json& getTemplates() {
19 return _templates;
20 }
21
22public:
23 using TemplateCheckData = std::map<std::string, std::vector<std::string>>;
24 static bool checkBasicTemplate(const nlohmann::json& template_data,
25 const TemplateCheckData& mandatory_items );
26 static void json_deep_update(nlohmann::json& target, const nlohmann::json& source);
27
28
29private:
30 GameRules() {};
31 ~GameRules() {};
32
33 static bool loadTemplate(const std::string& template_file,
34 const std::string& category,
35 const std::string& type );
36
37 static bool loadTemplates(const std::string& template_folder,
38 const std::string& category );
39
40
41 static bool loadDataItems( const std::string& template_file );
42
43 static bool loadNames( const std::string& template_file );
44
45 static void addCategory( const std::string& category );
46
47 static void addDataItem(const std::string& dataitem, const nlohmann::json& data );
48
49 static nlohmann::json templateFixer(const nlohmann::json& template_data );
50
51 inline static std::map<std::string, std::vector<std::string> > _names;
52 inline static nlohmann::json _templates;
53};
54
55#endif // GAMERULES_H