Login Languish
Public Member Functions | List of all members
GameManager Class Reference

the GameManager class is a class that controls the flow of the game More...

#include <game_manager.h>

Public Member Functions

 GameManager ()
 constructor for GameManager
 
StagegetStage (std::string stage)
 gets the current stage More...
 
void updateField (const rapidjson::Value &req)
 updates the field More...
 
void updateField (const std::string &stage, const std::string &field, const std::string &value)
 updates the field More...
 
std::string getNextStage ()
 progresses to the next stage is current stage is validated More...
 
std::vector< std::string > getFieldErrors (const std::string &stage, const std::string &field)
 gets the field errors More...
 
rapidjson::Document getGameState ()
 gets the game state More...
 
void progressStage (const rapidjson::Value &req)
 
std::string getCurrentStageName ()
 

Detailed Description

the GameManager class is a class that controls the flow of the game

contains all concrete stage objects and method for interacting with the vairous stages

Member Function Documentation

◆ getFieldErrors()

std::vector< std::string > GameManager::getFieldErrors ( const std::string &  stage,
const std::string &  field 
)

gets the field errors

gets the field errors for the requested stage and field

Parameters
stagethe name of the stage to get the field errors for
fieldthe name of the field to get the errors for
Returns
a vector of strings containing the errors for the field Stage::getFieldErrors

◆ getGameState()

rapidjson::Document GameManager::getGameState ( )

gets the game state

gets the game state by creating a rapidjson object containing the game state

Returns
a rapidjson object containing the game state Stage::getStageState

◆ getNextStage()

std::string GameManager::getNextStage ( )

progresses to the next stage is current stage is validated

Returns
"no" if current stage is not validated, "end" if it is the end, or the name of the new stage

◆ getStage()

Stage * GameManager::getStage ( std::string  stage)

gets the current stage

Parameters
stagename of stage requested
Returns
pointer to stage

◆ updateField() [1/2]

void GameManager::updateField ( const rapidjson::Value &  req)

updates the field

updates the field within the requested stage

Parameters
reqthe request object containing the stage, field to update and the new value Stage::update

◆ updateField() [2/2]

void GameManager::updateField ( const std::string &  stage,
const std::string &  field,
const std::string &  value 
)

updates the field

helper method to update the field within the requested stage, using string instead of a rapidjson object, used in testing

Parameters
stagethe name of the stage to update
fieldthe name of the field to update
valuethe new value of the field GameManager::updateField

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