|
Eile Mit Weile
|
ServerResponse that communicates the full state of the game to all players after any update to the GameState. More...
#include <FullStateResponse.hpp>
Public Member Functions | |
| FullStateResponse (std::string game_id, const GameState &state) | |
| ~FullStateResponse () | |
| rapidjson::Value * | GetStateJson () const |
| void | WriteIntoJson (rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator) const override |
Public Member Functions inherited from ServerResponse | |
| ResponseType | GetType () const |
| std::string | GetGameId () const |
| void | WriteIntoJson (rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator) const override |
| virtual void | Process () const |
Public Member Functions inherited from Serializable | |
| virtual rapidjson::Document * | ToJson () const |
Static Public Member Functions | |
| static FullStateResponse * | FromJson (const rapidjson::Value &json) |
Static Public Member Functions inherited from ServerResponse | |
| static ServerResponse * | FromJson (const rapidjson::Value &json) |
Private Member Functions | |
| FullStateResponse (BaseClassProperties props, rapidjson::Value *state_json) | |
Private Attributes | |
| rapidjson::Value * | _state_json {} |
Additional Inherited Members | |
Protected Member Functions inherited from ServerResponse | |
| ServerResponse (const BaseClassProperties &) | |
Static Protected Member Functions inherited from ServerResponse | |
| static BaseClassProperties | CreateBaseClassProperties (ResponseType type, const std::string &game_id) |
| static BaseClassProperties | ExtractBaseClassProperties (const rapidjson::Value &json) |
Protected Attributes inherited from ServerResponse | |
| std::string | _game_id |
| ResponseType | _type |
ServerResponse that communicates the full state of the game to all players after any update to the GameState.
Note: This class design is taken from https://gitlab.ethz.ch/hraymond/cse-lama-example-project. FullStateResponse is a derivative of ServerResponse. Due to static allocation, ServerResponse can call FullStateResponse's FromJson method. We think this is very bad design, but changing it would require a lot of refactoring so we decided to leave it as it is. Furthermore, **Process is only declared/defined for the client executable**. This means that this class definition differs between the client and the server executable. Again, we think this is bad design, but we decided to leave it as it is as trying to change it would require a lot of refactoring.
|
private |
Creates a FullStateResponse defining all member vars with args using BaseClassProperties
Creates a FullStateResponse defining all member vars with args but wihtout using BaseClassProperties
| FullStateResponse::~FullStateResponse | ( | ) |
Deletes dynamically allocated _state_json (if it exists).
|
static |
Deserializes a FullStateResponse from the given json.
| rapidjson::Value * FullStateResponse::GetStateJson | ( | ) | const |
Returns the state of the game as a serialized json value.
|
overridevirtual |
Serializes this FullStateResponse into the given json.
Implements Serializable.
|
private |
The state of the game as a serialized json value.