diff --git a/libs/utilities.c b/libs/utilities.c index 6ddc2b5..8fa9e98 100644 --- a/libs/utilities.c +++ b/libs/utilities.c @@ -84,6 +84,11 @@ int strcmpi(const char* str01, const char* str02) { return cmp; } +int validatePattern(char* userInput) { + char* options[] = {"glider", "toad", "press", "glider cannon"}; + return isStrIn(userInput, options, 4); +} + void trimStr(char* str) { trimLeftStr(str); trimRightStr(str); diff --git a/libs/utilities.h b/libs/utilities.h index 3da21a1..17dd4ca 100644 --- a/libs/utilities.h +++ b/libs/utilities.h @@ -90,6 +90,18 @@ void printDashboardByConsole(TGame* pGame); */ int strcmpi(const char* str01, const char* str02); +/** + * @brief Validates the pattern of user input. + * + * This function checks if the user input matches `glider`, `toad`, `press`, or + * `glider cannon` pattern. The comparison is case insensitive. + * + * @param userInput The user input to be validated. + * + * @return 1 if the pattern is valid, 0 otherwise. + */ +int validatePattern(char* userInput); + /** * @brief Trims leading and trailing whitespace characters from a string. * diff --git a/src/main.c b/src/main.c index 3acdeb5..554a293 100644 --- a/src/main.c +++ b/src/main.c @@ -2,11 +2,6 @@ #include "stdio.h" -int validatePattern(char* userInput) { - char* options[] = {"glider", "toad", "press", "glider cannon"}; - return isStrIn(userInput, options, 4); -} - int main() { TGame game; @@ -52,4 +47,4 @@ int main() { } while (invalidPattern); return 0; -} \ No newline at end of file +}