Invalid moves when checked now checked
This commit is contained in:
parent
635486c9b5
commit
be72018a0a
1 changed files with 6 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Reference in a new issue