Login Languish
stage.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <vector>
11 #include <string>
12 #include <map>
13 #include "rapidjson/document.h"
14 #include "../game_manager.h"
15 
20 class Stage
21 {
22 protected:
23  Stage(GameManager *gameManager);
24  GameManager *gm;
25 
26 public:
27  virtual bool validateStage() = 0;
28  std::vector<std::string> getFieldErrors(std::string field);
29  virtual void update(const rapidjson::Value &req) = 0;
30  std::string getStageName();
31  rapidjson::Value getStageState(rapidjson::Document::AllocatorType &allocator);
32  virtual rapidjson::Value getFieldStates(rapidjson::Document::AllocatorType &allocator) = 0;
33  virtual void progressStage() {};
34  bool isFieldDisabled(const std::string &field);
35 protected:
36  rapidjson::Value createFieldState(const std::string &field, rapidjson::Value &fieldValue, rapidjson::Document::AllocatorType &allocator);
37  std::string name = "";
38  std::map<std::string, std::vector<std::string>> field_errors;
39  const int REQ_FIELD_INDEX = 1;
40  const int REQ_VALUE_INDEX = 2;
41 };
std::vector< std::string > getFieldErrors(std::string field)
gets the field errors for a given field
Definition: stage.cpp:77
rapidjson::Value createFieldState(const std::string &field, rapidjson::Value &fieldValue, rapidjson::Document::AllocatorType &allocator)
creates the JSON representation of the field states
Definition: stage.cpp:48
rapidjson::Value getStageState(rapidjson::Document::AllocatorType &allocator)
creates the JSON representation of the stage state
Definition: stage.cpp:23
the Stage class is an abstract class that represents a stage in the game
Definition: stage.h:20
std::string getStageName()
gets the stage name
Definition: stage.cpp:87
the GameManager class is a class that controls the flow of the game
Definition: game_manager.h:22