astyle: reformatted all files
This commit is contained in:
parent
04c7a931d3
commit
7722a84b2e
5 changed files with 120 additions and 99 deletions
152
Board.cpp
152
Board.cpp
|
|
@ -31,9 +31,8 @@
|
|||
|
||||
Board::Board() {
|
||||
boardGrid.resize(8);
|
||||
for(int i = 0; i < 8; i++) {
|
||||
for(int i = 0; i < 8; i++)
|
||||
boardGrid[i].resize(8);
|
||||
}
|
||||
}
|
||||
|
||||
Board::~Board() {
|
||||
|
|
@ -92,9 +91,8 @@ void Board::setupInitialPosition() {
|
|||
|
||||
int setupFromFEN(std::string strFEN) {
|
||||
std::vector<std::string> splitFEN = split(strFEN, ' ');
|
||||
if(splitFEN.size() != 6) { // a valid FEN *must* contain 6 fields
|
||||
if(splitFEN.size() != 6) // a valid FEN *must* contain 6 fields
|
||||
return -1;
|
||||
}
|
||||
std::vector<std::string> splitField1 = split(splitFEN[0], '/');
|
||||
int rank = 0, file = 0;
|
||||
int skip = 0;
|
||||
|
|
@ -108,80 +106,80 @@ int setupFromFEN(std::string strFEN) {
|
|||
continue;
|
||||
}
|
||||
switch(sym) {
|
||||
case 'R':
|
||||
// white rook
|
||||
boardGrid[rank][file] = std::make_unique<Rook>(PIECE_WHITE);
|
||||
break;
|
||||
case 'r':
|
||||
// black rook
|
||||
boardGrid[rank][file] = std::make_unique<Rook>(PIECE_BLACK);
|
||||
break;
|
||||
case 'N':
|
||||
// white knight
|
||||
boardGrid[rank][file] = std::make_unique<Knight>(PIECE_WHITE);
|
||||
break;
|
||||
case 'n':
|
||||
// black knight
|
||||
boardGrid[rank][file] = std::make_unique<Knight>(PIECE_BLACK);
|
||||
break;
|
||||
case 'B':
|
||||
// white bishop
|
||||
boardGrid[rank][file] = std::make_unique<Bishop>(PIECE_WHITE);
|
||||
break;
|
||||
case 'b':
|
||||
// black bishop
|
||||
boardGrid[rank][file] = std::make_unique<Bishop>(PIECE_BLACK);
|
||||
break;
|
||||
case 'Q':
|
||||
// white queen
|
||||
boardGrid[rank][file] = std::make_unique<Queen>(PIECE_WHITE);
|
||||
break;
|
||||
case 'q':
|
||||
// black queen;
|
||||
boardGrid[rank][file] = std::make_unique<Queen>(PIECE_BLACK);
|
||||
break;
|
||||
case 'K':
|
||||
// white king
|
||||
if(wKingPlaced) {
|
||||
// invalid FEN, more than 1 white king
|
||||
case 'R':
|
||||
// white rook
|
||||
boardGrid[rank][file] = std::make_unique<Rook>(PIECE_WHITE);
|
||||
break;
|
||||
case 'r':
|
||||
// black rook
|
||||
boardGrid[rank][file] = std::make_unique<Rook>(PIECE_BLACK);
|
||||
break;
|
||||
case 'N':
|
||||
// white knight
|
||||
boardGrid[rank][file] = std::make_unique<Knight>(PIECE_WHITE);
|
||||
break;
|
||||
case 'n':
|
||||
// black knight
|
||||
boardGrid[rank][file] = std::make_unique<Knight>(PIECE_BLACK);
|
||||
break;
|
||||
case 'B':
|
||||
// white bishop
|
||||
boardGrid[rank][file] = std::make_unique<Bishop>(PIECE_WHITE);
|
||||
break;
|
||||
case 'b':
|
||||
// black bishop
|
||||
boardGrid[rank][file] = std::make_unique<Bishop>(PIECE_BLACK);
|
||||
break;
|
||||
case 'Q':
|
||||
// white queen
|
||||
boardGrid[rank][file] = std::make_unique<Queen>(PIECE_WHITE);
|
||||
break;
|
||||
case 'q':
|
||||
// black queen;
|
||||
boardGrid[rank][file] = std::make_unique<Queen>(PIECE_BLACK);
|
||||
break;
|
||||
case 'K':
|
||||
// white king
|
||||
if(wKingPlaced) {
|
||||
// invalid FEN, more than 1 white king
|
||||
return -1;
|
||||
} else {
|
||||
boardGrid[rank][file] = std::make_unique<King>(PIECE_WHITE);
|
||||
wKingPlaced = true;
|
||||
}
|
||||
break;
|
||||
case 'k':
|
||||
// black king
|
||||
if(bKingPlaced) {
|
||||
// invalid FEN, more than 1 black king
|
||||
return -1;
|
||||
} else {
|
||||
boardGrid[rank][file] = std::make_unique<King>(PIECE_BLACK);
|
||||
bKingPlaced = true;
|
||||
}
|
||||
break;
|
||||
case 'P':
|
||||
// white pawn
|
||||
boardGrid[rank][file] = std::make_unique<Pawn>(PIECE_WHITE);
|
||||
break;
|
||||
case 'p':
|
||||
// black pawn
|
||||
boardGrid[rank][file] = std::make_unique<Pawn>(PIECE_BLACK);
|
||||
break;
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
skip = atoi(sym);
|
||||
break;
|
||||
default:
|
||||
// invalid character?
|
||||
return -1;
|
||||
} else {
|
||||
boardGrid[rank][file] = std::make_unique<King>(PIECE_WHITE);
|
||||
wKingPlaced = true;
|
||||
}
|
||||
break;
|
||||
case 'k':
|
||||
// black king
|
||||
if(bKingPlaced) {
|
||||
// invalid FEN, more than 1 black king
|
||||
return -1;
|
||||
} else {
|
||||
boardGrid[rank][file] = std::make_unique<King>(PIECE_BLACK);
|
||||
bKingPlaced = true;
|
||||
}
|
||||
break;
|
||||
case 'P':
|
||||
// white pawn
|
||||
boardGrid[rank][file] = std::make_unique<Pawn>(PIECE_WHITE);
|
||||
break;
|
||||
case 'p':
|
||||
// black pawn
|
||||
boardGrid[rank][file] = std::make_unique<Pawn>(PIECE_BLACK);
|
||||
break;
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
skip = atoi(sym);
|
||||
break;
|
||||
default:
|
||||
// invalid character?
|
||||
return -1;
|
||||
}
|
||||
file++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue