Login Languish
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Stage Class Referenceabstract

the Stage class is an abstract class that represents a stage in the game More...

#include <stage.h>

Inheritance diagram for Stage:
Inheritance graph
[legend]
Collaboration diagram for Stage:
Collaboration graph
[legend]

Public Member Functions

virtual bool validateStage ()=0
 
std::vector< std::string > getFieldErrors (std::string field)
 gets the field errors for a given field More...
 
virtual void update (const rapidjson::Value &req)=0
 
std::string getStageName ()
 gets the stage name More...
 
rapidjson::Value getStageState (rapidjson::Document::AllocatorType &allocator)
 creates the JSON representation of the stage state More...
 
virtual rapidjson::Value getFieldStates (rapidjson::Document::AllocatorType &allocator)=0
 
virtual void progressStage ()
 
bool isFieldDisabled (const std::string &field)
 

Protected Member Functions

 Stage (GameManager *gameManager)
 
rapidjson::Value createFieldState (const std::string &field, rapidjson::Value &fieldValue, rapidjson::Document::AllocatorType &allocator)
 creates the JSON representation of the field states More...
 

Protected Attributes

GameManagergm
 
std::string name = ""
 
std::map< std::string, std::vector< std::string > > field_errors
 
const int REQ_FIELD_INDEX = 1
 
const int REQ_VALUE_INDEX = 2
 

Detailed Description

the Stage class is an abstract class that represents a stage in the game

contains functions that are implemented by all stages in the game

Member Function Documentation

◆ createFieldState()

rapidjson::Value Stage::createFieldState ( const std::string &  field,
rapidjson::Value &  fieldValue,
rapidjson::Document::AllocatorType &  allocator 
)
protected

creates the JSON representation of the field states

this function creates rapidjson::Value object containing the field states, this functions is used for standard fields that have a value, errors and disabled property

Parameters
fieldthe name of the field to create the field state for
fieldValuethe rapidjson::Value object containing the field value (this may be any native type and is created by Stage::getFieldStates)
allocatorthe rapidjson::Document::AllocatorType object used to allocate memory for the JSON objects
Returns
rapidjson value object containing the field states

◆ getFieldErrors()

std::vector< std::string > Stage::getFieldErrors ( std::string  field)

gets the field errors for a given field

this function returns the field errors for a given field

Parameters
fieldthe field to get the errors for
Returns
string vector containing the field errors

◆ getStageName()

std::string Stage::getStageName ( )

gets the stage name

returns the stage name as a string

Returns
string containing the stage name

◆ getStageState()

rapidjson::Value Stage::getStageState ( rapidjson::Document::AllocatorType &  allocator)

creates the JSON representation of the stage state

this function creates rapidjson::Value object containing the stage state including the stage name and the JSON representation of the field states

Parameters
allocatorthe rapidjson::Document::AllocatorType object used to allocate memory for the JSON objects
Returns
rapidjson value object containing the stage state Stage::getFieldStates

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