Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (36 loc) · 1.4 KB
/
Copy pathmain.cpp
File metadata and controls
40 lines (36 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "inc/Game.h"
using namespace Chess;
int main(){
std::cout << "############## WELCOME TO CHESS ##############\n\n";
std::string startChar;
std::cout << "Start game? (Y/N) ";
std::cin >> startChar;
std::cout << std::endl;
std::transform(startChar.begin(), startChar.end(), startChar.begin(), [](unsigned char c) { return std::tolower(c); });
Game game;
if (startChar == "n") {
std::cout << "Oh..." << std::endl;
std::getchar();
std::exit(0);
} else if (startChar != "y") {
std::cout << "What?? Let's try this again\n\n";
main();
}
game = Game();
game.startGame();
system("cls");
std::cin.ignore();
int state = 1;
std::cout << "========================================================================\n";
while (state != 2){
game.printBoard(game.getGameBoard()->getboard());
state = game.turn(game.receiveMove());
if (state == 1) {
game.nextTurn();
std::cout << "========================================================================\n";
}
else if (state == 0) { std::cout << "=================Entered invalid move, please try again=================\n"; }
}
game.gameOver();
return 0;
}