允许更大一点的棋盘,以及更好的输出。
This commit is contained in:
@@ -24,7 +24,7 @@ public:
|
||||
class ChessBoard {
|
||||
private:
|
||||
static char emptyBoardString[3][4][4];
|
||||
ChessPiece ChessPieces[15][15];
|
||||
ChessPiece ChessPieces[19][19];
|
||||
int size;
|
||||
int chessCount;
|
||||
|
||||
|
||||
@@ -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') {
|
||||
|
||||
@@ -41,7 +41,9 @@ putChessPieceResult Player::setChess(char row, char column) {
|
||||
}
|
||||
if (this->board->checkWinner(rowCount, columnCount, this->chessType)) {
|
||||
std::cout << "\n####################\n"
|
||||
<< this->playerName << " wins!" << std::endl
|
||||
<< this->playerName << " ["
|
||||
<< (this->getColor() ? "◯White" : "⬤Black") << "] "
|
||||
<< " wins!" << std::endl
|
||||
<< "####################\n";
|
||||
return win;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user