diff options
| -rw-r--r-- | chess.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -34,7 +34,22 @@ int main() { draw_board(board.pieces); printf(turn == 0 ? "\nWhite's turn\n" : "\nBlack's turn\n"); if(is_in_check(board, turn)) { - printf("You're in check!\n"); + vectorpp_t allMoves = get_all_moves(board, turn, 0); + int checkmate = 0; + for(int i = 0; i < allMoves.length; i++) { + if(allMoves.vectorps[i].length > 0) { + continue; + } + checkmate = 1; + break; + } + if(checkmate) { + printf("You've been checkmated!\n"); + break; + } + else { + printf("You're in check!\n"); + } } printf("Enter the coordinates of the piece you want to move\n"); //get the selection for the piece to be moved |
