diff --git a/src/main/c/Georg/tictactoe.c b/src/main/c/Georg/tictactoe.c index d01ae9f..195a85e 100644 --- a/src/main/c/Georg/tictactoe.c +++ b/src/main/c/Georg/tictactoe.c @@ -4,7 +4,9 @@ #include "tictactoe.h" -struct ticTacToe TICTACTOE; +struct ticTacToe GAME; +struct command* COMMANDS; + char* getWelcomeMessage(){ return "Hallo und willkommen zu unserem TicTacToe Spiel. Anbei die Anleitung:\n"; @@ -29,6 +31,8 @@ int handleCommand( char* input ){ return 0; }else if( strcmp(input, "start game") == 0 ){ return 1; + }else{ + return -1; } } @@ -68,10 +72,20 @@ int startMenu( int code ){ return 1; } - printf("Welcome to the menu!\n"); - char userInput[50]; - printf( ":" ); - scanf( "%s", userInput ); + while( GAME.currentState == 0 ){ + char userInput[50]; + printf( ":" ); + scanf( "%s", &userInput ); + + int nextState = 0; + nextState = handleCommand(userInput); + + if( nextState == -1 ){ + printf("command not found!"); + }else{ + GAME.currentState = nextState; + } + } return 0; } diff --git a/src/main/c/Georg/tictactoe.h b/src/main/c/Georg/tictactoe.h index 3fa6555..f957f9c 100644 --- a/src/main/c/Georg/tictactoe.h +++ b/src/main/c/Georg/tictactoe.h @@ -14,6 +14,9 @@ struct command{ commandFunction fun; }; +extern struct ticTacToe GAME; +extern struct command* COMMANDS; + char* getWelcomeMessage(); char* getRulesMessage(); struct ticTacToe createTicTacToe();