@@ -35,41 +35,66 @@ class JazzJackrabbit2GameClient {
3535 // cppcheck-suppress unusedStructMember
3636 const std::unordered_set<std::string> available_user_options;
3737
38+
3839 /*
39- * Reads from stdin line by line the sequence actions that the user wants to be performed.
40- * Then it lets the protocol handle the sending to the server of the built sequence with
41- * GameProtocolClient::play_action_sequence, which also waits for the server to respond with
42- * the output processed combos
40+ * Compares two options in equal conditions (both are sanitized with
41+ * JazzJackrabbit2GameClient::sanitize_string) and returns true if they are equal
4342 */
44- void read_and_play_action_lines ();
45-
4643 const bool are_options_equal (const std::string& option1, const std::string& option2) const ;
4744
45+ /*
46+ * Returns true if option_to_validate is included in the available_user_options
47+ */
4848 const bool is_option_valid (const std::string& option_to_validate) const ;
4949
50+ /*
51+ * Returns true if option_to_validate is the option JazzJackrabbit2GameClient::USER_OPTION_QUIT
52+ * Or if the socket connection from the protocol_client has closed
53+ */
5054 const bool should_game_end (const std::string& option_to_validate) const ;
5155
56+ /*
57+ * Saves in user_input_vectorized the user_input broken into each word one vector element
58+ */
5259 void vectorize_user_input (const std::string& user_input,
53-
5460 std::vector<std::string>& user_input_vectorized);
5561
62+ /*
63+ * Calls the appropiate method depending on the desired action
64+ */
5665 void execute_command (const std::vector<std::string>& user_input_vectorized);
5766
67+ /*
68+ * Returns an uppercase copy of the string
69+ */
5870 const std::string string_to_uppercase (const std::string& string) const ;
5971
72+ /*
73+ * Returns the result of JazzJackrabbit2GameClient::string_to_uppercase
74+ */
6075 const std::string sanitize_string (const std::string& string) const ;
6176
77+ /*
78+ * Uses the client_protocol to send an attack to the server
79+ */
6280 void execute_attack (const std::vector<std::string>& user_input_vectorized);
6381
82+ /*
83+ * Uses the client_protocol to block the I/O until read all the messages expressed
84+ * by the user
85+ */
6486 void execute_read_from_server (const std::vector<std::string>& user_input_vectorized);
6587
88+ /*
89+ * Prints to std::out the message read from the server
90+ */
6691 void print_messages_from_server (const std::vector<GameMessage>& messages) const ;
6792
6893public:
6994 /*
7095 * JazzJackrabbit2GameClient is the client side application interface for the game
7196 * JazzJackrabbit2. It is offered standalone, so everything that the game needs to function is
72- * included when instancing this class. It throws an std::runtime_error if the number of
97+ * included when instancing this class. It throws an exception if the number of
7398 * arguments argv is not EXPECTED_ARGUMENTS. The error exit code can be obtained with
7499 * JazzJackrabbit2GameClient::get_exit_code_error.
75100 */
@@ -95,8 +120,7 @@ class JazzJackrabbit2GameClient {
95120 static const int8_t get_exit_code_error () noexcept ;
96121
97122 /*
98- * Executes JazzJackrabbit2GameClient::read_and_play_action_lines and returns
99- * JazzJackrabbit2GameClient::EXIT_CODE_OK
123+ * Starts and runs the client game loop
100124 */
101125 const int8_t run_game ();
102126};
0 commit comments