允许更大一点的棋盘,以及更好的输出。

This commit is contained in:
unlockable
2023-03-01 21:00:13 +08:00
parent 1006c6038a
commit 30288e10b6
3 changed files with 13 additions and 5 deletions

View File

@@ -7,9 +7,9 @@ int main() {
{
int boardSize = 0;
while (true) {
std::cout << "Please enter the size of the board (5-15): ";
std::cout << "Please enter the size of the board (5-19): ";
std::cin >> boardSize;
if (std::cin.fail() || boardSize < 5 || boardSize > 15) {
if (std::cin.fail() || boardSize < 5 || boardSize > 19) {
std::cout << "Invalid input, try again." << std::endl;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(),
@@ -21,6 +21,7 @@ int main() {
}
aBoard = new ChessBoard(boardSize);
}
aBoard->show();
Player *players[2];
{
std::string temp = "";
@@ -57,6 +58,8 @@ int main() {
'\n');
}
else {
std::cin.ignore(std::numeric_limits<std::streamsize>::max(),
'\n');
break;
}
}
@@ -73,6 +76,8 @@ int main() {
'\n');
}
else {
std::cin.ignore(std::numeric_limits<std::streamsize>::max(),
'\n');
break;
}
}
@@ -89,10 +94,11 @@ int main() {
else {
aBoard->show();
char input;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
do {
std::cout << "Reset for another round? (y/n) ";
input = getchar();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(),
'\n');
} while (input != 'y' && input != 'Y' && input != 'n' &&
input != 'N');
if (input == 'y' || input == 'Y') {