Eile Mit Weile
Loading...
Searching...
No Matches
GameInstanceManager.hpp
1#ifndef EILE_MIT_WEILE_GAME_INSTANCE_MANAGER_HPP
2#define EILE_MIT_WEILE_GAME_INSTANCE_MANAGER_HPP
4#include <string>
5#include <shared_mutex>
6#include <unordered_map>
7
8#include "GameInstance.hpp"
9#include "PlayerManager.hpp"
10#include "ServerNetworkManager.hpp"
11
27private:
28
29 inline static std::shared_mutex games_lut_lock;
30 static std::unordered_map<std::string, GameInstance*> games_lut;
32 static GameInstance* CreateNewGame();
35public:
36
41 static bool TryGetGameInstance(const std::string& game_id, GameInstance*& game_instance_ptr);
42
48 static bool TryGetPlayerAndGameInstance(const std::string& player_id, Player*& player, GameInstance*& game_instance_ptr, std::string& err);
49
56
61 static bool TryAddPlayer(Player* player, GameInstance*& game_instance_ptr, std::string& err);
62
67 static bool TryRemovePlayer(Player* player, const std::string& game_id, std::string& err);
68
73 static bool TryRemovePlayer(Player* player, GameInstance*& game_instance_ptr, std::string& err);
74
75};
76#endif //EILE_MIT_WEILE_GAME_INSTANCE_MANAGER_HPP
Manages all active GameInstances.
Definition GameInstanceManager.hpp:26
static bool TryAddPlayer(Player *player, GameInstance *&game_instance_ptr, std::string &err)
Definition GameInstanceManager.cpp:88
static std::unordered_map< std::string, GameInstance * > games_lut
Definition GameInstanceManager.hpp:3
static bool TryAddPlayerToAnyGame(Player *player, GameInstance *&game_instance_ptr, std::string &err)
Definition GameInstanceManager.cpp:60
static bool TryRemovePlayer(Player *player, const std::string &game_id, std::string &err)
Definition GameInstanceManager.cpp:106
static bool TryGetPlayerAndGameInstance(const std::string &player_id, Player *&player, GameInstance *&game_instance_ptr, std::string &err)
Definition GameInstanceManager.cpp:46
static GameInstance * CreateNewGame()
Definition GameInstanceManager.cpp:120
static GameInstance * FindJoinableGameInstance()
Definition GameInstanceManager.cpp:5
static std::shared_mutex games_lut_lock
Definition GameInstanceManager.hpp:29
static bool TryGetGameInstance(const std::string &game_id, GameInstance *&game_instance_ptr)
Definition GameInstanceManager.cpp:35
Contains ServerGameState and can modify it.
Definition GameInstance.hpp:22
Holds all relevant information of a player.
Definition Player.hpp:27
A serializable value, used for writing values into json.
Definition serializable_value.hpp:28