Allow drops without valid moves.
This commit is contained in:
parent
c107eb35ff
commit
3df4224448
@ -752,17 +752,13 @@ impl Game {
|
|||||||
** A piece may not be dropped onto a position that puts the opposing king in check.
|
** A piece may not be dropped onto a position that puts the opposing king in check.
|
||||||
*/
|
*/
|
||||||
let piece_moves = self.get_moves_data(&piece);
|
let piece_moves = self.get_moves_data(&piece);
|
||||||
if piece_moves.len() > 0 {
|
if (flags & flags::IGNORE_CHECK as u32) == 0 {
|
||||||
if (flags & flags::IGNORE_CHECK as u32) == 0 {
|
for mv in piece_moves {
|
||||||
for mv in piece_moves {
|
if mv.valid && mv.check.is_check() {
|
||||||
if mv.valid && mv.check.is_check() {
|
valid = false;
|
||||||
valid = false;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
valid = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
valid
|
valid
|
||||||
|
@ -757,7 +757,7 @@ GAME.Game = class {
|
|||||||
let tile = this.board.tiles[tile_id];
|
let tile = this.board.tiles[tile_id];
|
||||||
|
|
||||||
// Check if tile is occupied.
|
// Check if tile is occupied.
|
||||||
if(tile.piece === null) {
|
if(tile.piece === null && this.state.code == 0) {
|
||||||
let position_valid = true;
|
let position_valid = true;
|
||||||
|
|
||||||
// Prevent placement that does not uncheck King.
|
// Prevent placement that does not uncheck King.
|
||||||
@ -800,7 +800,7 @@ GAME.Game = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Piece must have movements and not put king in check.
|
// 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;
|
valid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user