Allow drops without valid moves.

This commit is contained in:
yukirij 2024-12-27 19:56:45 -08:00
parent c107eb35ff
commit 3df4224448
2 changed files with 7 additions and 11 deletions

View File

@ -752,17 +752,13 @@ impl Game {
** A piece may not be dropped onto a position that puts the opposing king in check.
*/
let piece_moves = self.get_moves_data(&piece);
if piece_moves.len() > 0 {
if (flags & flags::IGNORE_CHECK as u32) == 0 {
for mv in piece_moves {
if mv.valid && mv.check.is_check() {
valid = false;
break;
}
if (flags & flags::IGNORE_CHECK as u32) == 0 {
for mv in piece_moves {
if mv.valid && mv.check.is_check() {
valid = false;
break;
}
}
} else {
valid = false;
}
valid

View File

@ -757,7 +757,7 @@ GAME.Game = class {
let tile = this.board.tiles[tile_id];
// Check if tile is occupied.
if(tile.piece === null) {
if(tile.piece === null && this.state.code == 0) {
let position_valid = true;
// Prevent placement that does not uncheck King.
@ -800,7 +800,7 @@ GAME.Game = class {
}
// Piece must have movements and not put king in check.
if(this.state.code == 0 && position_valid && movements.length > 0 && !checking) {
if(position_valid && !checking) {
valid = true;
}
}