Login Languish
credentials_stage.h
1 
8 #pragma once
9 
10 #include "../game_manager.h"
11 #include "name_stage.h"
12 #include "stage.h"
13 #include <vector>
14 
19 class CredentialsStage : public Stage {
20 public:
21  CredentialsStage(GameManager *gameManager);
22 
23  bool validateStage();
24  void update(const rapidjson::Value &req);
25  rapidjson::Value getFieldStates(rapidjson::Document::AllocatorType &allocator);
26 
27  // username error messages
28  std::string lengthError = "Username must be between 8 and 26 characters in length.";
29  std::string invalidCharError = "Invalid characters in username.";
30  std::string takenError = "Username is already taken.";
31  // password error messages
32  std::string tooShortError = "Password must be 8 or more characters."; // "Minimum password length not yet reached"?
33  std::string missingDigitError = "Password must include atleast one digit (0-9).";
34  std::string missingUppercaseError = "Password must include atleast one uppercase character (A-Z).";
35  std::string missingLowercaseError = "Password must include atleast one lowercase character (a-z).";
36  std::string missingSpecialError = "Password must include atleast one special character.";
37  std::string missingPrimeError = "Password must include atleast one prime number.";
38  std::string missingInitialsError = "Password must include your initials.";
39  std::string missingColourError = "Password must include a colour.";
40  std::string missingRomanNumError = "Pasword must include atleast one Roman numeral.";
41  std::string notPalindromeError = "Password must be a palindrome.";
42  std::string tooLongError = "Password must be 20 or less characters."; // "Maximum password length exceeded"?
43 
44  // strings of characters to find in password
45  std::string digits = "0123456789";
46  std::string lowercaseChars = "abcdefghijklmnopqrstuvwxyz";
47  std::string uppercaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
48  std::string specialChars = "!@#$%^&*()-_=+[]{}\\|;:'\",.<>/?`~";
49  std::string romanNumerals = "IVXLCDM";
50 
51  // booleans to track whether a condition has been previously met
52  bool metTooShort = false;
53  bool metMissingDigit = false;
54  bool metMissingUppercase = false;
55  bool metMissingLowercase = false;
56  bool metMissingSpecialChar = false;
57  bool metMissingPrime = false;
58  bool metMissingInitials = false;
59  bool metMissingColour = false;
60  bool metMissingRomanNumeral = false;
61  bool metNotPalindrome = false;
62  bool metTooLong = false;
63 
64 
65 private:
66  void updateErrors(const std::string &field);
67  std::string username = "";
68  std::string password = "";
69 };
CredentialsStage(GameManager *gameManager)
constructor for CredentialsStage
Definition: credentials_stage.cpp:23
void update(const rapidjson::Value &req)
updates the stage
Definition: credentials_stage.cpp:238
the Stage class is an abstract class that represents a stage in the game
Definition: stage.h:20
rapidjson::Value getFieldStates(rapidjson::Document::AllocatorType &allocator)
creates the JSON object for the field states
Definition: credentials_stage.cpp:256
bool validateStage()
validates the stage
Definition: credentials_stage.cpp:37
the Stage class is an abstract class that represents a stage of the game
the ExtrasStage class is the class that represents the DOB and T&Cs stage of the game ...
the GameManager class is a class that controls the flow of the game
Definition: game_manager.h:22
the CredetialsStage class is a class that represents the credentials stage in the game ...
Definition: credentials_stage.h:19