diff options
Diffstat (limited to 'src/board.cpp')
| -rw-r--r-- | src/board.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/board.cpp b/src/board.cpp index 172a9be..54df662 100644 --- a/src/board.cpp +++ b/src/board.cpp @@ -36,7 +36,7 @@ Piece createPiece(pieceType type, bool color, bool moved) { piece.moved = moved; return piece; }; -void printBoard(board *b) { +void printBoard(Board *b) { std::string line = " +-----------------+\n"; std::string whiteLetters = " a b c d e f g h\n"; std::string blackLetters = " h g f e d c b a\n"; @@ -89,4 +89,17 @@ void printBoard(board *b) { std::println("Castling: {}", b->castle); } -// void PlayMove(Move move, board *b) { return; } +void PlayMove(Move move, Board *b) { + // TODO: add all fide behavior + Piece piece = b->pieces[PositionToIndex(move.From)]; + Piece piece2 = b->pieces[PositionToIndex(move.To)]; + if (piece2.type != NONE) { + if (piece2.color == b->turn) { + assert(false && "capturing friendly piece error"); + } + } + b->pieces[PositionToIndex(move.To)] = piece; + b->pieces[PositionToIndex(move.From)] = {false, NONE, false}; + return; +} +int PositionToIndex(Position i) { return i.rank * 8 + i.file; } |
