Commit 02b9c5d1 authored by Jason Riggs's avatar Jason Riggs
Browse files

change

parent ffc256ed
......@@ -5,19 +5,23 @@ using namespace std;
int main() {
int seed = 0;
bool winner = false;
int turn = 1;
int difficulty = 0;
int x,y;
bool winner = false;
// Seeding random number genrator
cout << "Please enter a random seed: ";
cin >> seed;
srand(seed);
srand(seed);
cout << endl;
// ask for difficulty level
// Header
cout << "Welcome to Othello!" << endl;
cout << "the game of Reversi" << endl;
cout << endl;
// ask for difficulty level
cout << "What difficulty would you like to play against:" << endl;
cout << "1) Easy" << endl;
cout << "2) Medium" << endl;
......@@ -26,31 +30,47 @@ int main() {
cout << "Enter your choice: ";
cin >> difficulty;
// Error checking for difficulty
while(cin.fail()){
cin.clear();
cin.ignore(100, '\n');
cout << "Invalid selection."<<endl;
cout << "What difficulty would you like to play against:" << endl;
cout << "1) Easy" << endl;
cout << "2) Medium" << endl;
cout << "3) Hard" << endl;
cout << "4) 2 Player" << endl;
cout << "Enter your choice: ";
cin >> difficulty;
}
// start the game
displayBoard board;
board.start();
board.printBoard();
cout << "X goes first."<<endl;
do {
board.printBoard();
// Ask for players move
cout << "Enter the (X,Y) coordinates of where you would like to place a chip: " ;
int x,y;
cin >> x >> y;
// Player one's move
if (turn == 1) {
// Check fo valid move
if(board.isValidAdjacent(x-1,y-1,'O') && board.isValidFlip(x-1, y-1, 'X')){
// Player moves
board.playerMove1(x,y);
// Check for flips in every direction
board.verticalCheck(x, 'X');
board.horizontalCheck(y, 'X');
board.uprightCheck(x,y,'X');
board.upleftCheck(x,y,'X');
board.downrightCheck(x,y,'X');
board.downleftCheck(x,y,'X');
// Change to player 2
turn++;
}else{
......@@ -58,22 +78,29 @@ int main() {
}
// Player two's Move
} else if (turn == 2) {
// Check fo valid move
if(board.isValidAdjacent(x-1, y-1, 'X') && board.isValidFlip(x-1, y-1, 'O')){
// Player moves
board.playerMove2(x,y);
// Check for flips in every direction
board.verticalCheck(x, 'O');
board.horizontalCheck(y, 'O');
board.uprightCheck(x,y,'O');
board.upleftCheck(x,y,'O');
board.downrightCheck(x,y,'O');
board.downleftCheck(x,y,'O');
// Change to player 1
turn--;
}else{
// Prints invalid and then asks for another move
cout << "Invalid Move!"<<endl;
}
}
board.printBoard();
} while (winner == false);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment