diff --git a/assignment1-18/chessboard.c b/assignment1-18/chessboard.c index 2d348e8..dfac173 100644 --- a/assignment1-18/chessboard.c +++ b/assignment1-18/chessboard.c @@ -331,13 +331,19 @@ enum mstatus move( return INVALID; } + bool check_before_move = player_checks(cb, p == WHITE ? BLACK : WHITE); bool can = can_move(cb, p, from_row, from_col, to_row, to_col); if (!can) { return INVALID; } else { + // FIXME: check if move is allowed in check state cb_move(cb, from_row, from_col, to_row, to_col); if (player_checks(cb, p)) { + if (check_before_move) { + DEBUG("move: move does not end check state, invalid"); + return INVALID; + } // TODO: check checkmate return CHECK; } else {