From 476c3bc7692442974c6d7533a59f7d26c5848fb5 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Fri, 6 Jan 2023 15:22:22 -0800 Subject: added checkmate --- chess.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/chess.c b/chess.c index 0671430..b913536 100644 --- a/chess.c +++ b/chess.c @@ -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 -- cgit v1.3.1