void runProgram(char ** mine, char ** status, int width, int height) { int w, h; char **composite; int endGame = 0; while(endGame != 1) { // Takes in original move. If invalid, changed in "placeMove" function printf("Which square do you wish to uncover?\n"); printf("Enter a row and column: "); scanf(" %d %d", &h, &w); placeMove(status, width, height, w, h); system("clear"); composite = makeCompositeBoard(mine, status, width, height); uncoverSquares(composite, mine, status, width, height, w, h); printf(" -------MINESWEEPER-------\n"); printBoard(composite, width, height); printf("\n"); endGame = boardClear(status, mine, width, height); // If there is a winner, the game loop breaks and prints out winning statement if(endGame == 1) break; endGame = bombChosen(composite, width, height); // If a bomb is chosen, "endGame" changes to 1 and the loop breaks } }
int TicTacToe::play(bool _xTurn, int pos) { bool win; if(!isRightTurn(_xTurn)) { return INVALID_TURN; } if(!isValidMove(pos)) { return INVALID_MOVE; } placeMove(_xTurn,pos); plotGame(); win = won(_xTurn); xTurn = !xTurn; if(win) { resetGame(); return WIN; } else if(isFull()){ resetGame(); return OVER; } else { return NO_WIN; } }