summaryrefslogtreecommitdiff
path: root/chess.c
diff options
context:
space:
mode:
Diffstat (limited to 'chess.c')
-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