From c057d434510d556b048a2ba3d8056982c02d09d7 Mon Sep 17 00:00:00 2001 From: KaffeeMaus Date: Fri, 26 Jan 2024 12:16:37 +0100 Subject: [PATCH] refactoring: rename the command structure --- src/main/c/Georg/tictactoe.c | 14 +++++++------- src/main/c/Georg/tictactoe.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/c/Georg/tictactoe.c b/src/main/c/Georg/tictactoe.c index fcade80..ee0f8dc 100644 --- a/src/main/c/Georg/tictactoe.c +++ b/src/main/c/Georg/tictactoe.c @@ -8,7 +8,7 @@ void printBoard(); struct ticTacToe GAME; -struct command COMMANDS[MAX_COMMANDS] = { +struct usrCommand COMMANDS[MAX_COMMANDS] = { { 1, "\"start menu\" - startet das menu", startMenu}, { 2, "\"start game\" - startet das spiel", startGame} }; @@ -21,12 +21,12 @@ void startTicTacToe(){ GAME = createTicTacToe(); while( GAME.currentState != -1 ){ - commandFunction command; + commandFunction usrCommand; printf("search command!\n"); - command = getCommandById( GAME.currentState + 1); + usrCommand = getCommandById( GAME.currentState + 1); - if( command != NULL) - command(0); + if( usrCommand != NULL) + usrCommand(0); else{ printf("command not found"); return; @@ -105,7 +105,7 @@ int handleGameInput( char* input ){ } int startMenu( int code ){ - if( code == -1 ){ // command test + if( code == -1 ){ // usrCommand test return 1; } @@ -222,7 +222,7 @@ bool playerHasWon( bool board[BORAD_SIZE][BORAD_SIZE]){ } int startGame( int code ){ - if( code == -1 ){ // command test + if( code == -1 ){ // usrCommand test return 1; } diff --git a/src/main/c/Georg/tictactoe.h b/src/main/c/Georg/tictactoe.h index efd1d1e..59f90d9 100644 --- a/src/main/c/Georg/tictactoe.h +++ b/src/main/c/Georg/tictactoe.h @@ -15,14 +15,14 @@ struct ticTacToe{ // Typdefinition für einen Funktionszeiger typedef int (*commandFunction)( int ); -struct command{ +struct usrCommand{ int id; char* description; commandFunction fun; }; extern struct ticTacToe GAME; -extern struct command COMMANDS[MAX_COMMANDS]; +extern struct usrCommand COMMANDS[MAX_COMMANDS]; void startTicTacToe();