int environment(sqlite3 *db, char *username, int isAdmin){
	int start_boolean = 0;
	char select;
	do{
		if( (select != '1') && (select != '6') ) clrscr();
		if(start_boolean){
			printf("What would you like to do now, %s? ",username);
		}
		else{
			printf("Hello there, %s.\n\n", username);
			listOptions();
			lineBreak();
			printf("What would you like to do, %s? ",username);
			start_boolean = 1;
		}
		select = charInput();
		if(select != '0') clrscr();
		selection(select, db, username, isAdmin);
	}while( select!='0' );
	lineBreak();
	printf("Bye, %s!\n", username);
	sleep(2);
	clrscr();
	return 0;
}
Example #2
0
int main(void){
	/*variable declaration*/
	_Bool playingGame = 1, newGame = 1, thisGame;
	short sudoku[9][9], bckup[9][9];
	char input[5];
	short undoCount = 0, undo[5][9][9] = { 0 }, count;

	time_t startTime, endTime;
	int ranktime[6];
	/*game loop start here*/
	srand(time(NULL));
	for (newGame = 1; playingGame; newGame = 1){
		making_sudoku(sudoku, 1);
		sync(bckup, sudoku);
		for (thisGame = 1; newGame; thisGame = 1){
			print(sudoku);
			for (undoCount = 0; thisGame;){
				startTime = time(NULL);
				charInput(input);
				switch (input[0]){
				case 'h':case 'H': break;
				case 'q':case 'Q': playingGame = 0;
				case 'n':case 'N': newGame = 0;
				case 'a':case 'A': thisGame = 0; break;
				case 'u':case 'U':
					if (undoCount){
						sync(sudoku, undo[0]);
						for (count = 1; count < 5; count++)
							sync(undo[count - 1], undo[count]);
						undoCount--;
					}
					else
						printf("\n### no more undo left\n");
					print(sudoku); break;
				case 'v': case'V':
					if (verificate(bckup, sudoku, 1))
						printf("no error\n");
					print(sudoku); break;
				case 'r':case 'R':
					rank(ranktime);
				default:
					if (bckup[input[0] - 49][input[2] - 49] != '.')
						printf("wrong coordinate\n");
					else{
						if (undoCount < 5)
							undoCount++;
						for (count = 5 - undoCount; count; count--)
							sync(undo[count], undo[count - 1]);
						sync(undo[0], sudoku);
						sudoku[input[0] - 49][input[2] - 49] = input[4] - 48;
					}
					print(sudoku); break;
				}//end of switch(input[0])
				if (verificate(bckup, sudoku, 0)){
					endTime = time(NULL);
					ranktime[5] = difftime(endTime, startTime);
					printf("you completed in %d sec!", ranktime[5]);
				}
			}//end of thisGame
		}//end of newGame
	}//end of playingGame
	return 0;
}