Login Languish
image_captcha_stage.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include "stage.h"
11 #include "../game_manager.h"
12 
13 #include <filesystem>
14 #include <set>
15 
16 const char CELEB_CAPTCHAS = 0;
17 const char MUFFIN_DOG_CAPTCHAS = 1;
18 const char FREEDOM_CAPTCHAS = 2;
19 
20 namespace fs = std::filesystem;
21 
26 class ImageCaptchaStage : public Stage {
27 public:
28  ImageCaptchaStage(GameManager *gameManager);
29 
30  bool validateStage();
31  void update(const rapidjson::Value &req);
32  rapidjson::Value getFieldStates(rapidjson::Document::AllocatorType &allocator);
33  virtual void progressStage();
34 
35 private:
36  void initialiseDatasetImages(fs::path dataset_path, size_t MAX_NUM_IMAGES, size_t MAX_NUM_CORRECT, size_t MIN_NUM_CORRECT);
37  void initialiseCountryImages(size_t num_correct, size_t total_num);
38 
39  char current_challenge = 0;
40  void initialiseChallenge();
41  bool setNewChallenge();
42  std::set<char> challenges_remaining = {CELEB_CAPTCHAS, MUFFIN_DOG_CAPTCHAS, FREEDOM_CAPTCHAS};
43  std::vector<std::string> image_urls;
44  std::vector<std::string> image_labels; // The labels for each image, to be displayed to the user. Can be empty.
45  std::vector<std::string> correct_images;
46  std::string challenge_text = "";
47  std::vector<std::string> selected;
48  std::string last_round_error = "";
49  std::vector<fs::path> challenge_sets;
50 };
bool validateStage()
validates the stage
Definition: image_captcha_stage.cpp:39
the Stage class is an abstract class that represents a stage in the game
Definition: stage.h:20
the ImageCaptchaStage class is a class that represents a image captcha stage in the game ...
Definition: image_captcha_stage.h:26
the Stage class is an abstract class that represents a stage of the game
void update(const rapidjson::Value &req)
updates the stage
Definition: image_captcha_stage.cpp:49
the GameManager class is a class that controls the flow of the game
Definition: game_manager.h:22
rapidjson::Value getFieldStates(rapidjson::Document::AllocatorType &allocator)
gets the field states
Definition: image_captcha_stage.cpp:127
ImageCaptchaStage(GameManager *gameManager)
constructor for ImageCaptchaStage
Definition: image_captcha_stage.cpp:27