Cavoke  1.1.0
A Platform for creating and hosting multiplayer turn-based board games
Loading...
Searching...
No Matches
game.h
1#ifndef CAVOKE_SERVER_GAME_H
2#define CAVOKE_SERVER_GAME_H
3#include <drogon/drogon.h>
4#include <boost/filesystem/path.hpp>
5#include <nlohmann/json.hpp>
6#include <string>
7#include "games_storage_config.h"
8
9namespace cavoke::server::model {
10
11struct GameConfig {
12 std::string id;
13 std::string display_name;
14 std::string description;
15 std::string app_type;
16 std::string url;
17 int players_num;
18 std::vector<std::string> role_names;
19 json default_settings;
20
22 void validate() const {
23 // TODO: just a sample, `assert` removed in Release
24 assert(players_num >= 1);
25 }
26};
27NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(GameConfig,
28 id,
29 display_name,
30 description,
31 app_type,
32 url,
33 players_num,
34 role_names,
35 default_settings)
36
37class Game {
38 const std::string CONFIG_FILE;
39 const std::string CLIENT_FILE;
40 const std::string LOGIC_FILE;
41
42public:
43 explicit Game(const boost::filesystem::path &directory,
44 const GamesStorageConfig &game_storage_config);
45 Game() = default;
46
47 boost::filesystem::path directory;
48 boost::filesystem::path client_file;
49 GameConfig config;
50 boost::filesystem::path logic_file;
51
52 static bool is_game_directory(
53 const boost::filesystem::path &path,
54 const GamesStorageConfig &games_storage_config);
55};
56
57} // namespace cavoke::server::model
58
59#endif // CAVOKE_SERVER_GAME_H
void validate() const
Validates config. Throws an exception if invalid.
Definition: game.h:22