Browse Source

refactoring: rename the command structure

remotes/origin/georg
KaffeeMaus 11 months ago
parent
commit
c057d43451
  1. 14
      src/main/c/Georg/tictactoe.c
  2. 4
      src/main/c/Georg/tictactoe.h

14
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;
}

4
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();

Loading…
Cancel
Save