Eile Mit Weile
Loading...
Searching...
No Matches
ServerGameState Class Reference

Extra functionality for server-side GameState. More...

#include <ServerGameState.hpp>

Inheritance diagram for ServerGameState:
GameState UniqueSerializable Serializable

Public Member Functions

bool StartGame (std::string &err)
 
bool AddPlayer (Player *player, std::string &err)
 
bool RemovePlayer (Player *player, std::string &err)
 
bool UpdateCurrentPlayer (std::string &err)
 
bool MoveFigure (Player *player, unsigned figure_id, unsigned space_id, std::string &err)
 
- Public Member Functions inherited from GameState
 GameState ()
 
 GameState (std::string id)
 
 GameState (std::string id, Board *board, std::vector< Player * > &players, SerializableValue< bool > *is_started, SerializableValue< bool > *is_finished, SerializableValue< int > *current_player_idx, SerializableValue< int > *play_direction)
 
 ~GameState ()
 
bool IsFull ()
 
bool IsStarted ()
 
bool IsFinished ()
 
bool IsPlayerInGame (Player *player)
 
bool IsAllowedToPlayNow (Player *player)
 
std::vector< Player * > & GetPlayers ()
 
PlayerGetCurrentPlayer ()
 
int GetPlayerIndex (Player *player)
 
BoardGetBoard ()
 
void WriteIntoJson (rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator) const override
 
unsigned int ThrowDice (Player *player, std::string string)
 
- Public Member Functions inherited from UniqueSerializable
std::string GetId () const
 
void WriteIntoJson (rapidjson::Value &json, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator) const override
 
- Public Member Functions inherited from Serializable
virtual rapidjson::DocumentToJson () const
 

Additional Inherited Members

- Static Public Member Functions inherited from GameState
static GameStateFromJson (const rapidjson::Value &json)
 
- Protected Member Functions inherited from UniqueSerializable
 UniqueSerializable ()
 
 UniqueSerializable (std::string id)
 
- Protected Attributes inherited from GameState
Board_board
 
std::vector< Player * > _players
 
SerializableValue< bool > * _is_started
 
SerializableValue< bool > * _is_finished
 
SerializableValue< int > * _current_player_idx
 
SerializableValue< int > * _play_direction
 
- Protected Attributes inherited from UniqueSerializable
std::string id
 
- Static Protected Attributes inherited from GameState
static const int _max_nof_players = 4
 
static const int _min_nof_players = 2
 

Detailed Description

Extra functionality for server-side GameState.

Member Function Documentation

◆ AddPlayer()

bool ServerGameState::AddPlayer ( Player player,
std::string &  err 
)

Add a player to the game if it isn't full, hasn't already started, the player isn't already in the game and the player name isn't already taken. Returns false if it fails, with an error message in err.

◆ MoveFigure()

bool ServerGameState::MoveFigure ( Player player,
unsigned  figure_id,
unsigned  space_id,
std::string &  err 
)

Move a figure if the player is allowed to do so. Checks if

◆ RemovePlayer()

bool ServerGameState::RemovePlayer ( Player player,
std::string &  err 
)

Remove a player from the game if the player can be found in the game. Returns false if it fails, with an error message in err.

◆ StartGame()

bool ServerGameState::StartGame ( std::string &  err)

Start the game if enough players are in the game and hasn't already started. Also randomly picks a startig Player. Returns false if it fails, with an error message in err.

◆ UpdateCurrentPlayer()

bool ServerGameState::UpdateCurrentPlayer ( std::string &  err)

Update the current player to the next player in the list of players (i.e. start the next turn). Check if the previous Player has won and return false if that is the case.


The documentation for this class was generated from the following files: