Browse Source

some bugfix and add global vars

remotes/origin/georg
KaffeeMaus 11 months ago
parent
commit
4340d64ed3
  1. 24
      src/main/c/Georg/tictactoe.c
  2. 3
      src/main/c/Georg/tictactoe.h

24
src/main/c/Georg/tictactoe.c

@ -4,7 +4,9 @@
#include "tictactoe.h" #include "tictactoe.h"
struct ticTacToe TICTACTOE;
struct ticTacToe GAME;
struct command* COMMANDS;
char* getWelcomeMessage(){ char* getWelcomeMessage(){
return "Hallo und willkommen zu unserem TicTacToe Spiel. Anbei die Anleitung:\n"; return "Hallo und willkommen zu unserem TicTacToe Spiel. Anbei die Anleitung:\n";
@ -29,6 +31,8 @@ int handleCommand( char* input ){
return 0; return 0;
}else if( strcmp(input, "start game") == 0 ){ }else if( strcmp(input, "start game") == 0 ){
return 1; return 1;
}else{
return -1;
} }
} }
@ -68,10 +72,20 @@ int startMenu( int code ){
return 1; 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; return 0;
} }

3
src/main/c/Georg/tictactoe.h

@ -14,6 +14,9 @@ struct command{
commandFunction fun; commandFunction fun;
}; };
extern struct ticTacToe GAME;
extern struct command* COMMANDS;
char* getWelcomeMessage(); char* getWelcomeMessage();
char* getRulesMessage(); char* getRulesMessage();
struct ticTacToe createTicTacToe(); struct ticTacToe createTicTacToe();

Loading…
Cancel
Save