summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2023-01-06 15:22:22 -0800
committerKai Stevenson <kai@kaistevenson.com>2023-01-06 15:22:22 -0800
commit476c3bc7692442974c6d7533a59f7d26c5848fb5 (patch)
treedd189c4f82b5a30d73c1ab2302f04628843f173c
parent00458d7b95022e1daa604a59d236678ac33b3154 (diff)
added checkmate
-rw-r--r--chess.c17
1 files changed, 16 insertions, 1 deletions
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