From 75e050c8d47291fb0495373ba5bee594ccafb017 Mon Sep 17 00:00:00 2001 From: KaffeeMaus Date: Fri, 26 Jan 2024 12:05:44 +0100 Subject: [PATCH] add game command handler to the game --- src/main/c/Georg/tictactoe.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/c/Georg/tictactoe.c b/src/main/c/Georg/tictactoe.c index 614a3e7..4838534 100644 --- a/src/main/c/Georg/tictactoe.c +++ b/src/main/c/Georg/tictactoe.c @@ -100,7 +100,7 @@ int handleGameInput( char* input ){ if( strstr(input, "set") != NULL ){ return 1; }else{ - return false; + return -1; } } @@ -159,9 +159,12 @@ int startGame( int code ){ initializeBoard( board ); while( GAME.currentState == 1 ){ - int nextState = handleCommand( getUserInput() ); + char* input = getUserInput(); + int nextState = handleCommand( input ); + + if( nextState == -1 ){ // no stateCommand + int gameCommand = handleGameInput( input ); - if( nextState == -1 ){ printf("command not found!"); }else{ GAME.currentState = nextState;